-
Notifications
You must be signed in to change notification settings - Fork 6k
Allow to override the ExpressionBasedAnnotationAttributeFactory #9470
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
Comments
Hi, @ptahchiev, thanks for the suggestion. The support for this is being reworked right now in #9350, so please consider taking a look there to ensure that your use case is addressed. In the meantime, I'd recommend resolving by bean: @PreAuthorize("@authorizationService.hasAccess(...)") where If possible, you might also consider whether this database access can be performed during authentication time and authorities can be granted then. The nice thing about this is that you wouldn't need to access the database for each method invocation. I'm going to close this answered, but please feel free to clarify if you think I've misunderstood. |
Hi @jzheaux I think you got it wrong. I want users to change the value of the Currently what I ended up doing is a custom
and this way I can specify
The
but now i get:
|
Have you already tried creating your own |
Yes I did. However, the |
I ended up creating my own metadata source:
and I also register it in the security metadata source like this:
As you can see I am reading a file
This allows me to use the the I still think this is a nice feature to have. Please reopen this issue. @rwinch what do you think? |
Hello,
so I am creating a bunch of services with methods inside them and on each method I add the
@PreAuthorize
annotation like so:All of these services are packaged in a JAR file and shipped to the customer. What I really want is to resolve the expression in the
@PreAuthorize
annotation from the database or from an external file (I will cache it) so that the customer can specify their own expression and disallow access to some of the services.I think what I need is here:
https://github.com/spring-projects/spring-security/blob/master/config/src/main/java/org/springframework/security/config/annotation/method/configuration/GlobalMethodSecurityConfiguration.java#L343
would it be possible to provide a protected method in the
GlobalMethodSecurityConfiguration
which will construct theExpressionBasedAnnotationAttributeFactory
? This way I would be able to override this method and provide my own implementation that reads the expressions from the db or the file.Thank you.
The text was updated successfully, but these errors were encountered: