Skip to content

Add Meta-annotation Parameter Support #14480

Closed
@jzheaux

Description

@jzheaux

It would be nice if Spring Security's method security meta-annotation support allowed for parameters.

For example, it would be nice to be able to do:

@Retention(RetentionPolicy.RUNTIME)
@PreAuthorize("hasAuthority('{value}')")
public @interface HasAuthority {
    String value();
}

Then, an application could do:

@HasAuthority("message:read")
public String method(...) {
}

The annotation expression should be able to handle method parameters, like @PreAuthorize already does:

@Retention(RetentionPolicy.RUNTIME)
@PreAuthorize("@myAuthzBean.authorizeParameter(#object)")
public @interface AuthorizeObject {
}

allowing an application to do:

@AuthorizeObject
public String method(Object object) {
}

Also, it should support passing method parameters through the custom annotation where:

@Retention(RetentionPolicy.RUNTIME)
@PreAuthorize("@openfga.check({user}, {relation}, {_object})")
public @interface Check {
    String user() default "authentication.name";
    String relation();
    String _object();
}

supports:

@GetMapping("/resource/{id}")
@Check(relation="'reader'", _object="'#id'")
public String method(String id) {
}

Metadata

Metadata

Assignees

Labels

in: coreAn issue in spring-security-coretheme: partner-use-casesUse cases we identified with a partner (an established contributor)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

      翻译: