WebExpressionVoter
is a Spring Security decision voter that "handles web authorization decisions".
This answer about the difference between WebExpressionVoter
and AuthenticatedVoter
explains further that enabling it allows the use of SpEL expressions like in XML config:
<http use-expressions="true">
<intercept-url pattern="/admin*" access="hasRole('admin')"/>
...
</http>
However I find if I use WebSecurityConfigurerAdapter
, the SpEL expression that comes through isn't what I'd expect.
// ...
.anyRequest().authenticated()
.antMatcher("/*").denyAll()
// ...
If I put a breakpoint in WebExpressionVoter
here and look at the expression that is evaluated, it's "authenticated" -- which it passes so long as the user is authenticated. But "denyAll" is also an expression -- why is this not included in the expression that WebExpressionVoter
votes on. What logic does Spring use to decide which expression is used? And how could you make Spring Security evaluate all expressions.