How to use role-hierarchy in Spring Security 3 with Spring EL?

Posted by Aleksey on Stack Overflow See other posts from Stack Overflow or by Aleksey
Published on 2010-03-25T13:18:52Z Indexed on 2010/03/25 14:03 UTC
Read the original article Hit count: 608

Filed under:
|
|

I want to use @PreAuthorize annotation on service methods with Spring Security. One of requirements is to use role-hierarchy. But by default it is not enabled.

I found that in SecurityExpressionRoot class ("the base class for expression root objects") there is a property roleHierarchy. The class actually does use this property for methods like hasRole() and hasAnyRole().

I suppose that if I supply it with my own RoleHierarchy bean I will be able to use @PreAuthorize annotations with hierarchical roles.

How can I inject my hierarchy bean into SecurityExpressionRoot?

© Stack Overflow or respective owner

Related posts about spring-security

Related posts about roles