После ввода правильных данных в поля и отправки запроса на аутентификацию Spring повторно отправляет форму аутентификации и выдает ошибку «Неверный номер телефона или PIN-код». Подозреваю, что он просто не получает Принципал, но не уверен и не знаю почему.
В чем может быть ошибка, что я сделал не так и как это исправить?
Ниже приведены коды, которые могут потребоваться для решения проблемы:
Файл конфигурации Spring Security:
Код: Выделить всё
@Configuration
@EnableWebSecurity
public class SecurityConfiguration {
private final AuthProviderImpl authProvider;
@Autowired
public SecurityConfiguration(@Lazy AuthProviderImpl authProvider) {
this.authProvider = authProvider;
}
@Bean
public AuthenticationManager authenticationManager(HttpSecurity http) throws Exception {
AuthenticationManagerBuilder authenticationManagerBuilder =
http.getSharedObject(AuthenticationManagerBuilder.class);
authenticationManagerBuilder.authenticationProvider(authProvider);
return authenticationManagerBuilder.build();
}
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http.csrf().disable()
.authorizeRequests()
.requestMatchers("/BankAccounts/new").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/auth/login")
.loginProcessingUrl("/auth/login")
.permitAll();
return http.build();
}
@Bean
public PasswordEncoder getPasswordEncoder() {
return new BCryptPasswordEncoder();
}
@Bean
public AuthProviderImpl authProvider(BankAccountsDetailService bankAccountsDetailService) {
return new AuthProviderImpl(bankAccountsDetailService, getPasswordEncoder());
}
}
Код: Выделить всё
public class BankAccountDetails implements UserDetails {
private final BankAccount bankAccount;
private final Long phoneNumber;
public BankAccountDetails(BankAccount bankAccount) {
this.bankAccount = bankAccount;
this.phoneNumber = bankAccount.getPhoneNumber();
}
@Override
public Collection
Подробнее здесь: [url]https://stackoverflow.com/questions/79226126/after-sending-an-authentication-request-to-spring-security-the-same-form-is-ret[/url]
Мобильная версия