Я столкнулся с этой проблемой, когда пытаюсь вызвать конечную точку для регистрации учетной записи в приложении: Невозможно найти ожидаемый токен CSRF
Код: Выделить всё
@Configuration
@EnableWebSecurity
@RequiredArgsConstructor
public class SecurityConfig {
private final JwtAuthenticationFilter jwtAuthenticationFilter;
private final AuthenticationProvider authenticationProvider;
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
return http
.csrf(AbstractHttpConfigurer::disable)
.authorizeHttpRequests()
.requestMatchers("/api/auth/**")
.permitAll()
.anyRequest()
.authenticated()
.and()
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.authenticationProvider(authenticationProvider)
.addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class)
.build();
}
Можете ли вы помочь мне понять, что я сделал не так? Спасибо!
Я пытался позвонить в конечную точку регистрации учетной записи, но столкнулся с проблемой: Невозможно найти ожидаемый токен CSRF. Я ожидал, что не получу это сообщение, поскольку отключил csrf в классе конфигурации безопасности
конечную точку регистра вызовов
Подробнее здесь: https://stackoverflow.com/questions/760 ... boot-3-0-5
Мобильная версия