我正在尝试使用Spring Security为我的Web应用程序设置CAS身份验证.我已经按照文档编写并设法将XML配置示例转换为Java配置.但是,我不确定我是否正确地做了所有事情并且考虑到安全性的敏感性,我希望有人确认没有错误.
例如,我如何确定不再有默认配置(例如URL上的自由权限,不同的身份验证管理器和/或提供程序等等)?
我检索当前AuthenticationManager的方式是否正确?
像我做的那样正确配置EntryPoint吗?
我发现理解如何使用WebSecurityConfigurerAdapter相当混乱......
这是我的@Cofiguration类:
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Bean(name="authenticationManager")
@Override
public AuthenticationManager authenticationManagerBean() throws Exception {
// TODO Auto-generated method stub
return super.authenticationManagerBean();
}
@Bean
public ServiceProperties serviceProperties() {
final ServiceProperties serviceProperties = new ServiceProperties();
serviceProperties.setService("http://localhost:8088/webapp/login/cas");
return serviceProperties;
}
@Bean
public AuthenticationUserDetailsService<CasAssertionAuthenticationToken> authenticationUserDetailsService() {
return new MyCasAssertionUserDetailsService();
}
@Autowired
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
super.configure(auth);
final CasAuthenticationProvider casAuthenticationProvider = new CasAuthenticationProvider();
casAuthenticationProvider.setServiceProperties(serviceProperties());
casAuthenticationProvider.setAuthenticationUserDetailsService(authenticationUserDetailsService());
casAuthenticationProvider.setTicketValidator(new Cas20ProxyTicketValidator("https://my.cas.server.com/cas"));
casAuthenticationProvider.setKey("MY-KEY");
auth.authenticationProvider(casAuthenticationProvider);
}
@Bean
public CasAuthenticationEntryPoint casEntryPoint() …
Run Code Online (Sandbox Code Playgroud)