spring-security icon indicating copy to clipboard operation
spring-security copied to clipboard

Improve @AuthenticationPrincipal meta-annotations

Open rwinch opened this issue 1 year ago • 0 comments

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 "";
}

rwinch avatar Jun 20 '24 19:06 rwinch