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