Reject access tokens issued before a per-user cutoff
Draft
HA
42m ago+18142+18142+01234567890123456789012345678901234567890123456789-0-0-0123456789
Revoking a CLI token in the DB does not stop its 7-day JWT. This adds nullable auth.users.tokens_valid_after. sessionFromOAuthBearer rejects a token whose iat is before it. Null = no effect, other users untouched, JWKS key not rotated.
- Check is in
apps/api/src/trpc/context.ts. It reuses the user row already loaded per request: no extra query. - Migration
0199is a nullable column add with no default (metadata-only). It takes a brief ACCESS EXCLUSIVE lock onauth.users; the db-migrations checklist is not yet cleared, and the migration has not been run anywhere. - Not covered: Workers using
verifyJWT(relay, realtime) andpackages/mcp/src/auth.tshave no DB access and still accept the token until expiry. - Tests:
bun test src/trpc/isIssuedBeforeCutoff(4 pass).
Summary by cubic
Revoking a CLI token in the DB now stops its 7-day JWT instead of leaving it valid until expiry. This adds a nullable auth.users.tokens_valid_after column; sessionFromOAuthBearer rejects any bearer token whose iat predates the user's cutoff. A null cutoff leaves behavior unchanged, other users are untouched, and no JWKS keys are rotated. The check lives in apps/api/src/trpc/context.ts and reuses the user row already loaded per request, so no extra query is added.
Migration
- Migration
0199adds the nullable column with no default and takes a brief ACCESS EXCLUSIVE lock onauth.users; it has not been run anywhere yet.
Not covered
- Workers using
verifyJWT(relay, realtime) andpackages/mcp/src/auth.tshave no DB access and still accept the token until expiry.