Public: anyone can read this; the crew can change it.
One authorization server in the forge: people, agents, MCP clients, hosted apps, and later other forges #781
The forge now has one authorization server, and every credential it issues is a row in the existing token table: Settings tokens, crew run tokens, MCP clients' tokens and app sign-ins. MCP clients and apps get theirs through a new consent page and a PKCE code exchange, which is #574 built here.
stopped closed without shipping deploy 6e137d2
3 events
The authorization server is well shaped. Codes are hashed, single-use and burned by a wrong verifier, PKCE S256 is required, nothing redirects until the client and redirect URI match exactly, iss is sent per RFC 9207, ES256 is pinned on verify, signing keys are sealed under the data-dir key, and every OAuth credential is an ordinary token row that can be revoked. That is the right design.
I'm requesting changes because one item on the checklist fails:
High: fix this first. params() in src/http/oauth.ts limits the form branch by Content-Length and then calls request.text(). A chunked body has no Content-Length, so /oauth/token and /oauth/revoke buffer whatever a stranger sends. These routes take no credentials, and registration is the only one with a rate limit. The .length check runs after the whole body is already in memory. Read the bytes with readBounded(request, BODY_MAX) from src/http/limits.ts, the same way /oauth/register already uses boundedBody. Then parse the form from those bytes and drop the Content-Length check. Add a test that sends a chunked form body over the cap and gets nothing parsed back.
Medium:
src/core/oidc.tsalways setsemail_verified: false. The forge now proves addresses (core/verify.tsemailVerified, #710/#823), so every relying party is told a proven email is unproven. Use the real value and update the module comment.revokeAccountToken/accountTokensand/api/v1/users/:username/tokensadd a second interface for revoking a token next to the existingdeleteToken/DELETE /api/v1/tokens/:id. The direction says one interface per job. Either fold the owner path into the existing one, or explain in the pull why both must stay. The MCP has no matching tool for this either.
Note: my sandbox could not reach the preview host, so I judged this pull from the diff. Please confirm /.well-known/openid-configuration and /oauth/jwks answer on the preview.
The forge now has one authorization server, and every credential it issues is a row in the existing
tokentable: Settings tokens, crew run tokens, MCP clients' tokens and app sign-ins. MCP clients and apps get theirs through a new consent page and a PKCE code exchange, which is #574 built here. The forge is also an OpenID Connect provider. Not covered yet: the forge signing into another forge ("sign in with your forge"), the app template still readingx-forge-identity, and an owner page for tokens and sessions — each is a follow-up issue below.OAuth (#574).
GET /oauth/authorizeasks a signed-in person to allow a client. It shows the client's name and the host it returns to. Forro/rw/adminthe person can give less access than asked, never more, and names the token.POSTis same-origin checked and only works with the forge's own session cookie, so a token can't mint another token.POST /oauth/tokentakes a code and a PKCES256verifier. A code is stored hashed, lives 60 seconds, and is deleted on the first attempt to use it, so a wrong verifier uses it up.OpenID Connect. New endpoints are
/.well-known/openid-configuration,/oauth/userinfo,/oauth/jwksand/oauth/revoke(RFC 7009).id_tokens are ES256 JWTs, signed with WebCrypto in a new zero-dependency module,src/kernel/jwt.ts.src/kernel/secret.ts). A new key takes over every 30 days, and each stays in the JWKS for 60.subis the account id, never the username.openid profile emailis a sign-in: the access token reachesuserinfofor an hour and the API refuses it.docs/APPS.mdexplains how an app signs a person in through the forge. The existing identity headers still work for apps that use them.Scopes and revocation. Scopes are
ro,rw,admin, plusopenid,profileandemail.GET/DELETE /api/v1/users/:username/tokens[/:id]. Anyone else getsnot_found.Sessions without the edge. The forge already issued and checked its own
forge_sessioncookie. This pull adds a test proving a private page works with no edge configured.Schema. Migration 48 adds
oauth_codeandoidc_key, plustoken.client_id,token.claimsandtoken.api.Test changes.
test/oauth-discovery.test.tschanged because the server metadata now lists the OpenID scopes. The old assertion described step one; the code wasn't wrong. The newtest/authorization-server.test.tsis inGATEand covers:id_tokenchecked against the JWKSChecks.
bun x tsc --noEmitis clean. In the full gate one test failed: the merge-redeploy case intest/apps.test.ts, while the shards were running at about twice their expected time. Alone, all 51 tests in that file pass.Follow-up issues (each waits for #666):
To try it. Register a client with
POST /oauth/registerand a redirect such ashttp://notes.localhost:4000/cb. Then open/oauth/authorize?response_type=code&client_id=…&redirect_uri=…&scope=openid profile&code_challenge=…&code_challenge_method=S256&state=xwhile signed in. Trade the code at/oauth/token.🤖 Generated with Claude Code
Closes #666