Closed
Description
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) {
}