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 #1404

Closed opened this in answer to
Closed without merging

This pull covers the OpenID Connect provider part of #666, not the whole issue. The new tests and the existing OAuth tests pass, and tsc is clean. I ran only those OAuth suites, not the whole check.

Notes

stopped closed without shipping deploy c1b6624

opened this

This pull covers the OpenID Connect provider part of #666, not the whole issue. The new tests and the existing OAuth tests pass, and tsc is clean. I ran only those OAuth suites, not the whole check.

What changed

  • Discovery: GET /.well-known/openid-configuration lists the issuer, endpoints, openid/ro/rw scopes and ES256 as the signing algorithm. The OAuth authorization-server document now lists openid as well.
  • Sign-in: a request with scope=openid and a nonce goes through the existing authorize and PKCE flow, and /oauth/token returns an id_token next to the access token. The id_token has iss, aud, sub, iat, exp, nonce, preferred_username and name, and lasts ten minutes. A request without openid behaves as before.
  • Keys: src/core/oidc.ts generates ES256 keys, seals the private half with the data-dir key, and serves the public keys at GET /oauth/jwks. The signing key rotates after 30 days, and a retired key stays published for another ten minutes. Migration 74 adds the key table and the openid and nonce columns on oauth_code.
  • Userinfo: GET /oauth/userinfo takes a bearer token and returns sub, preferred_username and name. Revoking the token makes it return 401 immediately.
  • Tests: test/oidc.test.ts has an app signing in through OIDC and checking the id_token against the JWKS, plus a tampered token, no id_token without openid, and a revoked token. It also covers rotation (old tokens still verify, new ones use the new key) and the private key being sealed. I changed the scope assertion in test/oauth-discovery.test.ts because openid is now listed. docs/MCP.md has a short section on this.

Not done

  • Private pages without the edge: private pages still resolve identity through the edge header first. I did not touch that.
  • Token listing and revocation: I did not add a view for the forge owner to list or revoke any account's tokens. The only "revoke at once" case tested is through userinfo.
  • Edge sessions: I did not change the platform edge's sessions to go through this server.
  • Claims and refresh: there are no refresh tokens, and no email claim in id_token or userinfo, because tokens do not record the openid scope.
  • Client authentication: clients stay public, with PKCE and no client secret.
  • Key rotation: it happens automatically on age. There is no admin route to rotate on demand; rotateKey exists for one.
  • Follow-up issues: I did not file them. The remaining three acceptance items (edge-less private pages, owner and admin token listing and revocation, other forges signing in) need their own issues.

To try it Run FORGE_TEST_SOCKET=port bun test test/oidc.test.ts in a sandbox, or plain bun test test/oidc.test.ts elsewhere. Then fetch /.well-known/openid-configuration on a running forge.

Closes #666

commented

Parked by the crew: the check failed ("the gate's list > every test/*.test.ts is in exactly one list, and every entry exists") and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs