The Core's admin account is always an admin of the app

Every app's .env gets CORE_ADMIN_EMAIL (admin@<domain>, the Core's own
admin, as Federated's apps use). The skill says apps make that account an
admin on each Core sign-in, trusting only Authelia's email, instead of a
setup link; the sso example apps show the check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 18:34:36 -07:00
co-authored by Claude Opus 5.5
parent da36a669bf
commit dca8837487
8 changed files with 54 additions and 13 deletions
+7 -2
View File
@@ -2,7 +2,7 @@
Authorization code flow with PKCE, and a signed session cookie. Settings
come from the environment (.env on the Core): APP_URL, APP_SECRET,
OIDC_ISSUER, OIDC_CLIENT_ID, OIDC_CLIENT_SECRET.
OIDC_ISSUER, OIDC_CLIENT_ID, OIDC_CLIENT_SECRET, CORE_ADMIN_EMAIL.
location, flow = start_login() # /login: redirect to Authelia
user = finish_login(query, flow) # /auth/callback: who signed in
@@ -29,6 +29,9 @@ ISSUER = os.environ["OIDC_ISSUER"].rstrip("/")
CLIENT_ID = os.environ["OIDC_CLIENT_ID"]
CLIENT_SECRET = os.environ["OIDC_CLIENT_SECRET"]
REDIRECT_URI = APP_URL + "/auth/callback"
# The Core's admin account (admin@<domain>) is always the app's admin. Only
# trusted here, from the Core's sign-in: never from an address someone types
CORE_ADMIN_EMAIL = os.environ.get("CORE_ADMIN_EMAIL", "").lower()
SESSION_SECONDS = 3600
FLOW_SECONDS = 600
@@ -100,7 +103,8 @@ def start_login():
def finish_login(query, flow_cookie):
"""Who signed in: {sub, name, email, groups}, from Authelia's answer."""
"""Who signed in: {sub, name, email, groups, admin}, from Authelia's
answer."""
flow = unsign(flow_cookie)
if not flow or not hmac.compare_digest(flow["state"], query.get("state", "")):
raise SignInError("The sign-in expired or didn't start here. Try again.")
@@ -132,6 +136,7 @@ def finish_login(query, flow_cookie):
"name": info.get("name") or info.get("preferred_username") or info["sub"],
"email": info.get("email", ""),
"groups": info.get("groups", []),
"admin": bool(CORE_ADMIN_EMAIL) and info.get("email", "").lower() == CORE_ADMIN_EMAIL,
}