Skip to content

Allow Token Revocation to be customized #476

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
arfatbk opened this issue Nov 2, 2021 · 9 comments · Fixed by #490
Closed

Allow Token Revocation to be customized #476

arfatbk opened this issue Nov 2, 2021 · 9 comments · Fixed by #490
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@arfatbk
Copy link
Contributor

arfatbk commented Nov 2, 2021

Expected Behavior
Successful refresh Token Revocation should provide a token blocklist implementation for all related access tokens. Or Raise an Event, which then can be consumed to implement a custom token blocklist.

Current Behavior
After Refresh Token revocation, the access token remains valid and can be used by OAuth2 Resource servers.

Context
If we go with the 'Event' approach, after successful revocation of a refresh token, developers can implement blocklist as in memory, JDBC, Communicate over MQ.

I am using the OAuth Resource server that validates access token using the OAuth server's JWKs keys. After Refresh Token is revoked, There seems no way to communicate this to the OAuth Resource server. AFAIK @jgrandja please correct me or point me in the right direction. Thanks

@arfatbk arfatbk added the type: enhancement A general enhancement label Nov 2, 2021
@jgrandja
Copy link
Collaborator

jgrandja commented Nov 4, 2021

Thanks for getting in touch @arfatbk.

Spring Authorization Server does revoke the associated access token during a refresh token revocation (see test), but the JWT access token can still be used at the Resource Server, if the Resource Server verifies the token locally instead of calling the Introspection Endpoint.

This is an important use case to solve and as far as I am aware, there are no RFC standards that solve this problem. The Authorization Server and Resource Server(s) would need to communicate with each other so that the Resource Server's are up-to-date with all revoked tokens so it can implement the blocklist.

Instead of implementing the blocklist on the Resource Server, you could call the Introspection Endpoint with the JWT to determine if it's active or not. However, this would obviously downgrade performance with that extra hop.

The goal of this framework is to implement to spec and provide customization hooks for applications to customize the standard behaviour however they choose. Given that this would be custom behaviour, we would only provide customization hooks.

@arfatbk Would you be able to do some R&D to see what other providers have implemented to solve this problem?

@jgrandja jgrandja self-assigned this Nov 4, 2021
@jgrandja jgrandja added the status: waiting-for-feedback We need additional information before we can continue label Nov 4, 2021
@jgrandja jgrandja changed the title Implement blacklist tokens service Implement blocklist tokens service Nov 4, 2021
@arfatbk
Copy link
Contributor Author

arfatbk commented Nov 4, 2021

Thanks for your response. I will look for references.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Nov 4, 2021
@arfatbk
Copy link
Contributor Author

arfatbk commented Nov 4, 2021

I am not able to find exact implementation by other providers. Closest I could manage is to route revocation request though Spring Cloud Gateway and on successful revocation, propagate the event to all resource servers.

Resource servers may store this in memory blacklist or Centralized cache.

I think this is interesting use-case. We certainly don't want to call OAuth server on each request to validate token, or go to database either.

OAuth server should have a hook to provide onTokenRevocationSuccess() or make token revocation configurable.

@jgrandja
Copy link
Collaborator

jgrandja commented Nov 4, 2021

@arfatbk

OAuth server should have a hook to provide onTokenRevocationSuccess()

I'll get back to you after I've thought of an approach to implement this.

@jgrandja jgrandja removed the status: feedback-provided Feedback has been provided label Nov 4, 2021
@arfatbk
Copy link
Contributor Author

arfatbk commented Nov 4, 2021

I'll be more than happy to contribute. Thanks

@jgrandja
Copy link
Collaborator

jgrandja commented Nov 4, 2021

Sounds good @arfatbk 👍

@jgrandja
Copy link
Collaborator

@arfatbk We could add OAuth2TokenRevocationEndpointFilter.setAuthenticationSuccessHandler(AuthenticationSuccessHandler), which would provide the hook you're looking for. It would be a similar implementation as OAuth2TokenEndpointFilter and it's OAuth2TokenEndpointConfigurer. How does this sound?

@arfatbk
Copy link
Contributor Author

arfatbk commented Nov 11, 2021

Cool. Sounds great.👍

@arfatbk
Copy link
Contributor Author

arfatbk commented Nov 11, 2021

#490

@jgrandja Please review and suggest.
Thanks
This is my first contribution to Spring Framework

@jgrandja jgrandja assigned arfatbk and unassigned jgrandja Nov 15, 2021
@jgrandja jgrandja changed the title Implement blocklist tokens service Allow Token Revocation to be customized Nov 15, 2021
arfatbk added a commit to arfatbk/spring-authorization-server that referenced this issue Dec 1, 2021
Adds hooks to configure Token revocation success and failure handlers
Fixes spring-projectsgh-476
arfatbk added a commit to arfatbk/spring-authorization-server that referenced this issue Dec 1, 2021
Adds hooks to configure Token revocation success and failure handlers
Fixes spring-projectsgh-476
arfatbk added a commit to arfatbk/spring-authorization-server that referenced this issue Dec 1, 2021
Adds hooks to configure Token revocation success and failure handlers
Fixes spring-projectsgh-476
@jgrandja jgrandja added this to the 0.2.2 milestone Dec 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants