DaoAuthenticationProvider
の後に呼び出されるカスタム認証プロバイダを追加してください。例えば
あなたWebSecurityConfigurerAdapter
拡張クラスへの行の下に追加します。UserStateAuthenticationProvider
は
public class UserStateAuthenticationProvider{
@Override
public Authentication authenticate(Authentication authentication)
throws AuthenticationException {
//....do anything you want like below
String name = authentication.getName();
String password = authentication.getCredentials().toString();
return null;
}
@Override
public boolean supports(Class<?> authentication) {
return authentication.equals(
UsernamePasswordAuthenticationToken.class);
}
}
のように、独自のカスタムクラス
することができ
@Autowired
UserStateAuthenticationProvider userStateAuthenticationProvider;
@Autowired
public void globalUserDetails(AuthenticationManagerBuilder auth) throws
Exception {
auth.userDetailsService(userDetailsService);
auth.authenticationProvider(userStateAuthenticationProvider);
}