The hub as an OpenID Connect provider for T5DE Music
Pull request / title (pull_request) Successful in 1s
CI / test (pull_request) Successful in 1m30s
CI / image (apps/api/Dockerfile, t5de-hub-api) (pull_request) Skipped
CI / image (apps/web/Dockerfile, t5de-hub-web) (pull_request) Skipped

This commit is contained in:
dhkatz committed 2026-11-19 01:22:33 -08:00
1 parent f0a9661f8e
commit 096ee32fa5
20 files changed
+6531 -29

No files matched your search

+26 -1
View File
@@ -3,7 +3,7 @@
`apps/api` (Elysia on Bun). The route definitions in `apps/api/src/app.ts` are the reference: their schemas validate
requests and type the website's client (Eden). This is the overview.
- `/api/auth/*`: Better Auth (accounts, sessions, device sign-in, JWT keys).
- `/api/auth/*`: Better Auth (accounts, sessions, device sign-in, JWT keys, and the OpenID Connect provider).
- `/api/v1/*`: the hub's own routes.
The website reaches the API through its own origin (Next.js rewrites `/api` to it), so sessions are first-party
@@ -30,6 +30,31 @@ is. Codes: `invalid`, `signed_out`, `forbidden`, `not_found`, `no_such_imvu_acco
| `GET /api/v1/hub` | (anyone) `{registration, discord}`: registration `open` or `closed`, and whether Discord sign-in is on |
| `POST /api/v1/account/finish` | (a basic account) `{username, password}` → `{person}`: it becomes a member (`invalid_username`, `invalid_password`, `username_taken`, `already_member`); with registration closed it then waits for approval. Discord stays linked. |
## Signing in on T5DE's other sites (OpenID Connect)
The hub is an OAuth 2.1 / OpenID Connect provider (Better Auth's `@better-auth/oauth-provider`) for T5DE's own sites,
Music first (docs/music.md, The OIDC provider). The issuer is `API_URL/api/auth`; discovery at
`/api/auth/.well-known/openid-configuration`, keys at `/api/auth/jwks` (Ed25519, the same keys as the JWT plugin).
- **Clients**: first-party sites are made at startup from the environment (`MUSIC_CLIENT_SECRET`,
`MUSIC_REDIRECT_URIS`: client ID `t5de-music`), trusted (no consent screen), confidential (`client_secret_basic`),
PKCE required, HTTPS redirect URIs (plain HTTP on localhost in development). Dynamic registration is off.
- **Flow**: authorization code. `/api/auth/oauth2/authorize` sends people who aren't signed in to the website's
`/signin` with the request and a signature; once signed in (password or Discord) the page sends them back to
authorize, which returns them to the site with a code. `t5de_provider=discord` in the request starts Discord
sign-in at once (a site's "Sign in with Discord"). Other sites' requests show `/consent`.
- **Tokens**: `/api/auth/oauth2/token`, `/userinfo`, `/introspect`, `/revoke`. Ask for `resource=API_URL/api/v1` to
get an access token for the hub's API (a JWT, `typ: at+jwt`, audience that resource), needed for the routes below.
- **Scopes**: `openid`, `profile` (`name`, `preferred_username` for members), `email`, `offline_access` (a refresh
token), `imvu` (first-party only: `imvu: [{id, username}]`, the person's linked IMVU accounts, in the ID token and
userinfo), `imvu:link` (the hub's link routes with the person's access token).
| | |
| --- | --- |
| `GET /api/v1/oauth/clients/:clientId` | (anyone) `{client: {name, firstParty}}`: for the sign-in and consent pages |
| `GET /api/v1/account/imvu` | (`imvu:link` token, or the website) `{links, challenges, linkCap, canLink}` |
| `POST /api/v1/account/links`, `POST .../:imvu/check`, `DELETE /api/v1/account/challenges/:imvu`, `DELETE /api/v1/account/links/:imvu` | also take an `imvu:link` token, for any account (basic ones too); see the website routes below. Other routes answer such tokens 403 `token_not_allowed`, and a token without the scope gets 403 `insufficient_scope`. |
## Proxies
| | |