Validate userinfo endpoint in each request #501
rafaelrenanpacheco
started this conversation in
General
Replies: 1 comment
|
Moving this to discussion |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hello!
When using JWT as an authorization strategy the server will accept requests until the
expclaim expires. If the user account is disabled, blocked, or even if the user chooses to "logout from all devices", there is currently no way to refuse incoming requests that have a valid, not expired, JWT token.Even tho JWT authentication is used for stateless application, there is still the concept of session if the authorization server supports it. For example, Keycloak has session control for generated access/refresh tokens. Sadly, If I remove all sessions in Keycloak, nothing will happen because the server relies only on the
expclaim when receiving a request.In order to know if the JWT is still valid besides the
expand signature validation, micronaut-security could have aHttpServerFilterto ping theuser-infoendpoint using the JWT bearer authorization header. The authorization server (keycloak, aws cognito, etc) will validate the token looking at the user account, not only at theexpclaim. If the token is invalid for whatever reason (account blocked, session invalidated, etc), theuser-infoendpoint will send a 401 response. That would mean for micronaut-security that the token is invalid and should send a 401 response as well.I created a custom filter in my application using Keycloak SDK to filter the user's session, but if this idea make to micronaut-security, the user-info ping would be way better. The JWKS endpoint usually have a
userinfo_endpointto be used in this validation, or there could be an alternative property to setup the user-info to be used. Just to demonstrate what I did, here is the code:If micronaut-security will use user-info to validate each request, it would be necessary another property to enable/disable this feature as well.
What do you think about this feature?
Best regards,
Rafael Pacheco.
All reactions