Skip to content

Provide Access to Spring WebSocket's Configured PathMatcher [SPR-12845] #17443

@spring-projects-issues

Description

@spring-projects-issues

Rob Winch opened SPR-12845 and commented

Spring Security should be able to default to using the same PathMatcher that Spring WebSockets is using. This is ideal so that they both use the same PathMatcher (i.e. using . or / separators).

Using SimpAnnotationMethodMessageHandler PathMatcher property does not work because it fails with a circular bean reference. This happens because:

  • stompWebSocketHandlerMapping requests subProtocolWebSocketHandler
  • subProtocolWebSocketHandler requests clientInboundChannel
  • clientInboundChannel requests clientInboundChannelExecutor
  • clientInboundChannelExecutor requests simpAnnotationMethodMessageHandler. This is due to the fact the creation of clientInboundChannelExecutor invokes configureClientInboundChannel and in order to configureClientInboundChannel, we must lookup simpAnnotationMethodMessageHandler to determine the PatternMatcher
  • simpAnnotationMethodMessageHandler then looks up clientInboundChannel (which is a cycle)

You can find my attempt at https://github.com/rwinch/spring-security/tree/SEC-2864 The exact test is AbstractSecurityWebSocketMessageBrokerConfigurerTests#msmsRegistryCustomPatternMatcher

Note that I cannot use MessageBrokerRegistry directly because it is not exposed as a Bean and the accessor is protected.


Issue Links:

  • SEC-2864 Default PathMatcher for WebSocket Destination Matching

Referenced from: commits ae34171, e81862e

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions