1
多個身份驗證提供我與應用此安全設置:如何正確配置在春季啓動應用程序
問題是,我daoAutentication進行兩次,我想定。在日誌中我可以看到:
2017-01-03 10:29:18.106 DEBUG 2154 --- [[ACTIVE] ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)'] .r.o.MyApplication$ApplicationSecurity : providers: [org.spring[email protected]4c46fcec, [email protected], org.spring[email protected]60516c4c]
我不知道爲什麼有2個DaoAuthenticationProvider。當我編輯我這樣的配置:
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.authenticationProvider(kaasAuthenticationProvider());
// auth.authenticationProvider(daoAuthenticationProvider());
}
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
然後它工作正常。只有一個DaoAuthenticationProvider。問題是,我不知道爲什麼這個作品,所以我現在不想使用它,直到我也明白這一點的安全機制
UPDATE:
@Component
public class CustomAuthenticationProvider implements AuthenticationProvider {
private Logger log = LoggerFactory.getLogger(CustomAuthenticationProvider.class);
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
log.debug("Authentication: {}.", authentication);
...
return new CustomAuthenticationToken(securityToken, authorities,
new CustomUser(login, "", true, true, true, true, authorities));
}
}
安置自己的CustomAuthenticationProvider代碼。 – Apollo
爲什麼你需要這個提供商?這是一個複雜的,我不能粘貼代碼。我在這裏更新了骷髏 – hudi