spring-projects / spring-projects/spring-security
`EnableWebSocketSecurity` is not 1:1 replacement for `AbstractSecurityWebSocketMessageBrokerConfigurer`
@sjohnr is already working on this.
Since Aug 10, 2023.
- Dominant language
- Java
- Stars
- 9.6k
- Forks
- 6.3k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 52
Description
Describe the bug
When using AbstractSecurityWebSocketMessageBrokerConfigurer we can override sameOriginDisabled and enable or disable the CsrfChannelInterceptor. In configureClientInboundChannel it does
if (!sameOriginDisabled()) {
registration.interceptors(this.context.getBean(CsrfChannelInterceptor.class));
}
However, with @EnableWebSocketSecurity it is not possible to disable it since in configureClientInboundChannel it does
ChannelInterceptor csrfChannelInterceptor = getBeanOrNull(CSRF_CHANNEL_INTERCEPTOR_BEAN_NAME, ChannelInterceptor.class);
if (csrfChannelInterceptor != null) {
this.csrfChannelInterceptor = csrfChannelInterceptor;
}
and in the configuration itself it is already defined through
private ChannelInterceptor csrfChannelInterceptor = new XorCsrfChannelInterceptor();
The same sameOriginDisabled is also used in afterSingletonsInstantiated to configure the CSRF for the handler mappings.
Expected behavior
Provide a 1:1 replacement for the deprecated AbstractSecurityWebSocketMessageBrokerConfigurer
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.
Assessment
This issue has not been assessed yet.