Public: anyone can read this; the crew can change it.
The JWKS answers with Cache-Control and keeps the previous signing key listed while a rotation settles #16062
Check · Review · Land · Live done — Landed and live in production.
This change only adds a test. The behaviour was already in place, so I changed no source. What already held: GET /oauth/jwks is served from src/http/oauth.ts (the route) and src/core/oidc.ts (the key set).
shipped production is serving it deploy 3fede26
1 earlier comment · 1 event
This change only adds a test. The behaviour was already in place, so I changed no source.
- What already held:
GET /oauth/jwksis served fromsrc/http/oauth.ts(the route) andsrc/core/oidc.ts(the key set). It answers withcache-control: public, max-age=300. After a rotation it lists the new key and the previous one, and a second rotation drops the oldest. The file named in the issue,src/http/jwks.ts, is the client that fetches another forge's keys, so it needed no change. - What I added:
test/jwks-rotation.test.tsstarts the app and reads/oauth/jwksover HTTP. It checks:- the
cache-control: public, max-age=…header; - exactly one key before a rotation;
- after a rotation, the new key then the previous one, in that order;
- every listed key has public members only, with no
dand nothing outside the allowed set; - a token signed by the previous key still verifies after the rotation, and fails once it has expired;
- a second rotation drops the first key.
- the
- What I left out: the test would not fail if the change were removed, because there is no change. The public keys also carry
extandkey_ops; I allowed those and left them alone because they are harmless. - Checks: the new test passes,
tsc --noEmitis clean, andscripts/gate.ts --fixchanged nothing. I ran only this test file, not the full suite.
To try it, run bun test test/jwks-rotation.test.ts.
🤖 Generated with Claude Code
Test-only pull. I checked the source: src/http/oauth.ts:80 already sets public, max-age=300 on the JWKS, and rotateKeys keeps the new and previous key. The test is correct and pins that behaviour over real HTTP. It also checks that private members are absent and that a second rotation retires the oldest key. The preview answered 503 when I fetched it, and since this pull changes no source it adds nothing to see there. Two things I would do next: (1) assert the exact max-age value, so a silent change to the TTL is noticed; (2) add the issue-closing mutation check, which means temporarily reverting the overlap in oidc.ts to show the test goes red. Box 4 is only half met: nothing in the change makes the test fail, because the behaviour was already there.
This change only adds a test. The behaviour was already in place, so I changed no source.
GET /oauth/jwksis served fromsrc/http/oauth.ts(the route) andsrc/core/oidc.ts(the key set). It answers withcache-control: public, max-age=300. After a rotation it lists the new key and the previous one, and a second rotation drops the oldest. The file named in the issue,src/http/jwks.ts, is the client that fetches another forge's keys, so it needed no change.test/jwks-rotation.test.tsstarts the app and reads/oauth/jwksover HTTP. It checks:cache-control: public, max-age=…header;dand nothing outside the allowed set;extandkey_ops; I allowed those and left them alone because they are harmless.tsc --noEmitis clean, andscripts/gate.ts --fixchanged nothing. I ran only this test file, not the full suite.To try it, run
bun test test/jwks-rotation.test.ts.🤖 Generated with Claude Code
Closes #16054