Skip to content

Web Security Expression section of Documentation is obsolete or it does not work #12974

Closed
@nightswimmings

Description

@nightswimmings

First of all, the following part is obsolete,
https://docs.spring.io/spring-security/reference/servlet/authorization/expression-based.html#el-access-web-path-variables
for .access() method does not support a String anymore. I guess it must be updated to mirror previous section example that uses a WebExpressionAuthorizationManager()

But trying to reproduce it with WebExpressionAuthorizationManager does not work anyway, because the default expression handler is now DefaultHttpSecurityExpressionHandler instead of DefaultWebSecurityExpressionHandler and an exception jumps in with message "EL1057E: No bean resolver registered in the context to resolve access to bean".

But one cannot work it out with something like

WebExpressionAuthorizationManager authManager = new WebExpressionAuthorizationManager("@webSecurity.check(authentication,request)");
authManager.setExpressionHandler(new DefaultWebSecurityExpressionHandler());

because setExpressionHandler expects a SecurityExpressionHandler and DefaultWebSecurityExpressionHandler has FilterInvocation as type instead of RequestAuthorizationContext. the only built-in usabel one is therefore the default DefaultWebSecurityExpressionHandler.

So the whole section needs to be rewritten, and explain the equivalent modern way to achieve the legacy functionality, or statevery clear that SpEL expressions are not supported anymore out-of-the-box

Metadata

Metadata

Assignees

Labels

in: docsAn issue in Documentation or samplestype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions