Описание проблемы
Я внедряю аутентификацию на основе JWT для веб-питания в приложении Spring Boot с использованием Stomp. HTTP -запросы отлично работают с аутентификацией JWT, но соединения WebSocket не выполняют ошибку: < /p>
STOMP Error: Failed to send message to ExecutorSubscribableChannel[clientInboundChannel]
< /code>
setup:
-Spring Boot 3.x с Spring Security 6.x
-JWT Tokens (Access + Refresh) для аутентификации
-CSRF Disablet, без статистики
-React Frontend, подключающийся через Sockjs /STOMP < /p>
Ожидаемое поведение: websockeocke connecticate us undercocecocecocecocecoce and usken and usken and usken and uskeke krind undockecocke and stompken and stompke grongeke and stompken < /p>
. Обмен сообщениями. @Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
return http
.cors(Customizer.withDefaults())
.csrf(AbstractHttpConfigurer::disable)
.authorizeHttpRequests(request -> request
.requestMatchers("/auth/**").permitAll()
.requestMatchers("/ws/**").authenticated() // This might be the issue?
.anyRequest().authenticated()
)
.sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
.addFilterBefore(jwtFilter, UsernamePasswordAuthenticationFilter.class)
.build();
}
< /code>
websocketsecurityconfig.java:
@Configuration
@EnableWebSocketSecurity
public class WebSocketSecurityConfig {
@Bean
public AuthorizationManager
Подробнее здесь: [url]https://stackoverflow.com/questions/79662446/spring-security-websocket-authentication-with-jwt-stomp-connection-fails-with[/url]
Описание проблемы Я внедряю аутентификацию на основе JWT для веб-питания в приложении Spring Boot с использованием Stomp. HTTP -запросы отлично работают с аутентификацией JWT, но соединения WebSocket не выполняют ошибку: < /p> [code]STOMP Error: Failed to send message to ExecutorSubscribableChannel[clientInboundChannel] < /code> setup: -Spring Boot 3.x с Spring Security 6.x -JWT Tokens (Access + Refresh) для аутентификации -CSRF Disablet, без статистики -React Frontend, подключающийся через Sockjs /STOMP < /p> Ожидаемое поведение: websockeocke connecticate us undercocecocecocecocecoce and usken and usken and usken and uskeke krind undockecocke and stompken and stompke grongeke and stompken < /p> . Обмен сообщениями. @Bean public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { return http .cors(Customizer.withDefaults()) .csrf(AbstractHttpConfigurer::disable) .authorizeHttpRequests(request -> request .requestMatchers("/auth/**").permitAll() .requestMatchers("/ws/**").authenticated() // This might be the issue? .anyRequest().authenticated() ) .sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) .addFilterBefore(jwtFilter, UsernamePasswordAuthenticationFilter.class) .build(); } < /code> websocketsecurityconfig.java: @Configuration @EnableWebSocketSecurity public class WebSocketSecurityConfig { @Bean public AuthorizationManager
Описание проблемы
Я внедряю аутентификацию на основе JWT для веб-питания в приложении Spring Boot с использованием Stomp. HTTP -запросы отлично работают с аутентификацией JWT, но соединения WebSocket не выполняют ошибку:
STOMP Error: Failed to...
Я использую реализацию Spring STOMP поверх WebSocket с полнофункциональным брокером ActiveMQ. Когда пользователи ПОДПИСЫВАЮТСЯ на тему, существует определенная логика разрешений, через которые они должны пройти, прежде чем успешно подписаться. Я...
WebSocket (STOMP) endpoint (with message broker)
Clients connect via STOMP and authenticate with JWT (sent as a STOMP Authorization header in the CONNECT frame)
Spring Security with @PreAuthorize...
WebSocket (STOMP) endpoint (with message broker)
Clients connect via STOMP and authenticate with JWT (sent as a STOMP Authorization header in the CONNECT frame)
Spring Security with @PreAuthorize...
WebSocket (STOMP) endpoint (with message broker)
Clients connect via STOMP and authenticate with JWT (sent as a STOMP Authorization header in the CONNECT frame)
Spring Security with @PreAuthorize...