Skip to content
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

Re-use the instance of PreInvocationAuthorizationAdvice in the GlobalMethodSecurityConfiguration #8447

Open
gkgeorgiev opened this issue Apr 28, 2020 · 2 comments
Labels
in: core An issue in spring-security-core type: enhancement A general enhancement

Comments

@gkgeorgiev
Copy link

Expected Behavior

If I create my own factory method, instantiating PreInvocationAuthorizationAdvice, which will be used in the GlobalMethodSecurityConfiguration.accessDecisionManager(), or at least if I override the preInvocationAuthorizationAdvice(), the result to be used when constructing the access decision manager.

Current Behavior

Currently, the accessDecisionManager() constructs its own instance of PreInvocationAuthorizationAdvice(ExpressionBasedPreInvocationAdvice), which is not even taken from its factory method PreInvocationAuthorizationAdvice preInvocationAuthorizationAdvice()
In fact, I currently don't see the point of this factory method.

Context

In this way, I could inject my custom implementation of PreInvocationAuthorizationAdvice. Now if I want to extend the behavior accessDecisionManager(), I have to copy/paste the original code and customize, while in my case, it's sufficient if I extend the ExpressionBasedPreInvocationAdvice class and use it in a factory method.

@gkgeorgiev gkgeorgiev added status: waiting-for-triage An issue we've not yet triaged type: enhancement A general enhancement labels Apr 28, 2020
@eleftherias eleftherias added in: core An issue in spring-security-core and removed status: waiting-for-triage An issue we've not yet triaged labels Apr 30, 2020
@eleftherias
Copy link
Contributor

@gkgeorgiev As a workaround, could you override GlobalMethodSecurityConfiguration.createExpressionHandler()?
This would allow you to customize the MethodSecurityExpressionHandler used in the ExpressionBasedPreInvocationAdvice.
Or is there a different customization you need to add to the ExpressionBasedPreInvocationAdvice?

@gkgeorgiev
Copy link
Author

@eleftherias, Thank you for your reply. Actually my goal was to influence the behavior of the AccessDecisionManager, which by default has a Voter based on the ExpressionBasedPreInvocationAdvice, but I found my work-around. I'm aware it's a specific case, but IMHO the code would make more sense in with the improvement request I've posted.
Thx again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core An issue in spring-security-core type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants