提问人:سيدان عبد الوافي 提问时间:10/5/2023 更新时间:10/5/2023 访问量:7
WebSecurityConfigurerAdapter 和 authenticationManager() 现在不起作用,我如何更改它以在新版本中工作
WebSecurityConfigurerAdapter and authenticationManager() are not working now ,how i can change it to work in the new version
问:
我想更改它,因为 WebSecurityConfigurerAdapter 不再起作用 @EnableWebSecurity 公共类 WebSecurity 扩展了 WebSecurityConfigurerAdapter {
private final UserService userDetailsService;
private final BCryptPasswordEncoder bCryptPasswordEncoder;
public WebSecurity(UserService userDetailsService, BCryptPasswordEncoder bCryptPasswordEncoder) {
this.userDetailsService = userDetailsService;
this.bCryptPasswordEncoder = bCryptPasswordEncoder;
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.cors().and()
.csrf().disable()
.authorizeRequests()
.antMatchers(HttpMethod.POST, SecurityConstants.SIGN_UP_URL)
.permitAll()
.anyRequest().authenticated()
.and()
.addFilter(new AuthenticationFilter(authenticationManager()));
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userDetailsService).passwordEncoder(bCryptPasswordEncoder);
}
答: 暂无答案
评论