-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
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
RoleHierarchy not automatically inject in overwritten MethodSecurityExpressionHandler bean #16307
Comments
Can you please post some code to help me see what code you'd expect to work? |
I think when provide custom
Additionally, when both a custom MethodSecurityExpressionHandler and RoleHierarchy are provided, is it necessary to configure them within the framework? @jzheaux |
You are correct, @kse-music, this is covered in the reference specifically with respect to Since That said, I'd still like to give @plumarr the opportunity to respond in case I haven't correctly understood their question. |
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed. |
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue. |
If you manually define both a
RoleHierarchy
bean and aMethodSecurityExpressionHandler
, theRoleHierarchy
isn't injected in theMethodSecurityExpressionHandler
bean. As a result, the role hierarchy isn't applied when callinghasRole()
when securing a method with@PreAuthorize
.To Reproduce
RoleHierarchy
beanMethodSecurityExpressionHandler
. For example, by inheritingDefaultMethodSecurityExpressionHandler
.Expected behavior
The
RoleHierarchy
bean is injected in the manually definedMethodSecurityExpressionHandler
and can be used with@PreAuthorize
andhasRole()
Current behavior
When you launch the application the following happens in order:
PrePostMethodSecurityConfiguration
initializeexpressionHandler
with a manually createdDefaultMethodSecurityExpressionHandler
RoleHierarchy
bean is injected inPrePostMethodSecurityConfiguration
andexpressionHandler.setRoleHierarchy
is calledMethodSecurityExpressionHandler
. bean is injected inPrePostMethodSecurityConfiguration
and the configuration is adapted, but the methodsetRoleHierarchy
isn't called on the new bean.The text was updated successfully, but these errors were encountered: