We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
authorizeHttpRequests does not have direct expression support, this can create a slight issue when migrating expressions like the following:
authorizeHttpRequests
.mvcMatchers("/resource/{id}").access("#id == authentication.name")
While it can be migrated using WebExpressionAuthorizationManager like so:
WebExpressionAuthorizationManager
.mvcMatchers("/resource/{id}").access(new WebExpressionAuthorizationManager("#id == authentication.name"))
it would be nice to have something programmatic that does not require SpEL.
One way to do this already is a custom AuthorizationManager like this one:
AuthorizationManager
.mvcMatchers("/resource/{id}").access((authentication, object) -> { String value = object.getVariables().get("id"); return new AuthorizationDecision(authentication.get().getName().equals(value)); })
But this isn't as idiomatic as other Spring Security expressions like hasAuthority.
hasAuthority
A possible improvement is:
.mvcMatchers("/resource/{id}").access(variable("id").isEqualTo(Authentication::getName))
Or another would be:
.mvcMatchers("/resource/{id}").hasVariable("id").equalTo(Authentication::getName)
The text was updated successfully, but these errors were encountered:
Add Request Path Extraction Support
7858085
Closes spring-projectsgh-13256
ec02c22
Closes gh-13256
Successfully merging a pull request may close this issue.
authorizeHttpRequests
does not have direct expression support, this can create a slight issue when migrating expressions like the following:While it can be migrated using
WebExpressionAuthorizationManager
like so:it would be nice to have something programmatic that does not require SpEL.
One way to do this already is a custom
AuthorizationManager
like this one:But this isn't as idiomatic as other Spring Security expressions like
hasAuthority
.A possible improvement is:
Or another would be:
The text was updated successfully, but these errors were encountered: