spring-security icon indicating copy to clipboard operation
spring-security copied to clipboard

`SecurityExpressionRoot#hasAuthority` should delegate to `AuthorizationManagerFactory#hasAuthority(String)`

Open thuri opened this issue 10 months ago • 1 comments

Expected Behavior

The hasAuthority method of a provided custom AuthorizationManagerFactory should be called when using @PreAuthorize("hasAuthority('foobar')" on a method.

Current Behavior

the hasAnyAuthority method of AuthorizationManagerFactory is called by SecurityExpressionRoot f@PreAuthorize("hasAuthority('foobar')"

Context

I added a Custom AuthorizationManagerFactory as described here.

But instead of handling hasRole as in the example i tried to override hasAuthority. But my method wasn't called.

Using the debugger I found out that SecurityExpressionRoot is actually calling hasAnyAuthority on the AuthorizationManagerFactory.

thuri avatar Jan 13 '26 10:01 thuri

Closing this in favor of the associated PR, #18487

jzheaux avatar Feb 26 '26 23:02 jzheaux