feat: revoke token chain by consent challenge ID #3932
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.
This change adds the ability to revoke token chains by "consent challenge ID".
"Consent sessions"
Each time the user goes through a
GET /oauth2/auth?response_type=code&...
auth code flow, we persist a new "consent session" to the database.This is independent of whether the user has previously logged in and/or granted consent, or whether the user was actively asked to grant consent by the consent app. A successful journey through the auth code flow results in a new "consent session".
This consent session is uniquely identified by its "consent challenge ID". This ID is obtained from the
GET /admin/oauth2/auth/requests/consent?consent_challenge=...
API. Note that it is not the same as theconsent_challenge=...
query parameter!Any access and refresh tokens obtained from a token exchange following that particular user journey are bound to that consent session.
We call the totality of all refresh+access tokens derived from a particular consent session a "token chain".
Token revocation
Revoking an access token (AT) is simple: send the AT to
/oauth2/revoke
and it is revoked. If this AT was birthed from a refresh token (RT), the RT that birthed it is not revoked.Revoking a refresh token (RT) also revokes assocated access tokens.
What if I want to revoke a complete token chain given only an access token?
Revocation by consent challenge ID
During an authorization code flow, save the consent challenge ID into the access token session data:
Response:
Accept the consent request:
To revoke the token chain associated with this consent challenge ID, use
PR notes
The persistence code and much of the test code are pretty bad. We test implementation not behavior. There are wrong abstractions.
I have deleted
sdk_test.go
because honestly I can't see the point of that whole file.