-
Notifications
You must be signed in to change notification settings - Fork 6.1k
OIDC Backchannel Logout Support #12570
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good @jzheaux! At the moment, I just have one comment below for discussion.
...ramework/security/oauth2/client/oidc/authentication/session/OidcProviderSessionRegistry.java
Outdated
Show resolved
Hide resolved
...ework/security/oauth2/client/oidc/web/authentication/logout/OidcBackchannelLogoutFilter.java
Outdated
Show resolved
Hide resolved
...ework/security/oauth2/client/oidc/web/authentication/logout/OidcBackchannelLogoutFilter.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @jzheaux !
Please see review comments.
Also, I would recommend taking a look at the OpenID Connect 1.0 Logout Endpoint (spring-projects/spring-authorization-server@98e3fe8) in Spring Authorization Server and to see how it makes use of SessionRegistry
as we want to align the usage in this PR as well.
...ramework/security/oauth2/client/oidc/authentication/session/OidcProviderSessionRegistry.java
Outdated
Show resolved
Hide resolved
.../security/oauth2/client/oidc/authentication/session/InMemoryOidcProviderSessionRegistry.java
Outdated
Show resolved
Hide resolved
...ework/security/oauth2/client/oidc/authentication/session/OidcClientSessionEventListener.java
Outdated
Show resolved
Hide resolved
...curity/oauth2/client/oidc/authentication/session/OidcProviderSessionRegistrationDetails.java
Outdated
Show resolved
Hide resolved
...in/java/org/springframework/security/web/authentication/logout/BackchannelLogoutHandler.java
Outdated
Show resolved
Hide resolved
...ework/security/oauth2/client/oidc/web/authentication/logout/OidcBackchannelLogoutFilter.java
Outdated
Show resolved
Hide resolved
...ework/security/oauth2/client/oidc/web/authentication/logout/OidcBackchannelLogoutFilter.java
Outdated
Show resolved
Hide resolved
...ework/security/oauth2/client/oidc/web/authentication/logout/OidcBackchannelLogoutFilter.java
Outdated
Show resolved
Hide resolved
...amework/security/oauth2/client/oidc/authentication/logout/OidcLogoutTokenDecoderFactory.java
Outdated
Show resolved
Hide resolved
...ingframework/security/oauth2/client/oidc/authentication/logout/LogoutTokenClaimAccessor.java
Outdated
Show resolved
Hide resolved
I might have overlooked this PR, but it seems entirely focused on sessions when, as I understand the spec, the logout token might contain either a Additionally, the user sessions are not necessarily to be closed on all clients notified with the Back-Channel Logout event: I believe that what we need to remove are the authorized-clients (with authorization-code flow) for the emitting OP. The session on a specific client is to be closed only when we remove the last authorized-clients with authorization-code flow. Let's consider a client with authorized clients to an internal OP and one or more external ones (for optional API calls, for instance). If it is pretty convenient to be notified of a logout event on any of this OPs (to stop trying to send requests and adapt the UI), it would also probably be abrupt to end the session on the client, when the user still has a valid session on other OPs. |
Hey, @ch4mpy! Thanks for the feedback.
The intent of the PR is to address both scenarios;
This is interesting, thanks for bringing it up. @jgrandja, I'm a little unfamiliar with this use case of having multiple authorized clients tied to a single session. The |
7b0cb43
to
b75b3df
Compare
This would be custom behaviour and is not detailed in the spec. If I'm missing it, please provide a link to the spec reference. After a client completes an OIDC flow, it results in an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates @jzheaux.
In addition to the review comments, can you also address the following:
- Update
@since 6.1
to@since 6.2
- There are a few invalid references in
@param
javadoc - Some of the class / method javadoc are either missing or require editing
.../src/main/java/org/springframework/security/config/annotation/web/builders/HttpSecurity.java
Outdated
Show resolved
Hide resolved
...ework/security/oauth2/client/oidc/web/authentication/logout/OidcBackChannelLogoutFilter.java
Outdated
Show resolved
Hide resolved
...ework/security/oauth2/client/oidc/web/authentication/logout/OidcBackChannelLogoutFilter.java
Outdated
Show resolved
Hide resolved
...ework/security/oauth2/client/oidc/web/authentication/logout/OidcBackChannelLogoutFilter.java
Outdated
Show resolved
Hide resolved
...ework/security/oauth2/client/oidc/web/authentication/logout/OidcBackChannelLogoutFilter.java
Outdated
Show resolved
Hide resolved
...ramework/security/oauth2/client/oidc/authentication/session/OidcProviderSessionRegistry.java
Outdated
Show resolved
Hide resolved
...ramework/security/oauth2/client/oidc/authentication/session/OidcProviderSessionRegistry.java
Outdated
Show resolved
Hide resolved
...ramework/security/oauth2/client/oidc/authentication/session/OidcProviderSessionRegistry.java
Outdated
Show resolved
Hide resolved
...curity/oauth2/client/oidc/authentication/session/OidcProviderSessionRegistrationDetails.java
Outdated
Show resolved
Hide resolved
...curity/oauth2/client/oidc/authentication/session/OidcProviderSessionRegistrationDetails.java
Outdated
Show resolved
Hide resolved
@jgrandja no. I mean exactly what I wrote: only the authorized-clients matching the Back-Channel Logout request should be removed (those corresponding to the emitting OP and @jzheaux yes, it is possible to have a user logged-in on several OP at the same time with spring security. I have a running sample there: https://crs.demo.c4-soft.com/ui/ (you can login as Of course, I had to hack a bit to get things working. I provided some details 3 month ago when opening this ticket (which is still waiting for triage), as:
|
@ch4mpy, I think that #12862 requires enhancements that are out of scope for this PR (for example, the Otherwise, I'm not clear on how to query |
@jzheaux I think there are two different concerns in what I commented:
I agree that the second point is related to gh-12862. For the first point, iterating over authorized clients should be enough. Also, this is not directly related, but I don't understand why the repository interface doesn't expose a method to iterate over authorized clients and the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates, @jzheaux! I've added some additional comments below.
...ework/security/oauth2/client/oidc/web/authentication/logout/OidcBackChannelLogoutFilter.java
Outdated
Show resolved
Hide resolved
...ity/oauth2/client/oidc/authentication/logout/OidcBackChannelLogoutAuthenticationManager.java
Outdated
Show resolved
Hide resolved
...k/security/oauth2/client/oidc/authentication/logout/OidcBackChannelLogoutAuthentication.java
Outdated
Show resolved
Hide resolved
.../springframework/security/oauth2/client/oidc/authentication/session/OidcSessionRegistry.java
Outdated
Show resolved
Hide resolved
.../springframework/security/oauth2/client/oidc/authentication/session/OidcSessionRegistry.java
Outdated
Show resolved
Hide resolved
...ework/security/oauth2/client/oidc/web/authentication/logout/OidcBackChannelLogoutFilter.java
Outdated
Show resolved
Hide resolved
This tries to respond to the feedback that the session registry logic belongs in the authentication manager. This does have some nice benefits, for example it appears to remove a couple of classes in the PR. However, it has the potential downside of the authentication manager causing side-effects, which I'm not clear on whether our other authentication managers do. In effect, the sessions get deregistered from the session registry in order to be supplied to the BackchannelLogoutAuthentication instance. Does it make sense to tell a user who is customizing Logout Token authentication that they, as part of authenticating that token, need to supply the sessions attributed to that token? It also has the somewhat uncomfortable consequence of using the session registry in such a way as to make it tricky to expose it and in the DSL. That's because the session registry gets applied to multiple beans and so even if a person is supplying a custom, the coder still needs to know that any custom session registry set on the authentication manager still needs to be set on the DSL as well. I believe this could be a consequence of trying to overuse the authentication API. I'd advocate for not using AuthenticationManager to validate the logout token. Instead, we could introduce LogoutTokenValidator that validates and returns the token. The filter would take this token and invoke the session registry. Then, it would formulate the appropriate Authentication to perform backchannel logout.
- Moved session registry logic into OidcBackChannelLogoutHandler - Updating naming conventions - Moved packages - Adjusted exception handling - Added audience checks
- Note that the reason OidcLogoutAuthenticationToken has a ClientRegistration instance (instead of a reference) is because OAuth2LoginAuthenticationToken does
Looking forward to having this support! Thanks @jzheaux |
There is a reactive xref in the end of the servlet advanced login documentation. docs/modules/ROOT/pages/servlet/oauth2/login/advanced.adoc
This should be:
BTW thanks for this great implementation @jzheaux! This is the last piece we needed to replace the deprecated Keycloak Spring Security Adapter. 👍 |
Closes gh-7845