Skip to content

Allow to override the ExpressionBasedAnnotationAttributeFactory #9470

Closed
@ptahchiev

Description

@ptahchiev

Hello,

so I am creating a bunch of services with methods inside them and on each method I add the @PreAuthorize annotation like so:

    @Override
    @PreAuthorize("hasAccess()")
    public Page<DepartmentDtoDefinition> getAllDepartments(@NonNull final Pageable pageable) {
    }

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 the ExpressionBasedAnnotationAttributeFactory? 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.

Metadata

Metadata

Assignees

Labels

in: coreAn issue in spring-security-corestatus: declinedA suggestion or change that we don't feel we should currently apply

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions