Shorten the skill into reference files; fixes from the Miniflux rehearsal

SKILL.md keeps what every app needs; sign-in details and publishing move
to references/sign-in.md and references/publishing.md, read when it says.
A Miniflux rehearsal found coreapp signin calling a quiet callback failure
"Signed in": it now checks the app's page doesn't offer sign-in again.
Every app gets CORE_PROXY (traefik's address). The skill says groups is
null (don't map roles from it), claims come from userinfo, and to wait
for Authelia's discovery and the database at startup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 20:14:06 -07:00
co-authored by Claude Opus 5.5
parent adcd2f9aec
commit a7cd4e325c
9 changed files with 319 additions and 176 deletions
+53
View File
@@ -0,0 +1,53 @@
# Publishing a release, and installing it from its repository
Read this only when the user asks for a release, or to install an app from
its repository. Publishing pushes to the user's registry and tags their
repository, so don't do it on your own.
## Publishing
A published app is a tagged commit in its repository plus its image in a
registry, from which any Core can install it.
1. Set `image` in `coreapp.toml` to the registry: for an app on a Gitea
server, `<gitea-host>/<owner>/<repo>` in lowercase (Gitea's container
registry is on the same host). `coreapp publish` suggests one from the
git remote. `coreapp deploy` keeps working with that name.
2. Raise `version` if this version was published before (published
versions are never replaced).
3. Commit everything; `coreapp publish` refuses uncommitted changes.
4. `coreapp publish` builds the image for linux/amd64 (add
`--platform linux/amd64,linux/arm64` for ARM Cores too), pushes
`image:version`, and tags the commit `v<version>`. It needs
`docker login <registry>` first; that's the user's to do (for Gitea,
with a token that has the `write:package` scope).
5. The user pushes the commit and tag: `git push && git push origin v<version>`.
New apps also have `.gitea/workflows/publish.yml`, which does the same on
the Gitea server when a `v*` tag is pushed, if the repository has an
Actions runner that can use Docker and the secrets `REGISTRY_USER` and
`REGISTRY_TOKEN`. When porting an existing app, copy it from a new app
(`coreapp new x`) if the user wants it.
## Installing from the repository
To check a release the way a Core's owner will get it:
- `coreapp install https://<gitea-host>/<owner>/<repo>` installs it on the
Core in the VM from the repository (the newest `v*` tag; `@v1.2.0` for
another), pulling the published image. `coreapp update <name>` moves it
to a newer release.
- The Core reads only `coreapp.toml` and `icon.png` from the repository;
`version` has to match the tag.
- Coreapps are often private: for a private repository and image, the Core
needs a token for the host first, `coreapp login <gitea-host>`, which asks
for a user name and a read-only token (repositories and packages). That's
the user's to enter, not yours.
- On the same Core, `coreapp deploy` from the folder and `coreapp install`
from the repository update the same app (same name, data and database).
- A Core keeps running the image it installed, by digest: a release can't
be fixed by pushing its tag again (installing it again is refused), so
publish a new version.
- Going back to an older release needs `coreapp install --downgrade
<url>@v<old>`; the user decides that, since the older version may not
understand the newer one's data.
+147
View File
@@ -0,0 +1,147 @@
# Sign-in with Core accounts: the details
Read this when the app has `needs = ["sso"]`: to fit the Core's client to
the app, to put the admin and role rules into the app, and to test sign-in.
SKILL.md has the summary.
## Fitting the client to the app
The Core's client, by default: redirect URI exactly
`https://<name>.<domain>/auth/callback` (`$APP_URL/auth/callback`),
authorization code flow, PKCE with S256 required, the secret sent with
`client_secret_basic` (in the Authorization header).
If the app's sign-in can't be configured to match (many have a fixed
callback path, and many don't send PKCE), change the client in
`coreapp.toml` instead of working around it in the app:
```toml
[sso]
callback = "/auth/openid/core" # the app's callback path (default "/auth/callback")
pkce = false # the app doesn't send PKCE (default true)
token_auth = "client_secret_post" # it sends the secret in the form (default client_secret_basic)
```
Set only what the app needs, and say in a comment why. Find out from the
app's documentation or source:
- the callback path it puts in `redirect_uri` (sometimes built in the
browser, e.g. `/auth/openid/<provider key>`; then pick the key so the
path is known),
- whether it sends `code_challenge`,
- how it sends the secret.
Authelia checks the redirect URI when sign-in starts (an error page instead
of its login page if it's wrong), but PKCE and the secret only after the
person has signed in, so a curl of the authorize URL can't show those are
right; `coreapp signin` can. Changing `[sso]` and deploying registers the
client again; Authelia restarts for it (a few seconds of 404s from it).
Many apps fetch discovery only once at startup: wait for it in the
entrypoint (SKILL.md, "Wait for what it needs at startup").
Use the app's own OpenID Connect support or its framework's library: most
self-hosted apps have "generic OIDC" settings that map onto `OIDC_*`. If
the app has its own step for setting up its client (an admin makes a
secret in its settings, or pastes a client block into the identity
provider), skip it on the Core: fill its settings from `OIDC_*`, so
sign-in works with no admin step, and don't show those instructions when
the Core gave the client. `coreapp new --sso example` makes a
standard-library Python example of the whole flow (`oidc.py`).
## What Authelia says about the person
- Scopes: `openid profile email groups`. The claims come from the
userinfo endpoint: `sub`, `email` (with `email_verified: true`), `name`
(the account's uid, e.g. `coreapp.test`), `preferred_username` (the
email address, which is what people sign in with), `groups`. The ID token
has none of them, so an app that reads the person only from the ID token
gets no email or name: turn on its "use userinfo" setting.
- `groups` is `null` on today's Cores, not a list: they have two groups,
`admins` and `everybody`, but Authelia's settings don't find them yet
(for Federated to fix). Don't turn on an app's group-to-role mapping:
apps that expect a list fail every sign-in on `null` (Miniflux: "groups
must be a string or a list of strings").
- An app that can make admins only from a group (no way to name one by
email) can't follow the admin rule yet: leave its admins off, say so in
your report, and note that once groups work, mapping the Core's
`admins` group would do it (the user decides).
- Discovery: `$OIDC_ISSUER/.well-known/openid-configuration`. The Core
routes `authelia.<domain>` from inside the app's container to the real
HTTPS endpoint, with a valid certificate, so normal TLS verification
works.
- Sign-out in the app ends the app's session; the person stays signed in
to the Core.
## Putting the admin and role rules into the app
The rules are in SKILL.md: `CORE_ADMIN_EMAIL` is always an admin, everyone
else gets the lowest role that can look around. How:
- Check the admin on every Core sign-in, from the `email` Authelia gives
(compared case-insensitively), and make that account an admin (back) if
it isn't. Never from an address typed into the app: no local account,
sign-up or invitation with that address becomes an admin.
- If the app has its own first-run setup (an owner to create, a setup
link), skip it on a Core: the Core's admin is the owner. If the app
can't run without an owner (its pages say "not set up" until there is
one), make `CORE_ADMIN_EMAIL` the owner at startup, without a password.
- That account signs in only with the Core: turn off the app's password
sign-in and password reset for it, or its forgot-password page could
give it a local password.
- Other Core accounts join on their first Core sign-in, without an
invitation, as read-only members (a viewer: they see what members see,
change nothing). Not "nothing until an admin grants access".
- The example app (`coreapp new --sso`) shows the admin check in `oidc.py`.
## Testing sign-in: coreapp signin
`coreapp signin` signs in to the app as a browser would, on the real
Authelia with the app's real client, as the Core's test account
(`coreapp.test@<domain>`, display name `coreapp.test`, in no groups; made
on the Core in the VM when first needed, with a new password each time).
It prints each step, with Authelia's error if the client doesn't fit, and
says whether it got back to the app signed in. Run it in the app's folder
(it reads `coreapp.toml`).
```bash
coreapp signin # starts at /login
coreapp signin /auth/login # the app's own page that starts sign-in
coreapp signin /signin # a page whose button starts sign-in: pressed
jar=$(mktemp) && coreapp signin --cookies "$jar" /login && curl -b "$jar" https://<name>.<domain>/api/me
```
- A page with a sign-in button (a form with only hidden fields, such as a
CSRF token) is submitted as a person pressing it would; with several such
forms, pick one with `--form <action>`. Don't add routes to the app just
for the test.
- With `--cookies`, check what the test account may do: it should land as
a read-only member. Keep the jar's path in one command, as above
(`$TMPDIR` can differ between a sandboxed shell and `coreapp`'s).
- "Signed in" needs the app to have kept the person: if its page offers
sign-in again (its callback failed quietly), `coreapp signin` says "Not
signed in ... offers sign-in again"; `coreapp logs` has the app's reason.
- Apps whose sign-in starts in the browser's JavaScript (single-page apps:
the page builds the authorize URL itself): `coreapp signin --code` starts
at Authelia with the app's client and stops at the app's callback,
printing it with the code; give that to the app as its page would (e.g.
Vikunja's: `POST /api/v1/auth/openid/<key>/callback` with `code` and
`redirect_url`). Its `state` isn't the app's, so a server-side callback
that checks state refuses it: use the path form for those.
- Authelia bans an account for a few minutes after repeated failed
sign-ins, so don't loop on it.
The test account isn't the admin, so ask the user to sign in once in a
browser as `admin@<domain>` before a release: it checks what a script
can't (the app's pages, and that the admin gets the admin role).
## When sign-in fails
`coreapp signin` shows Authelia's error and hint:
- "The 'redirect_uri' parameter does not match": the app's callback isn't
the client's (`[sso] callback`).
- "invalid_client": it sends the secret another way (`[sso] token_auth`).
- A PKCE error: `[sso] pkce` doesn't match what the app does.
- "didn't lead to the Core's sign-in": the path doesn't start sign-in; give
the right one, `--form` for a page with several buttons, or `--code` for
a single-page app.