Admin SSO and Access Control
This describes the current, intended architecture for admin login (admin.alternun.co), as distinct from the AIRS mobile/web consumer login covered in Authentication and Session Flow. Both share the same Authentik instance, but the admin path uses a different flow shape and its own access-control gate.
Outer-Flow Source Stage
Admin login goes through a custom outer-flow SourceStage on top of stock Authentik, rather than a direct source login:
SourceStageViewsuspends the current (admin) flow execution, saves it as a pickledFlowPlanon aFlowToken, and redirects the browser into the chosen source (e.g. Google).- The source's own authentication/enrollment flow runs as normal, with a dynamic in-memory
SourceStageFinalstage injected at the end. SourceStageFinalrestores the original suspended admin flow from theFlowTokenand resumes it, completing the handoff back toadmin.alternun.co.
This lets the admin app sit behind a normal social login while keeping the admin flow itself in full control of what happens after the identity provider returns. It is implemented as a runtime patch applied to the identity container on every deploy — see packages/infra/scripts/templates/deploy-authentik.sh — not as stock Authentik behavior.
Access Control
Reaching admin.alternun.co requires two things, in order:
- Authentication — any user who can complete the outer-flow source login (e.g. via Google) reaches this point.
- Authorization — the
alternun-adminAuthentik application is gated by an expression policy,alternun-admin-access, that only allows users who belong toAlternun Dashboard Adminsorauthentik Admins.
A successful login does not imply admin access. A new admin must be added to one of those two groups explicitly; this is a deliberate authorization step, not something the identity bootstrap automates.
Operational Notes
- The outer-flow hotfix and the
alternun-admin-accesspolicy are both required, load-bearing parts of this path — they are not legacy code to be cleaned up. - If admin login loops indefinitely, suspect the outer-flow hotfix ordering (redirect must happen before session cleanup).
- If a real admin sees "Permission denied" after a successful login, add them to
Alternun Dashboard Admins. - Full incident history and root causes:
docs/alternun-authentik-admin-sso-incident-2026-08.mdin the repo root.