Answer the question
In order to leave comments, you need to log in
Spring Security don't understand how it works?
Greetings dear forum users.
I have a question of this kind:
Please tell me, here in Spring Security there is a method loadUserByUsername
loadUserByUsername
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
// Получаем User из БД для проверки
User user = repositories.getUserByUsername(username);
return new org.springframework.security.core.userdetails.User(user.getUsername(), user.getUsername(),
true, true, true, true, getAuthorities());
}
private Collection<? extends GrantedAuthority> getAuthorities(){
return Collections.singletonList(new SimpleGrantedAuthority("ROLE_USER"));
}
Answer the question
In order to leave comments, you need to log in
What if the requested user does not exist? Then what to do? how to tell Spring that there is no such user?
throws UsernameNotFoundException
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question