spring-security
spring-security copied to clipboard
Improve @AuthenticationPrincipal meta-annotations
It would be nice if we could improve the support of @AuthenticationPrincipal meta-annotations to align with method security. For example, the following doesn't appear to work:
@Retention(RetentionPolicy.RUNTIME)
@AuthenticationPrincipal
public @interface CurrentUser {
@AliasFor(annotation = AuthenticationPrincipal.class)
String expression() default "";
}
@CurrentUser(expression = "id") Long currentUserId
It would be nice to also support something like this:
@Retention(RetentionPolicy.RUNTIME)
@AuthenticationPrincipal("principal.{property}")
public @interface CurrentUser {
String property() default "";
}