spring-cloud / spring-cloud/spring-cloud-bus
Wrong order of ChannelInterceptors?
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 445
- Forks
- 246
- Avg merge
- 16h 25m
- Merged PRs (30d)
- 5
Description
Describe the issue
I am using AbstractSecurityWebSocketMessageBrokerConfigurer with Spring Cloud Bus. The order of the ChannelInterceptors defined in the configurer leads to problems when not authenticated. Because ChannelSecurityInterceptor is added before SecurityContextChannelInterceptor, ChannelSecurityInterceptor has no security context when there is not already an authentication.
StreamBridge adds the ChannelInterceptors in the order it gets them from the application context which is CsrfChannelInterceptor, ChannelSecurityInterceptor, SecurityContextChannelInterceptor.
To Reproduce
Steps to reproduce the behavior:
- Use Spring Cloud Bus with spring-security-config AbstractSecurityWebSocketMessageBrokerConfigurer with inbound constraints.
messages.anyMessage().permitAll()is sufficient. - Incoming events lead to "AbstractSecurityInterceptor.authenticationNotFound" due to a missing security context.
Version of the framework
3.1.1.
Expected behavior
An anonymous security context will be used and no failures.
Additional context
I manually changed the order of the ChannelInterceptors to CsrfChannelInterceptor, SecurityContextChannelInterceptor, ChannelSecurityInterceptor and it worked fine.
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 reproducing the missing-security-context failure with Spring Cloud Bus and AbstractSecurityWebSocketMessageBrokerConfigurer using the stated inbound permitAll constraint. Inspect how StreamBridge obtains and orders CsrfChannelInterceptor, ChannelSecurityInterceptor, and SecurityContextChannelInterceptor. Done means unauthenticated incoming events use an anonymous security context without the authenticationNotFound failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- authentication, backend, security
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100