-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Decouple SAML 2.0 Single Logout from the authenticated principal's type #11338
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
@chschu Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
@chschu Thank you for signing the Contributor License Agreement! |
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.
I'm not totally clear on why this new interface is needed. Maybe the code instead should check for authentication
as well as authentication.getPrincipal
being of type Saml2AuthenticatedPrincipal
. The code could change to:
if (authentication instanceof Saml2AuthenticatedPrincipal principal) {
return principal.getRelyingPartyRegistrationId();
}
if (authentication.getPrincipal() instanceof Saml2AuthenticatedPrincipal principal) {
return principal.getRelyingPartyRegistrationId();
}
It seems like this would achieve what you are wanting without adding a new interface to support. This is nice since there is such a big overlap between Saml2AuthenticatedPrincipal
and Saml2AuthenticationInfo
's methods.
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.
Because an authentication token is not a principal, while both a token and a principal can be sources of SAML information.
You don't want to have Saml2Authentication implements Saml2AuthenticatedPrincipal
do you?
.../springframework/security/saml2/provider/service/authentication/Saml2AuthenticationInfo.java
Outdated
Show resolved
Hide resolved
@chschu, I realize it's been a bit since you submitted this PR. I've posted a review; once we are aligned on how to change things, I'm happy to do the legwork to resolve the conflicting files so that you can focus on making the implementation changes. |
i had to use this as a work around for now. https://stackoverflow.com/a/78768756/19424868 |
This allows SLO to be triggered without the authentication principal needing to implement a given interface. Issue spring-projectsgh-10820
de62adc
to
79170b9
Compare
This commit separates the authentication principal, the assertion details, and the relying party tenant into separate components. This allows the principal to be completely decoupled from how Spring Security triggers and processes SLO. Specifically, it adds Saml2AssertionAuthentication, a new authentication implementation that allows an Object principal and a Saml2ResponseAssertionAccessor credential. It also moves the relying party registration id from Saml2AuthenticatedPrincipal to Saml2AssertionAuthentication. As such, Saml2AuthenticatedPrincipal is now deprecated in favor of placing its assertion components in Saml2ResponseAssertionAccessor and the relying party registration id in Saml2AssertionAuthentication. Closes spring-projectsgh-10820
79170b9
to
c160801
Compare
Thanks, @chschu, for your patience on this PR. I've changed the name of the interface and placed it in the credential instead. In this way, there isn't any expectation for what interface the principal implements in order to inform logout behavior. It will merge once the build completes. |
Issue gh-10820
When using a custom authenticated principal that does not implement
Saml2AuthenticatedPrincipal
, theAuthentication
itself can now implementSaml2AuthenticationInfo
to provide the same information.Making the authenticated principal implement the
Saml2AuthenticatedPrincipal
interface is not always an option. The authenticated principal can be an opaqueObject
created and consumed by code completely unaware of Spring Security.On the other hand, the code that creates a custom
Authentication
already has Spring Security on the classpath, so implementingSaml2AuthenticationInfo
there should always be possible.The new interface
Saml2AuthenticationInfo
is currently only used for SAML 2.0 Single Logout. If neither the authenticated principal nor theAuthentication
itself implements it, SAML 2.0 Single Logout requests won't be detected.This PR does not change the default behavior. It improves flexibility if
OpenSaml4AuthenticationProvider.responseAuthenticationConverter
is customized.