|
66 | 66 | import org.springframework.security.messaging.access.intercept.MessageAuthorizationContext;
|
67 | 67 | import org.springframework.security.messaging.access.intercept.MessageMatcherDelegatingAuthorizationManager;
|
68 | 68 | import org.springframework.security.messaging.context.SecurityContextChannelInterceptor;
|
69 |
| -import org.springframework.security.messaging.web.csrf.CsrfChannelInterceptor; |
| 69 | +import org.springframework.security.messaging.web.csrf.XorCsrfChannelInterceptor; |
70 | 70 | import org.springframework.security.web.csrf.CsrfToken;
|
71 | 71 | import org.springframework.security.web.csrf.DefaultCsrfToken;
|
72 | 72 | import org.springframework.security.web.csrf.DeferredCsrfToken;
|
|
96 | 96 |
|
97 | 97 | public class WebSocketMessageBrokerSecurityConfigurationTests {
|
98 | 98 |
|
| 99 | + private static final String XOR_CSRF_TOKEN_VALUE = "wpe7zB62-NCpcA=="; |
| 100 | + |
99 | 101 | AnnotationConfigWebApplicationContext context;
|
100 | 102 |
|
101 | 103 | Authentication messageUser;
|
@@ -198,7 +200,7 @@ public void csrfProtectionDefinedByBean() {
|
198 | 200 | MessageChannel messageChannel = clientInboundChannel();
|
199 | 201 | Stream<Class<? extends ChannelInterceptor>> interceptors = ((AbstractMessageChannel) messageChannel)
|
200 | 202 | .getInterceptors().stream().map(ChannelInterceptor::getClass);
|
201 |
| - assertThat(interceptors).contains(CsrfChannelInterceptor.class); |
| 203 | + assertThat(interceptors).contains(XorCsrfChannelInterceptor.class); |
202 | 204 | }
|
203 | 205 |
|
204 | 206 | @Test
|
@@ -238,7 +240,7 @@ public void messagesConnectWebSocketUseCsrfTokenHandshakeInterceptor() throws Ex
|
238 | 240 | public void messagesContextWebSocketUseSecurityContextHolderStrategy() {
|
239 | 241 | loadConfig(WebSocketSecurityConfig.class, SecurityContextChangedListenerConfig.class);
|
240 | 242 | SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor.create(SimpMessageType.CONNECT);
|
241 |
| - headers.setNativeHeader(this.token.getHeaderName(), this.token.getToken()); |
| 243 | + headers.setNativeHeader(this.token.getHeaderName(), XOR_CSRF_TOKEN_VALUE); |
242 | 244 | Message<?> message = message(headers, "/authenticated");
|
243 | 245 | headers.getSessionAttributes().put(CsrfToken.class.getName(), this.token);
|
244 | 246 | MessageChannel messageChannel = clientInboundChannel();
|
|
0 commit comments