-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Propagate Authorities From Previous Factors #17790
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
6eb00d0
to
b48b10a
Compare
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! I've provided feedback inline, but my main pieces of feedback are:
- The
AuthenticationManager
should not be accessing theSecurityContext
. Instead, we should have the controller (e.g.Filter
) that invokes theAuthenticationManager
perform the merging of the twoAuthentication
instances. - I think that the builder APIs should function independently of MFA and should work for any properties on the
Authentication
. Doing this would also allow deprecation of thesetAuthenticated
method. - I don't think we should have an
Authentication.apply(Authentication)
method. Especially so if it is only applying the authorities and ignoring many other properties that are on theAuthentication
object.
core/src/main/java/org/springframework/security/authentication/AbstractAuthenticationToken.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/springframework/security/authentication/AbstractAuthenticationToken.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/springframework/security/authentication/AbstractAuthenticationToken.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/springframework/security/authentication/AbstractAuthenticationToken.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/springframework/security/authentication/AbstractAuthenticationToken.java
Outdated
Show resolved
Hide resolved
cas/src/main/java/org/springframework/security/cas/authentication/CasAuthenticationToken.java
Outdated
Show resolved
Hide resolved
cas/src/main/java/org/springframework/security/cas/authentication/CasAuthenticationToken.java
Outdated
Show resolved
Hide resolved
...ava/org/springframework/security/authentication/DelegatingReactiveAuthenticationManager.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/springframework/security/core/Authentication.java
Outdated
Show resolved
Hide resolved
...ngframework/security/saml2/provider/service/authentication/Saml2AssertionAuthentication.java
Outdated
Show resolved
Hide resolved
5e94df2
to
4d89979
Compare
4d89979
to
547bbd5
Compare
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 again for all your work on this. I think that we are nearly done. I provided a minor comment inline.
I think that we should also update the reference. At minimum it should be added to whats-new.adoc
and link to the Javadoc. However, I think the core APIs in servlet/authentication/architecture.adoc
should be updated and the diagram description of AbstractAuthenticationProcessingFilter
and the reactive equivalents.
...ringframework.security.authentication.event.InteractiveAuthenticationSuccessEvent.serialized
Show resolved
Hide resolved
core/src/main/java/org/springframework/security/core/Authentication.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/springframework/security/core/Authentication.java
Show resolved
Hide resolved
547bbd5
to
1d60b4a
Compare
1d60b4a
to
6af848f
Compare
This commit adds a new default method to Authentication for the purposes of creating a Builder based on the current authentication, allowing other authentications to be applied to it as a composite. It also adds Builders for each one of the authentication result classes. Issue spring-projectsgh-17861
This commit allows looking up the current authentication and applying it to the latest authentication. This is specifically handy when collecting authorities gained from each authentication factor. Issue spring-projectsgh-17862
This commit provides the SecurityContextHolderStrategy bean to ProviderManager instances that the HttpSecurity DSL constructs. Issue spring-projectsgh-17862
- Added remaining properties - Removed apply method since Spring Security isn't using it right now - Made builders extensible since the authentications are extensible Issue spring-projectsgh-17861
Given that the filters are the level at which the SecurityContextHolder is consulted, this commit moves the operation that ProviderManager was doing into each authentication filter. Issue spring-projectsgh-17862
This commit allows a default implementation of Authentication.Builder that performs the builder operations. In this way, authorities and other previous authentication material can still be effectively be propagated in the event a custom authentication does not implement the method. Issue spring-projectsgh-17861
It would be better to introduce parameter types for principal and credentials into Authentication.Builder at the same time as doing so for Authentication Issue spring-projectsgh-17861
6af848f
to
c7d6a87
Compare
The commit documents the new Authentication Builder interface and its usage in the security filter chain. Closes spring-projectsgh-17861 Closes spring-projectsgh-17862
c7d6a87
to
b09afb3
Compare
Applications can use
AuthenticationBuilder
to apply existing authentications to new ones.For example, if the current logged in user is represented by:
And they provide a second set of authenticated credentials, represented by:
Then the first factor can be applied to the second factor as follows:
This draft PR adds a basic builder to each Authentication implementation that implements
Authentication.Builder
. In order to simplify upgrades,toBuilder
by default returns a no-op implementation ofAuthentication.Builder
that ultimately returns the same authentication unchanged.