spring-projects / spring-projects/spring-security
SEC-2914: Support @AuthenticationPrincipal on @SubscribeMapping endpoints
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.6k
- Forks
- 6.3k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 52
Description
Igor Kolomiets (Migrated from SEC-2914) said:
I'm using latest websocket/messaging related features of Spring Security 4 to secure my application's websocket messaging endpoints. We have many @SubscribeMapping annotated methods to provide request-response style of communication that need access to current authenticated user. Currently we do this to get authenticated user:
@SubscribeMapping("/foo")
public MyResponse foo(MyAuthenticationToken authenticationToken) {
MyUser user = authenticationToken.getPrincipal();
}
Naturally I'd like to use @AuthenticationPrincipal so we can do this:
@SubscribeMapping("/foo")
public MyResponse foo(@AuthenticationPrincipal MyUser user) {
}
But it looks like @AuthenticationPrincipal is only supported by @MessageMapping annotated methods. Can we have it work for those annotated with @SubscribeMapping?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing how @AuthenticationPrincipal is supported for @MessageMapping methods with the @SubscribeMapping endpoints described in the issue. Trace the existing Spring Security messaging argument-resolution path, then verify that a principal can be injected for @SubscribeMapping methods using the requested example shape.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- backend, security
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100