Authelia OIDC as Forgejo login source (was deferred, now unblocked) #33
Labels
No labels
blocked
conflicted
curated
in-progress
in-review
needs-decision
No milestone
No project
No assignees
1 participant
Due date
No due date set.
Dependencies
No dependencies set
Reference
larandar/flaky-mesh#33
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Stable ID: FM-FORGE-OIDC
Source: DEFERRED.md + backlog.md (was deferred "until forge is stable"); owner ruling 2026-08-06: unblocked
Disposition: open — prerequisite of mesh decommission (#32)
Blocked by: nothing (owner confirms forge is stable enough)
Epic: #32 (mesh decommission)
Problem
git cloneover HTTPS is performed by git, not a browser. It cannot follow aredirect to a login page. Putting
jo.et0.pwbehind Caddyforward_authbreaks git over HTTPS, breaks
just forgejo(receives login HTML instead ofJSON), and breaks any CI pulling from the forge.
The solution is OIDC as a Forgejo login source, not forward_auth. Authelia
serves as an OAuth2/OIDC provider; Forgejo consumes it as an auth source. Web
UI login goes through Authelia; git over HTTPS keeps using Forgejo tokens; git
over SSH keeps using keys; the API keeps using its token.
This was deferred until the forge was stable. The owner confirms it is now
unblocked.
Scope
Per backlog.md (fully scoped already):
Turn the OIDC provider on.
outputs/hosts/heimdallr/configuration.nix~line 75 — uncomment
oidcHmacSecretFile,oidcIssuerPrivateKeyFile, andthe
settingsFilesentry forauthelia/oidc_clients. Secrets alreadyexist and are decrypted; only the wiring is commented out.
Register an
authorization_codeclient.just identity register-servicedoes NOT cover this — it mintsgrant_types: [client_credentials]service accounts. Forgejo needsauthorization_codewithredirect_uris = ["https://jo.et0.pw/user/oauth2/authelia/callback"].Either a new recipe or a hand-edit of
authelia/oidc_clients.Add the auth source in Forgejo — not declarative. Forgejo stores auth
sources in its database; NixOS has no option for it:
forgejo-admin admin auth add-oauth --name authelia --provider openidConnect …, once, on the box.ENABLE_AUTO_REGISTRATION = true. Registration is disabled in themodule, so without this an Authelia login lands on "no such account" and
nobody can get in. The symptom does not point at the cause.
Known cost
Step 3 is not reproducible from the repo. A freshly provisioned bifrost has a
forge with no Authelia auth source until someone runs the command again. Same
exposure as the first admin account — not a new class of problem, just a
second instance of one.
Acceptance
authorization_codeclient registered inauthelia/oidc_clientsforgejo-admin admin auth add-oauth)ENABLE_AUTO_REGISTRATION = truegit clone https://jo.et0.pw/...still works (token auth, unaffected)just forgejostill works (API token auth, unaffected)git clone git@...still works (SSH keys, unaffected)Provenance
From backlog.md and DEFERRED.md, where this was fully scoped and deferred
until the forge stabilized. Owner ruling 2026-08-06: unblocked. It is now a
prerequisite of the mesh decommission (#32) — without it, moving the forge to
public ingress breaks git over HTTPS.
Implemented in flake-ops (heimdallr's closure moved there; the paths in this ticket's scope are the flaky-mesh ancestors). Status against the acceptance list:
Done in config (uncommitted in flake-ops, eval-verified, awaiting deploy):
modules/hosts/heimdallr/configuration.nixwiresoidcHmacSecretFile,oidcIssuerPrivateKeyFile, andsettingsFiles = [ oidc_clients ], in the same change as the first client (this ticket's original step order was wrong; provider-before-client makes Authelia refuse to start).authorization_codeclient registered —authelia/oidc_clientsinmodules/hosts/heimdallr/secrets.yamlnow holds:client_id: forgejo,authorization_policy: one_factor,consent_mode: implicitredirect_uris: [https://jo.et0.pw/user/oauth2/authelia/callback](bound to the auth source being namedauthelia— rename one, rename both)require_pkce: true/S256,token_endpoint_auth_method: client_secret_basic, scopesopenid email profile groupsauthelia crypto hash generate pbkdf2— digest in heimdallr's client entry, plaintext in bifrost'smodules/hosts/bifrost/secrets.yamlasforgejo/oidc_client_secret, wired as a root-owned sops secret on bifrost so the hand-run step can read it at/run/secrets/forgejo/oidc_client_secret. Neither value ever appeared on a terminal.services.forgejo.settings.oauth2_client.ENABLE_AUTO_REGISTRATION = trueon bifrost.Hand-run step (operator, on bifrost, after both hosts carry the new closures):
Note the ordering: heimdallr must be deployed first (bifrost is unarmed anyway — flake-ops#44) — the auth source is harmless to add early, but a login attempt before heimdallr carries the client gets
invalid_clientat Authelia.Verify (last four acceptance boxes): web login via the Authelia button;
git cloneover HTTPS with a token,just forgejo, and SSH clones are all untouched by design — the vhost stays out of forward_auth.Known cost stands: the auth source lives in Forgejo's database; a re-provisioned bifrost needs the command run again (same class as the first admin account).
Complete, owner-verified 2026-08-09: web login through Authelia works on
jo.et0.pw, existing admin account linked via the one-time bridge; git-over-HTTPS tokens, SSH clones and the API were never in the OIDC path by design.Every acceptance box:
authorization_codeclientforgejoinauthelia/oidc_clientsforgejo-admin admin auth add-oauth --name authelia …, source id 1)ENABLE_AUTO_REGISTRATION = true(bifrost, live)One deviation from the client registration as first minted:
require_pkceis now false — Forgejo'sopenidConnectsource sends nocode_challenge(no CLI flag for it), and Authelia hard-rejects the authorization when PKCE is enforced ("Clients must include a 'code_challenge'…"). A confidential client with a pbkdf2-hashed secret over TLS stands without it. If a PKCE toggle appears in Forgejo's auth-source UI, re-enforcing is one sops edit on heimdallr.Context that made this land today: bifrost was armed and took its first flake-ops closure (flake-ops#44), which is what put the decrypted client secret and auto-registration on the box.