fix(authentik): chaptarr verified-email mapping + ginnoir-only binding
Authentik's default email scope hardcodes email_verified=false, which Chaptarr's OIDC rejects. Chaptarr gets its own verified email mapping, and the app is bound to the ginnoir user so the email allowlist can't be matched by another account. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f92cad4d66
commit
e1fd7acce9
2 files changed
+23
No files matched your search
@@ -99,5 +99,26 @@ for slug, app_name, host, prefix, uris in OIDC:
|
|||||||
print(f"OIDC {slug}: provider pk={p.pk} created={created}")
|
print(f"OIDC {slug}: provider pk={p.pk} created={created}")
|
||||||
lines += [f"{prefix}_CLIENT_ID={p.client_id}", f"{prefix}_CLIENT_SECRET={p.client_secret}"]
|
lines += [f"{prefix}_CLIENT_ID={p.client_id}", f"{prefix}_CLIENT_SECRET={p.client_secret}"]
|
||||||
|
|
||||||
|
# chaptarr insists on email_verified=true, but authentik's default email
|
||||||
|
# mapping hardcodes False. Give chaptarr its own email mapping, and bind the
|
||||||
|
# app to ginnoir only so nobody can match the allowlist by editing their email.
|
||||||
|
from authentik.core.models import User
|
||||||
|
from authentik.policies.models import PolicyBinding
|
||||||
|
from authentik.providers.oauth2.models import ScopeMapping
|
||||||
|
|
||||||
|
verified, _ = ScopeMapping.objects.update_or_create(
|
||||||
|
name="homelab: OpenID 'email' (verified)",
|
||||||
|
defaults=dict(
|
||||||
|
scope_name="email",
|
||||||
|
description="Email address (marked verified)",
|
||||||
|
expression='return {"email": request.user.email, "email_verified": True}',
|
||||||
|
),
|
||||||
|
)
|
||||||
|
ch = OAuth2Provider.objects.get(name="homelab-chaptarr")
|
||||||
|
ch.property_mappings.set([SCOPES[0], SCOPES[2], verified.pk])
|
||||||
|
ch_app = Application.objects.get(slug="chaptarr")
|
||||||
|
PolicyBinding.objects.get_or_create(target=ch_app, user=User.objects.get(username="ginnoir"), defaults=dict(order=0))
|
||||||
|
print(f"OIDC chaptarr: verified-email mapping + ginnoir-only binding")
|
||||||
|
|
||||||
with open("/tmp/books-oidc.env", "w") as f:
|
with open("/tmp/books-oidc.env", "w") as f:
|
||||||
f.write("\n".join(lines) + "\n")
|
f.write("\n".join(lines) + "\n")
|
||||||
@@ -41,6 +41,8 @@ sudo chown -R 1000:1000 /config/chaptarr /config/calibre-web-automated /config/a
|
|||||||
- OIDC Authority: `https://auth.ginnoir.com/application/o/chaptarr/`
|
- OIDC Authority: `https://auth.ginnoir.com/application/o/chaptarr/`
|
||||||
- Scopes: `openid profile email`
|
- Scopes: `openid profile email`
|
||||||
- Allowed Emails: your Authentik account email(s)
|
- Allowed Emails: your Authentik account email(s)
|
||||||
|
- Authentik's default email mapping sends `email_verified: false`, and Chaptarr requires `true`. So the chaptarr provider uses its own mapping, `homelab: OpenID 'email' (verified)`. The app is also bound to the `ginnoir` user, so no other account can match the allowlist by changing its email.
|
||||||
|
- Changing anything in `stack.env` makes Portainer recreate every media container. Don't do it while you're in the middle of a login.
|
||||||
- **Audiobookshelf (Pattern A):** OIDC provider `homelab-audiobooks` (pk 46) plus app `audiobooks`. Its strict redirect URIs are `https://audiobooks.ginnoir.com/auth/openid/{callback,mobile-redirect}` and `audiobookshelf://oauth`. The client ID and secret are in `stack.env` (`ABS_OIDC_CLIENT_*`).
|
- **Audiobookshelf (Pattern A):** OIDC provider `homelab-audiobooks` (pk 46) plus app `audiobooks`. Its strict redirect URIs are `https://audiobooks.ginnoir.com/auth/openid/{callback,mobile-redirect}` and `audiobookshelf://oauth`. The client ID and secret are in `stack.env` (`ABS_OIDC_CLIENT_*`).
|
||||||
**Still to do in the ABS UI** (it keeps OIDC settings in its own database): go to Settings → Authentication → OpenID Connect.
|
**Still to do in the ABS UI** (it keeps OIDC settings in its own database): go to Settings → Authentication → OpenID Connect.
|
||||||
- Issuer URL: `https://auth.ginnoir.com/application/o/audiobooks/`. Click *Auto-populate*, then paste the client ID and secret.
|
- Issuer URL: `https://auth.ginnoir.com/application/o/audiobooks/`. Click *Auto-populate*, then paste the client ID and secret.
|
||||||
|
|||||||
Reference in new issue
Block a user