Spring 2.7中的WebSecurityConfigurerAdapter已过时。我应该如何更新此类:
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
private final UserRepository userRepository;
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(
email -> {
log.debug("Authenticating '{}'", email);
Optional<User> optionalUser = userRepository.findByEmailIgnoreCase(email);
return new AuthUser(optionalUser.orElseThrow(
() -> new UsernameNotFoundException("User '" + email + "' was not found")));
}
).passwordEncoder(PasswordEncoderFactories.createDelegatingPasswordEncoder());
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()....
}
}
3条答案
按热度按时间tv6aics11#
根据Spring Security without the WebSecurityConfigurerAdapter,可以更新:
hmae6n7t2#
//Spring Boot子2.7.0 +更改与Spring安全
rpppsulh3#
https://spring.io/blog/2022/02/21/spring-security-without-the-websecurityconfigureradapter