coreapp new --sso: sign-in through the Core's Authelia

A template overlay (templates/sso) registers the app as an OpenID Connect
client in Authelia's idproviders.yml (between markers, secret hashed by
the running Authelia), checks the configuration before restarting
Authelia and restores it if the check fails; uninstall removes the client.
The app reaches Authelia's https address through traefik (@TRAEFIK_IP@,
provided by the template's install and by redeploys). The example is a
standard-library Python OIDC client (code flow with PKCE). Tested by
install, redeploy, remove and reinstall, and a real sign-in in a browser.

Also: the postgres overlay appends to the base install, uninstall and
env.in; database names get a coreapp_ prefix (PostgreSQL reserves pg_*);
deploy waits until the app answers on its own address.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 12:34:27 -07:00
co-authored by Claude Opus 5.5
parent 74bdc13f0f
commit 284f52fc29
19 changed files with 419 additions and 37 deletions
+23 -4
View File
@@ -173,14 +173,33 @@ no `blackboxregistrar` request.
### With a database
1. `coreapp new --postgres guest-book`: has `app.py`, no `www/`;
`service` has `DEPENDS="postgresql"`; `env.in` has `DB_NAME=guest_book`
`service` has `DEPENDS="postgresql"`; `env.in` has `DB_NAME=coreapp_guest_book`
and a random `DB_PASSWORD`; the README has a Database section.
2. `coreapp deploy`, `coreapp check`. Loading the page several times
(`curl -s https://guest-book.<domain>/ | grep visits`) counts up. On the
Core, `docker exec postgresql psql -U postgres -l` lists `guest_book`,
owned by `guest_book`.
Core, `docker exec postgresql psql -U postgres -l` lists `coreapp_guest_book`,
owned by `coreapp_guest_book`.
3. Change `app.py`, `coreapp deploy`: the change shows, the count continues.
4. `virsh -c qemu:///system reboot coreserver`: once the Core is up, the
app answers and the count continues (its log may show "Waiting for the
database" first).
5. `coreapp remove`: the `guest_book` database and user are gone too.
5. `coreapp remove`: the `coreapp_guest_book` database and user are gone too.
### With sign-in
1. `coreapp new --sso sso-demo`: has `app.py`, no `www/`; `service` has
`DEPENDS="authelia"`; `docker-compose.yml.in` has `extra_hosts` with
`@TRAEFIK_IP@`; `env.in` has `OIDC_*`; the README has a Sign-in section.
`coreapp new --sso --postgres x` refuses.
2. `coreapp deploy`, `coreapp check`. On the Core, `idproviders.yml` has one
`### coreapp-sso-demo begin` block; Authelia is healthy;
`docker exec authelia authelia validate-config` is OK; no `*.bak` is
left; the rendered compose file maps `authelia.<domain>` to traefik's
address.
3. `https://sso-demo.<domain>/login` redirects to
`https://authelia.<domain>/api/oidc/authorization?...client_id=coreapp-sso-demo...code_challenge_method=S256`.
4. In a browser, sign in with a Core account: the page says "Signed in as
..." with the account's email and groups. "Sign out" goes back to the
sign-in link.
5. Redeploy: still one client block. `coreapp remove`: none, Authelia
healthy, other clients (Nextcloud) still work. Deploy again: one block.