-
Notifications
You must be signed in to change notification settings - Fork 6k
Consider XML and Java support to simplify migration to filter-based default deny #11967
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
Comments
Having described the options above, I'll throw in my two cents here. For my taste, a catch-all I can see how |
@jzheaux I believe this ticket is no longer valid since we decided to document the migration strategy instead. I'll leave this ticket for you to close. For the migration guide, please document the recommended strategy: To test Spring Security 6.0 compatibility in a Spring Security 5.8 (or earlier) application, add the authorization rule Alternatively, if the application has upgraded to Spring Security 6.0 and certain requests are denied, and is different behaviour before the upgrade, then add the authorization rule |
Closed the ticket as |
Given #11958 and #11963, an application can change from default deny in Spring Security 6 by modifying their URL registry, post-processing the
RequestMatcherDelegatingAuthorizationManager
, or publishing one of their own.However, these approaches may be too cumbersome for folks, especially in the midst of upgrading from 5 to 6. Consider the following program:
In Spring Security 5, the default for unmatched endpoints is to abstain (which has the effect of permitting the request), and the default in Spring Security 6 is to deny.
For an application to revert to the Spring Security 5 behavior, they can first do:
Or, second, they can permit all at the end of their definition:
(If they aren't using expressions, the point is moot since
use-expressions="false"
does not useAuthorizationManager
. If that fact changes, the point still stands as an app can also do<intercept-url pattern="/**" access="IS_AUTHENTICATED_ANONYMOUSLY"/>
)If needed, the application can introduce a
BeanPostProcessor
to post-process theRequestMatcherDelegatingAuthorizationManager
instance, or it can construct one of its own and replace the XMLintercept-url
elements with anauthorization-manager-ref
attribute in<http>
.Though the options are plentiful, it needs to be decided if they are sufficient. For example, one way that may be simpler is to introduce an XML attribute like so:
This attribute would imply
use-authorization-manager="true"
. Ifuse-authorization-manager="true"
, thendefault-authorization-decision
would default todeny
.authorization-manager-ref
would supersede it.A corollary can be made for Java. Consider the same application:
In Spring Security 5, the default for unmatched endpoints is to abstain (which has the effect of permitting the request), and the default in Spring Security 6 is to deny.
For an application to revert to the Spring Security 5 behavior, they can first do:
A corollary can be made for Java. Consider the same application:
Or, second, they can permit all at the end of their definition:
If needed, the application can introduce an
ObjectPostProcessor
to post-process theRequestMatcherDelegatingAuthorizationManager
instance, or it can construct one of its own and replace themvcMatchers
call with a call toanyRequest().access(AuthorizationManager)
.Though the options are plentiful, it needs to be decided if they are sufficient. For example, one way that may be simpler is to introduce a DSL property like so:
The text was updated successfully, but these errors were encountered: