У меня есть следующие услуги:
Сервер Eureka
Сервер аутентификации
- Spring Gateway
- Это передаст запрос на вход в службу входа.
- Все остальные запросы будут аутентифицированы (с использованием токена jwt и секретного ключа) и переданы другим службам.
Служба входа в систему
- Чтобы проверить логин и выпустить токен jwt
Ниже мой конфиг. Поток даже не доходит до этого кода ..
@Configuration
@EnableWebFluxSecurity
@EnableReactiveMethodSecurity
public class SecurityConfig {
private static final Logger LOGGER = LoggerFactory.getLogger(SecurityConfig.class);
@Autowired
private AuthenticationManager authenticationManager;
@Autowired
private SecurityContextRepository securityContextRepository;
@Bean(value="org.springframework.security.config.annotation.web.reactive.WebFluxSecurityConfiguration.WebFilterChainFilter")
public SecurityWebFilterChain springSecurityWebFilterChainFilter(ServerHttpSecurity http) {
LOGGER.info("In the securiry config..................");
return http
.csrf().disable()
.exceptionHandling()
.authenticationEntryPoint((swe, e) -> {
return Mono.fromRunnable(() -> {
swe.getResponse().setStatusCode(HttpStatus.UNAUTHORIZED);
});
}).accessDeniedHandler((swe, e) -> {
return Mono.fromRunnable(() -> {
swe.getResponse().setStatusCode(HttpStatus.FORBIDDEN);
});
})
.and()
.authenticationManager(authenticationManager)
.securityContextRepository(securityContextRepository)
.authorizeExchange()
.pathMatchers(HttpMethod.OPTIONS).permitAll()
.pathMatchers("/login-service/api/login").permitAll()
.anyExchange().authenticated()
.and().build();
}
}
Я всегда получаю 403
с An expected CSRF token cannot be found
этой ошибкой, хотя я отключил csrf. Может ли кто-нибудь помочь, что здесь может быть не так?
@Bean(value="org.springframework.security.config.annotation.web.reactive.WebFluxSecurityConfiguration.WebFilterChainFilter")
как явное значение Bean поверх этого метода? - person Nagaraj Tantri   schedule 13.04.2021