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
+59 -169
View File
@@ -55,6 +55,7 @@ What the Core gives every app:
| `IMAGE_VERSION` | The installed version (`coreapp deploy` builds with plain `docker build .`, no build args, so read the version from here, not a build-time `VERSION`) |
| `CORE_DOMAIN` | The Core's domain (`<domain>`). Set only on a Core: an app that also runs elsewhere can use it to tell |
| `CORE_ADMIN_EMAIL` | `admin@<domain>`, the Core's admin account: always an admin of the app (see `sso`) |
| `CORE_PROXY` | traefik's address, the only proxy in front of the app: the one to trust for `X-Forwarded-For` and `X-Forwarded-Proto` |
`APP_SECRET` isn't hex or base64: an app that wants key bytes (e.g. 32
bytes for encryption) derives them, e.g. SHA-256 of `APP_SECRET`. It
@@ -155,14 +156,11 @@ The Core makes a PostgreSQL user and database just for this app, and adds:
| `DB_NAME`, `DB_USER` | `coreapp_<name>` with `-` as `_` (e.g. `coreapp_my_app`) |
| `DB_PASSWORD` | random |
The server is PostgreSQL 17 (17.6 today; `coreapp core` shows the Core's
version, and `coreapp status` once the app needs it), shared with the Core's other apps; the app owns its database and
nothing else. Check what version the app needs before choosing this (its
docs, its own compose file's `postgres:` image, its migrations): features
of a newer PostgreSQL fail only when the code that uses them runs, so a
deploy, `coreapp check` and a sign-in can all pass on the wrong version.
If it needs a newer one, see "Not available yet". There's no superuser access, so the app creates
its own tables (migrations at startup are the usual way). At boot the
The server is the Core's PostgreSQL (its version and extensions: "What the
Core offers"; check the app's needs against them first), shared with the
Core's other apps; the app owns its database and nothing else. There's no
superuser access, so the app creates its own tables (migrations at startup
are the usual way). At boot the
database may come up after the app: retry the connection instead of
exiting. Many apps want a URL; build it from these variables in the
entrypoint or the app's config (e.g.
@@ -198,85 +196,31 @@ and adds:
| `OIDC_CLIENT_ID` | `coreapp-<name>` |
| `OIDC_CLIENT_SECRET` | random |
The client, by default:
By default the client's redirect URI is `$APP_URL/auth/callback`, PKCE
(S256) is required and the secret goes in the Authorization header
(`client_secret_basic`). Many apps have a fixed callback path or no PKCE:
then fit the client to the app with `[sso]` in `coreapp.toml` (`callback`,
`pkce`, `token_auth`), never with a workaround in the app. Use the app's
own OpenID Connect support ("generic OIDC" settings) with `OIDC_*`.
- Redirect URI: exactly `https://<name>.<domain>/auth/callback`
(`$APP_URL/auth/callback`).
- Authorization code flow, PKCE with S256 required, client authentication
`client_secret_basic` (secret in the Authorization header).
Two rules for who may do what, on every Core:
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:
- **The Core's admin is the app's admin.** `CORE_ADMIN_EMAIL`
(`admin@<domain>`, the Core's own admin) is always an admin of the app:
made one (again) on each Core sign-in, trusted only from the email
Authelia gives, never from an address typed into the app. No setup link,
no first-come owner; it signs in only with the Core.
- **Everyone else gets the lowest role that can look around.** Any other
Core account may sign in, without an invitation, as a read-only member
(a viewer). The app's admins raise people from there. In an app where
each person has only their own private things (a feed reader, notes),
a regular user is the lowest role.
```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`,
and how it sends the secret. Authelia checks the redirect URI when the
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 (see
"Deploy and test"). Changing
`[sso]` and deploying registers the client again; Authelia restarts for it
(a few seconds of 404s from it, which an app checking discovery at startup
may log; it should retry).
- Scopes: `openid profile email groups`. Userinfo gives `sub`,
`preferred_username`, `name`, `email`, and `groups`, which is empty on
today's Cores: they have two groups, `admins` and `everybody`, but
Authelia's settings don't find them yet (for Federated to fix). Read `groups`
if the app can use it, but don't depend on it for roles.
- **The app's admin is the Core's admin.** On a Core, the account
`CORE_ADMIN_EMAIL` (`admin@<domain>`, the Core's own admin, as in
Federated's apps) is always an admin of the app, from its first sign-in:
no setup link, no first-come owner. It can then make other people admins
in the app. Two rules:
- Trust it only from the Core's sign-in: the `email` in Authelia's
userinfo or ID token, compared case-insensitively. Never make a local
account, a sign-up or an invitation with that address an admin; anyone
could type it.
- Every time, not only the first: if its admin role was taken away in
the app, its next Core sign-in gives it back.
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; it
signs in with the Core. 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. The example app
(`coreapp new --sso`) shows the check in `oidc.py`. `coreapp signin`
signs in as the test account, not the admin, so ask the user to sign in
once as `admin@<domain>` in a browser and check it gets the admin pages.
- **Everyone else gets the lowest role.** Any other Core account (a person
at the company) may sign in, with no invitation, and gets the app's
lowest role that can still look around: read-only, seeing what the app
shows its members but changing nothing (a viewer). Not "nothing until an
admin grants access": they should find the app useful to look at. The
app's admins raise people from there in the app. Don't hand out more by default, and don't
require invitations for Core accounts. `coreapp signin` checks this: the
test account should land with that role.
- 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.
Use the app's own OpenID Connect support or its framework's library where it
has one: most self-hosted apps have "generic OIDC" settings that map onto
these variables. 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. For a standard-library Python example of the whole flow,
`coreapp new --sso example` makes one (`oidc.py`).
**Before writing sign-in code, read
[references/sign-in.md](references/sign-in.md):** how to find what the app
needs for `[sso]`, how to build the two rules into the app (first-run
setup, password reset), what Authelia tells the app (its `groups` are
empty today), and how to test sign-in with `coreapp signin`.
### `email`: sending mail
@@ -352,8 +296,11 @@ and make the Dockerfile fit the Core:
- **Listen on `0.0.0.0` and on `port`**, plain HTTP. No TLS in the app.
- **Know its public address**: `APP_URL` (many apps need a "base URL" or
"trusted host" setting; it's behind a proxy that sends `X-Forwarded-Proto:
https` and `X-Forwarded-For`).
"trusted host" setting). It's behind traefik, which sends
`X-Forwarded-Proto: https` and `X-Forwarded-For`: set the app's "trusted
proxies" to `CORE_PROXY` (so it logs and rate-limits by the real client
address), and turn on its "behind HTTPS" or secure-cookie setting if it
has one, since it sees plain HTTP itself.
- **Keep state in `/data`**: point upload folders, SQLite files and
generated keys there. If the app needs a directory structure under `/data`,
create it at startup (it starts empty).
@@ -377,6 +324,18 @@ and make the Dockerfile fit the Core:
otherwise, and on a Core nobody else sets them. (In the app's own code,
as above, the Core's values are defaults that the app's explicit
settings override: that's for its other editions, not upstream `ENV`.)
Before writing the entrypoint, look at how the upstream image starts
(`docker inspect -f '{{json .Config.Entrypoint}} {{json .Config.Cmd}}'
<image>`): end yours by running what it ran (`exec` its entrypoint with
`"$@"`, or `exec "$@"` when it only has a `CMD`).
- **Wait for what it needs at startup** if it only checks once: the
database may come up after the app on a reboot, and Authelia restarts
when the app's sign-in client is registered (on the first deploy, and
when `[sso]` changes). An app that fetches Authelia's discovery only at
startup then has no sign-in until restarted, so wait in the entrypoint,
with a time limit, e.g.
`until wget -qO /dev/null "$OIDC_ISSUER/.well-known/openid-configuration"; do sleep 2; done`
(and `nc -z "$DB_HOST" "$DB_PORT"` for the database).
- **Images without a shell** (built `FROM scratch` or distroless) can't run
an entrypoint script, and `coreapp shell` can't open one. Copy a static
busybox in and run the script with it:
@@ -437,42 +396,13 @@ or ask the user to use a browser), sign in if it has `sso`, and check that
what it stores survives `coreapp deploy --recreate` (data in `/data` and
the database).
Sign in with `coreapp signin`: it 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:
```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
coreapp signin --cookies jar /login && curl -b jar https://<name>.<domain>/api/me
```
Like the other commands, run it in the app's folder (it reads
`coreapp.toml`); the cookie jar can be anywhere, e.g. `--cookies
"$TMPDIR/jar"`.
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.
For 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` is not the app's, so a callback that checks
state (a server-side callback page) 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.
Still ask the user to sign in once in a browser before a release, as the
Core's admin (`admin@<domain>`): it checks what a script can't (the app's
pages, and that the admin gets the admin role).
For an app with `sso`, `coreapp signin [path]` signs in as a browser would,
with the Core's test account (`coreapp.test@<domain>`), and says whether it
got back to the app signed in; see
[references/sign-in.md](references/sign-in.md) for its options
(`--cookies`, `--form`, `--code` for single-page apps). The test account
isn't the admin: ask the user to sign in once in a browser as
`admin@<domain>` before a release.
### 4. When something fails
@@ -506,11 +436,8 @@ Common causes:
- `coreapp check` fails but deploy worked: a new certificate can take a
minute; it retries for two. It also tries the VM directly, which tells the
app apart from the way in.
- Sign-in fails (`coreapp signin` shows Authelia's error and hint): "The
'redirect_uri' parameter does not match" means the app's callback isn't
the client's (`[sso] callback`); "invalid_client" means it sends the
secret another way (`[sso] token_auth`); a PKCE error means `[sso] pkce`
doesn't match what the app does.
- Sign-in fails: `coreapp signin` shows Authelia's error and hint; what
each means is at the end of [references/sign-in.md](references/sign-in.md).
- Permission denied under `/data`: the app switches to another user after
starting (the Core gives `/data` to the image's `USER`), or it writes
somewhere else in the container (`coreapp shell 'id; ls -ld /data'`).
@@ -520,48 +447,11 @@ The installer's own log (the Core's install scripts) is on the Core in
look at the end of it with `coreapp-vm ssh tail -n 40 /federated/logs/coreapps/<name>-install.log`
only when a deploy fails in the installer itself.
### 5. Publishing (when the user asks for a release)
### 5. Publishing (only when the user asks for a release)
A published app is a tagged commit in its repository plus its image in a
registry, from which any Core can install it. Only publish when the user
asks: it pushes to their registry and tags their repository.
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.
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, and `coreapp update <name>` moves it
to a newer release. 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. The Core
only reads `coreapp.toml` and `icon.png` from the repository; `version` has
to match the tag. 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.
Publishing pushes the image to the user's registry and tags their
repository; installing a release from its repository is how a Core's owner
gets it. For both, read [references/publishing.md](references/publishing.md).
## Reporting back
@@ -570,7 +460,7 @@ When you're done, tell the user:
- what you changed in the repository (`coreapp.toml`, Dockerfile, config),
- what you tested and how (deploy, check, which pages, a redeploy keeping
data, `coreapp signin`), and what they still need to test themselves
(signing in in a browser with their own account),
(signing in in a browser as `admin@<domain>`),
- anything the app needs that the Core doesn't offer yet, and how you
handled it,
- anything in coreapp-dev that got in the way or was unclear. coreapp-dev is