现在我将为经理和普通用户制作两个AuthenticationProvider,现在我已经设置了经理的AuthenticationProvider,但是如何为普通用户设置另一个AuthenticationProvider? 这是spring security config的代码。
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable()
.authorizeRequests()
.antMatchers("/").permitAll()
.antMatchers("/register/*").permitAll()
.antMatchers(HttpMethod.POST, "/login/manager").permitAll()
.antMatchers("/hello").hasAuthority("AUTH_WRITE")
.antMatchers("/world").hasRole("ADMIN")
.anyRequest().authenticated()
.and()
.addFilterBefore(new JWTLoginFilter("/manager/login", authenticationManager()),
UsernamePasswordAuthenticationFilter.class)
.addFilterBefore(new JWTAuthenticationFilter(),
UsernamePasswordAuthenticationFilter.class);
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.authenticationProvider(authenticationProvider());
}
然后,我不知道AuthenticationManager如何绑定authenticationProvider,你能解释一下吗?