| 1 |
#1
|
????????? ?????????? ?????????? ?????????? (UserDetailService)
|
? ?????? ?????? ?????????? ???????? UserDetailService, ? ?? UserDetailsService, ??? ???????? Spring Security.
|
?????????? ?????? ?????????? ? UserDetailsService, ??????? ?????????? ?????????? ?????? Spring Security.
|
@Bean
public AuthenticationProvider authenticationProvider(UserDetailsService userDetailsService) {
DaoAuthenticationProvider authenticationProvider = new DaoAuthenticationProvider();
authenticationProvider.setUserDetailsService(userDetailsService);
authenticationProvider.setPasswordEncoder(passwordEncoder());
return authenticationProvider;
}
|
UserDetailsService - ???? ??????? ? Spring Security, ? UserDetailService - ??????? ???????, ??????? ????? ??????? ???????.
|
| 2 |
#1
|
????????? ?????????? passwordEncoder ? ??????
|
??????? passwordEncoder() ?????????? ? ?????? ??????, ?? ?? ?????????? ? ?????? ??????????.
|
?????????? passwordEncoder ? ?????? ?????????? ? ??????? ?????? ?????????? ???? ?????????? ??????????.
|
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
@Bean
public AuthenticationProvider authenticationProvider(UserDetailsService userDetailsService, PasswordEncoder passwordEncoder) {
DaoAuthenticationProvider authenticationProvider = new DaoAuthenticationProvider();
authenticationProvider.setUserDetailsService(userDetailsService);
authenticationProvider.setPasswordEncoder(passwordEncoder);
return authenticationProvider;
}
|
??? ??????? ?????????? ???????? ?????????? ?????? ?????????? ??????? ?????????? ??????????.
|
| 3 |
#1
|
????????? ?????????? ?????????? ??????????
|
?? ?????????? ?????????? ?????????? ?????????? (???????, ???? ??????? ??????????).
|
?????????? ?????????? ?????????? ??????????, ??????? ?????? ??????? ?????????? ?????????? ??????????.
|
@Bean
public AuthenticationProvider authenticationProvider(UserDetailsService userDetailsService, PasswordEncoder passwordEncoder) {
DaoAuthenticationProvider authenticationProvider = new DaoAuthenticationProvider();
authenticationProvider.setUserDetailsService(userDetailsService);
authenticationProvider.setPasswordEncoder(passwordEncoder);
authenticationProvider.setHideUserNotFoundExceptions(false); // ?????????? ?????????? ??????????
return authenticationProvider;
}
|
??? ?????????? ?????????? ?????????? ?????????? ?????????? ?????????? ?????????? ?????????? ??????????.
|