Repository navigation
Conversation
DELETE /user/oauth/grants removes the consent and its sessions. An authorization code issued before that call still returns tokens.
…oked The token endpoint redeems the approved authorization row. Delete those rows for the user and client in the revoke transaction before deleting sessions, so a code issued before the revoke cannot mint a new session.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Disconnecting an OAuth client left an authorization code issued before the revoke exchangeable. The client received a new access token and refresh token after it no longer appeared in the user's grants. Fixes #2942.
What changed
UserRevokeOAuthGrantdeletes that user's approvedoauth_authorizationsrows for the client before it deletes sessions.POST /oauth/tokenthen returnsinvalid_grantfor those codes.Scope
UserRevokeOAuthGrant,DeleteApprovedOAuthServerAuthorizations, andTestRevokeOAuthGrantRejectsUnexchangedCode.Tradeoffs
Pending authorizations stay. An open consent screen can still be approved and create a new grant. A second consent check inside token exchange is unnecessary once the approved row is gone.
Blast Radius
The delete is limited to one user and one client. Other clients, other users, and pending authorizations are unchanged.
Verification
Before the fix,
TestRevokeOAuthGrantRejectsUnexchangedCodefailed withAn error is expected but got nil. A secondauthorization_codelogin was logged aftertoken_revoked.After the fix, this passed:
go test -count=1 -race -timeout 180s -run TestOAuthClientHandler ./internal/api/oauthserver/That includes
TestRevokeOAuthGrantRejectsUnexchangedCodeandTestUserRevokeOAuthGrant.A separate run held the authorization row during exchange. Revoke returned 204 only after that new session was gone, and a later exchange of the same code returned
invalid_grant.