Skip to content

Improve @AuthenticationPrincipal meta-annotations #15286

@rwinch

Description

@rwinch

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

Metadata

Metadata

Assignees

Labels

in: coreAn issue in spring-security-coretype: enhancementA general enhancement

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions