spring-cloud / spring-cloud/spring-cloud-bus

Wrong order of ChannelInterceptors?

Open
#250 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feedback-provided
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:

  1. Use Spring Cloud Bus with spring-security-config AbstractSecurityWebSocketMessageBrokerConfigurer with inbound constraints. messages.anyMessage().permitAll() is sufficient.
  2. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.