В соответствии с аутентификацией Spring Doc для веб-сокета используется аутентификация HTTP-запроса (рукопожатие), и когда Spring-Security настроен, дополнительная настройка не требуется.
Я настроил весенняя безопасность:
В соответствии с аутентификацией Spring Doc для веб-сокета используется аутентификация HTTP-запроса (рукопожатие), и когда Spring-Security настроен, дополнительная настройка не требуется. Я настроил весенняя безопасность: [code]@EnableWebSecurity @EnableMethodSecurity @EnableRedisIndexedHttpSession(maxInactiveIntervalInSeconds = 60 * 30) @Configuration @RequiredArgsConstructor public class SecurityConfig {
private final UserDetailsService detailsService; private final RedisIndexedSessionRepository redisIndexedSessionRepository;
@Bean public PasswordEncoder passwordEncoder() { return new BCryptPasswordEncoder(); }
@Bean public AuthenticationProvider authenticationProvider(PasswordEncoder passwordEncoder) { DaoAuthenticationProvider provider = new DaoAuthenticationProvider(); provider.setPasswordEncoder(passwordEncoder); provider.setUserDetailsService(this.detailsService); return provider; }
@Bean public AuthenticationManager authenticationManager(AuthenticationProvider authenticationProvider) { return new ProviderManager(authenticationProvider); }
@Bean public CorsConfigurationSource corsConfigurationSource() { CorsConfiguration configuration = new CorsConfiguration(); configuration.setAllowedOrigins(List.of("http://localhost:3000")); //allows React to access the API from origin on port 3000. Change accordingly configuration.setAllowedMethods(List.of("GET", "POST", "PUT", "DELETE")); configuration.setAllowCredentials(true); configuration.addAllowedHeader("*"); UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); source.registerCorsConfiguration("/**", configuration); return source; }