feat(media): chaptarr native OIDC instead of forward_auth
Deploy Caddyfile to valhalla / deploy (push) Successful in 1m23s
Deploy Caddyfile to valhalla / deploy (push) Successful in 1m23s
Chaptarr has built-in OIDC (/signin-oidc), so per the auth standard it gets Pattern A: new homelab-chaptarr OAuth2 provider, old forward_auth proxy provider removed, Caddy block reduced to internal_only + proxy. setup-books-auth.py now handles both OIDC apps generically. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e0240d8e10
commit
f92cad4d66
5 files changed
+72
-48
No files matched your search
@@ -275,21 +275,12 @@ stash.ginnoir.com {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# BOOKS — chaptarr / CWA / storyteller behind forward_auth; ABS uses native OIDC
|
# BOOKS — CWA / storyteller behind forward_auth; chaptarr + ABS use native OIDC
|
||||||
# (forward_auth would break the mobile app). All internal_only — remote access
|
# (forward_auth would break the ABS mobile app). All internal_only — remote access
|
||||||
# is via the tailnet (100.64.0.0/10 is already allowed by internal_only).
|
# is via the tailnet (100.64.0.0/10 is already allowed by internal_only).
|
||||||
chaptarr.ginnoir.com {
|
chaptarr.ginnoir.com {
|
||||||
import internal_only
|
import internal_only
|
||||||
route {
|
reverse_proxy chaptarr:8789
|
||||||
import authentik_outpost
|
|
||||||
handle /api/* {
|
|
||||||
reverse_proxy chaptarr:8789
|
|
||||||
}
|
|
||||||
handle {
|
|
||||||
import authentik_forward_auth
|
|
||||||
reverse_proxy chaptarr:8789
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
books.ginnoir.com {
|
books.ginnoir.com {
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Creates the books-stack Authentik providers/apps (idempotent). Run on valhalla.
|
# Creates the books-stack Authentik providers/apps (idempotent). Run on valhalla.
|
||||||
# Prints the audiobookshelf OIDC client id/secret path on success.
|
# Copies the OIDC client ids/secrets out on success.
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
here="$(cd "$(dirname "$0")" && pwd)"
|
here="$(cd "$(dirname "$0")" && pwd)"
|
||||||
docker cp "$here/setup-books-auth.py" authentik_server:/tmp/setup-books-auth.py
|
docker cp "$here/setup-books-auth.py" authentik_server:/tmp/setup-books-auth.py
|
||||||
docker exec authentik_server ak shell -c "exec(open('/tmp/setup-books-auth.py').read())" 2>&1 | grep -E '^(PROXY|OIDC)|Error|Traceback'
|
docker exec authentik_server ak shell -c "exec(open('/tmp/setup-books-auth.py').read())" 2>&1 | grep -E '^(PROXY|OIDC)|Error|Traceback'
|
||||||
docker cp authentik_server:/tmp/books-abs-oidc.env "${1:-./books-abs-oidc.env}"
|
docker cp authentik_server:/tmp/books-oidc.env "${1:-./books-oidc.env}"
|
||||||
docker exec authentik_server rm -f /tmp/books-abs-oidc.env /tmp/setup-books-auth.py
|
docker exec authentik_server rm -f /tmp/books-oidc.env /tmp/setup-books-auth.py
|
||||||
+54
-31
@@ -1,8 +1,9 @@
|
|||||||
# Authentik objects for the books stack (see stacks/media/BOOKS.md).
|
# Authentik objects for the books stack (see stacks/media/BOOKS.md).
|
||||||
# Idempotent. Run via scripts/run-books-auth.sh (ak shell inside authentik_server).
|
# Idempotent. Run via scripts/run-books-auth.sh (ak shell inside authentik_server).
|
||||||
# - forward_single proxy providers for chaptarr / books (CWA) / storyteller,
|
# - forward_single proxy providers for books (CWA) / storyteller, cloned from
|
||||||
# cloned from homelab-sonarr and attached to the embedded outpost
|
# homelab-sonarr and attached to the embedded outpost (Pattern B)
|
||||||
# - native OIDC provider for audiobookshelf (Pattern A)
|
# - native OIDC providers for chaptarr + audiobookshelf (Pattern A)
|
||||||
|
# Writes the OIDC client ids/secrets to /tmp/books-oidc.env in the container.
|
||||||
from authentik.core.models import Application
|
from authentik.core.models import Application
|
||||||
from authentik.crypto.models import CertificateKeyPair
|
from authentik.crypto.models import CertificateKeyPair
|
||||||
from authentik.flows.models import Flow
|
from authentik.flows.models import Flow
|
||||||
@@ -24,7 +25,6 @@ outpost = Outpost.objects.get(managed="goauthentik.io/outposts/embedded")
|
|||||||
|
|
||||||
FORWARD = [
|
FORWARD = [
|
||||||
# (slug, app name, host)
|
# (slug, app name, host)
|
||||||
("chaptarr", "Chaptarr", "chaptarr.ginnoir.com"),
|
|
||||||
("books", "Calibre-Web Automated", "books.ginnoir.com"),
|
("books", "Calibre-Web Automated", "books.ginnoir.com"),
|
||||||
("storyteller", "Storyteller", "storyteller.ginnoir.com"),
|
("storyteller", "Storyteller", "storyteller.ginnoir.com"),
|
||||||
]
|
]
|
||||||
@@ -50,31 +50,54 @@ for slug, app_name, host in FORWARD:
|
|||||||
)
|
)
|
||||||
print(f"PROXY {slug}: provider pk={p.pk} created={created} app={app.slug}")
|
print(f"PROXY {slug}: provider pk={p.pk} created={created} app={app.slug}")
|
||||||
|
|
||||||
outpost.save() # nudge the embedded outpost to pick up new providers
|
# chaptarr started on forward_auth; it has native OIDC, so drop the proxy provider.
|
||||||
|
old = ProxyProvider.objects.filter(name="homelab-chaptarr").first()
|
||||||
|
if old:
|
||||||
|
outpost.providers.remove(old)
|
||||||
|
old.delete()
|
||||||
|
print("PROXY chaptarr: removed old forward_auth provider")
|
||||||
|
|
||||||
abs_host = "audiobooks.ginnoir.com"
|
outpost.save() # nudge the embedded outpost to pick up provider changes
|
||||||
abs_p, created = OAuth2Provider.objects.get_or_create(
|
|
||||||
name="homelab-audiobooks",
|
|
||||||
defaults=dict(
|
def redirect(url):
|
||||||
client_type="confidential",
|
return {"url": url, "matching_mode": "strict", "redirect_uri_type": "authorization"}
|
||||||
authorization_flow=AUTH_FLOW,
|
|
||||||
invalidation_flow=INVALIDATION_FLOW,
|
|
||||||
sub_mode="hashed_user_id",
|
OIDC = [
|
||||||
signing_key=SIGNING_KEY,
|
# (slug, app name, host, env prefix, redirect URIs)
|
||||||
grant_types=["authorization_code", "refresh_token"],
|
("chaptarr", "Chaptarr", "chaptarr.ginnoir.com", "CHAPTARR_OIDC", [
|
||||||
_redirect_uris=[
|
redirect("https://chaptarr.ginnoir.com/signin-oidc"),
|
||||||
{"url": f"https://{abs_host}/auth/openid/callback", "matching_mode": "strict", "redirect_uri_type": "authorization"},
|
]),
|
||||||
{"url": f"https://{abs_host}/auth/openid/mobile-redirect", "matching_mode": "strict", "redirect_uri_type": "authorization"},
|
("audiobooks", "Audiobookshelf", "audiobooks.ginnoir.com", "ABS_OIDC", [
|
||||||
{"url": "audiobookshelf://oauth", "matching_mode": "strict", "redirect_uri_type": "authorization"},
|
redirect("https://audiobooks.ginnoir.com/auth/openid/callback"),
|
||||||
],
|
redirect("https://audiobooks.ginnoir.com/auth/openid/mobile-redirect"),
|
||||||
),
|
redirect("audiobookshelf://oauth"),
|
||||||
)
|
]),
|
||||||
if created:
|
]
|
||||||
abs_p.property_mappings.set(SCOPES)
|
|
||||||
Application.objects.update_or_create(
|
lines = []
|
||||||
slug="audiobooks",
|
for slug, app_name, host, prefix, uris in OIDC:
|
||||||
defaults=dict(name="Audiobookshelf", provider=abs_p, meta_launch_url=f"https://{abs_host}"),
|
p, created = OAuth2Provider.objects.get_or_create(
|
||||||
)
|
name=f"homelab-{slug}",
|
||||||
print(f"OIDC audiobooks: provider pk={abs_p.pk} created={created}")
|
defaults=dict(
|
||||||
with open("/tmp/books-abs-oidc.env", "w") as f:
|
client_type="confidential",
|
||||||
f.write(f"ABS_OIDC_CLIENT_ID={abs_p.client_id}\nABS_OIDC_CLIENT_SECRET={abs_p.client_secret}\n")
|
authorization_flow=AUTH_FLOW,
|
||||||
|
invalidation_flow=INVALIDATION_FLOW,
|
||||||
|
sub_mode="hashed_user_id",
|
||||||
|
signing_key=SIGNING_KEY,
|
||||||
|
grant_types=["authorization_code", "refresh_token"],
|
||||||
|
_redirect_uris=uris,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
if created:
|
||||||
|
p.property_mappings.set(SCOPES)
|
||||||
|
Application.objects.update_or_create(
|
||||||
|
slug=slug,
|
||||||
|
defaults=dict(name=app_name, provider=p, meta_launch_url=f"https://{host}"),
|
||||||
|
)
|
||||||
|
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}"]
|
||||||
|
|
||||||
|
with open("/tmp/books-oidc.env", "w") as f:
|
||||||
|
f.write("\n".join(lines) + "\n")
|
||||||
@@ -12,7 +12,7 @@ storyteller reads both libraries :ro ─► /storage1/labdata/storyteller (align
|
|||||||
|
|
||||||
| Service | Container:port | Host port | URL |
|
| Service | Container:port | Host port | URL |
|
||||||
|---|---|---|---|
|
|---|---|---|---|
|
||||||
| chaptarr | `chaptarr:8789` | 8789 | https://chaptarr.ginnoir.com (forward_auth, `/api/*` bypass) |
|
| chaptarr | `chaptarr:8789` | 8789 | https://chaptarr.ginnoir.com (native OIDC, LAN + tailnet only) |
|
||||||
| calibre-web-automated | `calibre-web-automated:8083` | 8083 | https://books.ginnoir.com (forward_auth, `/opds*` + `/kobo/*` bypass) |
|
| calibre-web-automated | `calibre-web-automated:8083` | 8083 | https://books.ginnoir.com (forward_auth, `/opds*` + `/kobo/*` bypass) |
|
||||||
| audiobookshelf | `audiobookshelf:80` | 13378 | https://audiobooks.ginnoir.com (native OIDC, LAN + tailnet only) |
|
| audiobookshelf | `audiobookshelf:80` | 13378 | https://audiobooks.ginnoir.com (native OIDC, LAN + tailnet only) |
|
||||||
| storyteller | `storyteller:8001` | 8001 | https://storyteller.ginnoir.com (forward_auth, `/api/*` bypass) |
|
| storyteller | `storyteller:8001` | 8001 | https://storyteller.ginnoir.com (forward_auth, `/api/*` bypass) |
|
||||||
@@ -35,7 +35,12 @@ sudo chown -R 1000:1000 /config/chaptarr /config/calibre-web-automated /config/a
|
|||||||
|
|
||||||
`scripts/run-books-auth.sh` creates everything below (idempotent, runs `scripts/setup-books-auth.py` through `ak shell`). **Done on 2026-10-18.**
|
`scripts/run-books-auth.sh` creates everything below (idempotent, runs `scripts/setup-books-auth.py` through `ak shell`). **Done on 2026-10-18.**
|
||||||
|
|
||||||
- **chaptarr / books / storyteller (Pattern B):** proxy providers `homelab-{chaptarr,books,storyteller}` (pk 43–45). They're `forward_single`, cloned from `homelab-sonarr`, attached to the embedded outpost, and each has an app with the same slug.
|
- **books / storyteller (Pattern B):** proxy providers `homelab-{books,storyteller}` (pk 44–45). They're `forward_single`, cloned from `homelab-sonarr`, attached to the embedded outpost, and each has an app with the same slug.
|
||||||
|
- **Chaptarr (Pattern A):** OIDC provider `homelab-chaptarr` (pk 47) plus app `chaptarr`, with the strict redirect URI `https://chaptarr.ginnoir.com/signin-oidc`. This replaced the forward_auth provider it started with (pk 43). The client ID and secret are in `stack.env` (`CHAPTARR_OIDC_CLIENT_*`).
|
||||||
|
In Chaptarr, go to Settings → General → Authentication, choose OIDC, and fill in:
|
||||||
|
- OIDC Authority: `https://auth.ginnoir.com/application/o/chaptarr/`
|
||||||
|
- Scopes: `openid profile email`
|
||||||
|
- Allowed Emails: your Authentik account email(s)
|
||||||
- **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.
|
||||||
|
|||||||
@@ -12,3 +12,8 @@ STORYTELLER_SECRET_KEY=5b41f526eb62c2fbe17527b65a0e71ff06d5927fbeb869541f52e812b
|
|||||||
# ABS stores OIDC config in its own DB (Settings → Authentication).
|
# ABS stores OIDC config in its own DB (Settings → Authentication).
|
||||||
ABS_OIDC_CLIENT_ID=H617VXaM04KA0URJyWI52ThBpC3crIAZY77UYlzt
|
ABS_OIDC_CLIENT_ID=H617VXaM04KA0URJyWI52ThBpC3crIAZY77UYlzt
|
||||||
ABS_OIDC_CLIENT_SECRET=1Tmw0PLw8CP82JX4Vz5nuOfpykh6XKngrU8a4Vspc6ZsIarJn3mG5GwKre1D5DnVqfF7MXbOc5g83lkR7NUcHPjlj3QgPX4BFnbUdl2r09LHrcH9X8CY4gJP0Sl1hdcr
|
ABS_OIDC_CLIENT_SECRET=1Tmw0PLw8CP82JX4Vz5nuOfpykh6XKngrU8a4Vspc6ZsIarJn3mG5GwKre1D5DnVqfF7MXbOc5g83lkR7NUcHPjlj3QgPX4BFnbUdl2r09LHrcH9X8CY4gJP0Sl1hdcr
|
||||||
|
|
||||||
|
# chaptarr — Authentik OIDC client (homelab-chaptarr, pk 47). Reference only:
|
||||||
|
# chaptarr stores OIDC config in its own DB (Settings → General → Authentication).
|
||||||
|
CHAPTARR_OIDC_CLIENT_ID=BlQNRexLVkgUuH8j0ybmFSiD93dw1mBUF6tsjG6b
|
||||||
|
CHAPTARR_OIDC_CLIENT_SECRET=THoqN0qLbPuni9cg0vqeid200VsgXKs1WihOSYV8NqciIcp6eCTmvYeRHKYWxF7jOiCBUdL3kP6e4e06SeQr0vwzFSz8rLYYCRomQqizv1iWfRGv0HjfDgkNj49rwrz6
|
||||||
Reference in new issue
Block a user