fix(oauth): an authorization code mints tokens only while the password it was granted under holds

The consent page mints a two-minute authorization code from the cookie
session. A password reset or change revokes the user's OAuth tokens but
left such a pending code alone, so a code granted before the reset still
redeemed afterwards into a fresh token pair at either token endpoint.

The code now carries the password version of the session that consented,
and both token endpoints issue tokens for it only while that version is
still the account's, checked in the transaction that writes the tokens.
A refused code answers invalid_grant as any other and is audited as
password_changed.
This commit is contained in:
Maurice
2026-11-26 22:21:46 +01:00
parent c88d3abc5e
commit f9ab280b7e
13 changed files with 161 additions and 24 deletions
+1
View File
@@ -61,6 +61,7 @@ const { oauthSvc } = vi.hoisted(() => ({
consumeAuthCode: vi.fn(),
saveConsent: vi.fn(),
issueTokens: vi.fn(),
issueTokensForCode: vi.fn(),
issueClientCredentialsToken: vi.fn(),
refreshTokens: vi.fn(),
revokeToken: vi.fn(),