カスタム認証プロバイダーを使用してアプリケーションに春のセキュリティ (Java 構成を使用) を追加したいのですが、機能させることができません。authenticationProvider が適切に構成されていないようです。coz 認証 (Authentication) メソッドにデバッグできず、println は何も出力しません。そして、すべてのリクエストは 403 で応答しました。
誰でもこれで私を助けてください、私は週末全体でこれに打たれました。
@Configuration
@EnableWebMvcSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.anyRequest().authenticated();
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.authenticationProvider(new AuthenticationProvider(){
@Override
public Authentication authenticate(Authentication arg0) throws AuthenticationException {
System.out.println("authenticating...");
return arg0;
}
@Override
public boolean supports(Class<?> arg0) {
return true;
}
});
}
}