Проблема: невозможно войти с безопасным входом в приложение весенней загрузки.Когда я попытался войти на страницу, я получил страницу '.failureUrl ("/ login? Error = true").Но мое имя пользователя и пароль верны.Я использую электронную почту вместо имени пользователя в моем коде.В форме, Мои входные имена j_username и j_password, эти имена в UserServiceImpl.java с тем же именем, но все еще не могут войти.
Anasayfa.html
<form name='f' action="j_spring_security_check" method='POST'>
<table>
<tr>
<td>User:</td>
<td><input type='text' name='j_username'>
</td>
</tr>
<tr>
<td>Password:</td>
<td><input type='password' name='j_password' />
</td>
</tr>
<tr>
<td colspan='2'><input name="submit" type="submit"
value="submit" />
</td>
</tr>
</table>
<input type="hidden"
name="${_csrf.parameterName}"
value="${_csrf.token}"/>
SecurityConfiguration.java
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable();
http
.authorizeRequests()
.antMatchers(
"/fonts**",
"/js/**",
"/css/**",
"/images/**",
"/*.html").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/Anasayfa.html")
.loginProcessingUrl("/j_spring_security_check")
.usernameParameter("j_username")
.passwordParameter("j_password")
.failureUrl("/login?error=true")
.permitAll()
.and()
.logout()
.invalidateHttpSession(true)
.clearAuthentication(true)
.logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
.logoutSuccessUrl("/Anasayfa.html") //FIXME logout islemleri yapilacak
.permitAll();
}
UserServiceImpl.java
public class UserServiceImpl implements UserService {
@Autowired
private KullaniciRepository userRepository;
public Kullanici findByEmail(String email){
return userRepository.findByEmail(email);}
@Override
public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException {
Kullanici user = userRepository.findByEmail(email);
if(user == null){
throw new UsernameNotFoundException("EMail Bulunamadı!");
}
return new org.springframework.security.core.userdetails.User(user.getEmail(), user.getSifre(), null);
}
}