fix(forgejo): allow anonymous public-repo browsing, block anon registry tokens at CF edge

REQUIRE_SIGNIN_VIEW was the F11 mitigation for ghost-user /v2/token grants,
but it also forced every public repo to a login page. Move the guard to a
Cloudflare custom rule that blocks /v2/token unless the request carries
Basic auth, and turn public browsing back on.
This commit is contained in:
Lance Walters 2026-12-01 22:27:43 -05:00
commit b909456a3e
2 changed files with 37 additions and 21 deletions

View file

@ -58,17 +58,17 @@ spec:
# Bot signup lockdown: admin-only account creation (web + API).
- name: FORGEJO__service__DISABLE_REGISTRATION
value: "true"
# Registry hardening (audit F11): Forgejo hands an anonymous
# ("ghost user") token to /v2/token and grants Read on every
# package, regardless of the owning repo's visibility, so all app
# images were world-downloadable. With REQUIRE_SIGNIN_VIEW the
# token endpoint answers UNAUTHORIZED to anonymous clients and
# containerd pulls need a dockerconfigjson secret per namespace
# (`forgejo-pull`, created out of band — docs/registry-pull-auth.md).
# Side effect: the Forgejo web UI/API is login-only for anonymous
# visitors, including the public repos.
# Public-repo browsing is ON. Audit F11 had turned this on because
# Forgejo issues anonymous ("ghost user") registry tokens at
# /v2/token with Read on every package, so with public browsing
# every app image was world-pullable. That coupling is now cut at
# the edge instead: a Cloudflare zone custom rule ("Block anonymous
# Forgejo registry tokens") blocks /v2/token unless the request
# carries Basic auth, so anonymous pulls get 403 while containerd
# (which sends its `forgejo-pull` dockerconfigjson credentials)
# still pulls. Re-check that rule before turning this back to true.
- name: FORGEJO__service__REQUIRE_SIGNIN_VIEW
value: "true"
value: "false"
volumeMounts:
- name: data
mountPath: /data