Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve @AuthenticationPrincipal meta-annotations #15286

Closed
rwinch opened this issue Jun 20, 2024 · 0 comments · Fixed by #15344
Closed

Improve @AuthenticationPrincipal meta-annotations #15286

rwinch opened this issue Jun 20, 2024 · 0 comments · Fixed by #15344
Assignees
Labels
in: core An issue in spring-security-core type: enhancement A general enhancement
Milestone

Comments

@rwinch
Copy link
Member

rwinch commented Jun 20, 2024

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 rwinch added status: waiting-for-triage An issue we've not yet triaged type: enhancement A general enhancement labels Jun 20, 2024
@jzheaux jzheaux added this to the 6.4.x milestone Jun 24, 2024
@jzheaux jzheaux self-assigned this Jun 24, 2024
@jzheaux jzheaux added in: core An issue in spring-security-core and removed status: waiting-for-triage An issue we've not yet triaged labels Jun 24, 2024
kse-music added a commit to kse-music/spring-security that referenced this issue Jul 2, 2024
kse-music added a commit to kse-music/spring-security that referenced this issue Jul 3, 2024
kse-music added a commit to kse-music/spring-security that referenced this issue Jul 3, 2024
kse-music added a commit to kse-music/spring-security that referenced this issue Jul 3, 2024
kse-music added a commit to kse-music/spring-security that referenced this issue Jul 3, 2024
jzheaux pushed a commit to kse-music/spring-security that referenced this issue Jul 19, 2024
jzheaux added a commit to kse-music/spring-security that referenced this issue Jul 19, 2024
jzheaux added a commit to kse-music/spring-security that referenced this issue Jul 19, 2024
kse-music added a commit to kse-music/spring-security that referenced this issue Jul 23, 2024
kse-music added a commit to kse-music/spring-security that referenced this issue Jul 23, 2024
kse-music added a commit to kse-music/spring-security that referenced this issue Jul 23, 2024
kse-music added a commit to kse-music/spring-security that referenced this issue Jul 23, 2024
kse-music added a commit to kse-music/spring-security that referenced this issue Jul 23, 2024
kse-music added a commit to kse-music/spring-security that referenced this issue Jul 23, 2024
jzheaux added a commit to kse-music/spring-security that referenced this issue Jul 29, 2024
kse-music added a commit to kse-music/spring-security that referenced this issue Jul 30, 2024
jzheaux added a commit to kse-music/spring-security that referenced this issue Aug 10, 2024
Since there is nothing specific to configuring pre/post
annotations, there is no need for the extra class.

If a need like this does arise in the future,
either AnnotationTemplateExpressionDefaults can be sub-
classed, or it can have introduced a Map field holding
custom properties.

Issue spring-projectsgh-15286
jzheaux added a commit to kse-music/spring-security that referenced this issue Aug 10, 2024
jzheaux pushed a commit to kse-music/spring-security that referenced this issue Aug 10, 2024
jzheaux added a commit to kse-music/spring-security that referenced this issue Aug 10, 2024
jzheaux added a commit to kse-music/spring-security that referenced this issue Aug 10, 2024
Since there is nothing specific to configuring pre/post
annotations, there is no need for the extra class.

If a need like this does arise in the future,
either AnnotationTemplateExpressionDefaults can be sub-
classed, or it can have introduced a Map field holding
custom properties.

Issue spring-projectsgh-15286
jzheaux added a commit to kse-music/spring-security that referenced this issue Aug 10, 2024
jzheaux added a commit to kse-music/spring-security that referenced this issue Aug 10, 2024
jzheaux added a commit to kse-music/spring-security that referenced this issue Aug 10, 2024
Since there is nothing specific to configuring pre/post
annotations, there is no need for the extra class.

If a need like this does arise in the future,
either AnnotationTemplateExpressionDefaults can be sub-
classed, or it can have introduced a Map field holding
custom properties.

Issue spring-projectsgh-15286
jzheaux added a commit to kse-music/spring-security that referenced this issue Aug 10, 2024
jzheaux added a commit that referenced this issue Aug 10, 2024
Since there is nothing specific to configuring pre/post
annotations, there is no need for the extra class.

If a need like this does arise in the future,
either AnnotationTemplateExpressionDefaults can be sub-
classed, or it can have introduced a Map field holding
custom properties.

Issue gh-15286
jzheaux added a commit that referenced this issue Aug 10, 2024
fb64 added a commit to fb64/spring-security that referenced this issue Aug 23, 2024
jzheaux added a commit that referenced this issue Aug 30, 2024
jzheaux added a commit that referenced this issue Aug 30, 2024
Rename to a class that isn't focused on the synthesis implementation detail.
Also add Security to the front of the name to clarify that it is only intended
for security annotations, reminiscent of SecurityMetadataSource.

Refine method signatures to better articulate supported use cases.

Issue gh-15286
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core An issue in spring-security-core type: enhancement A general enhancement
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants