spring-projects / spring-security

Spring Security

Home Page:http://spring.io/projects/spring-security

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Improve @AuthenticationPrincipal meta-annotations

rwinch opened this issue · 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 "";
}