Spring security 如何在CAS登录后使用spring筛选器模拟用户
是否有一个spring筛选器对象允许我选择通过spring安全链传递哪个身份验证令牌Spring security 如何在CAS登录后使用spring筛选器模拟用户,spring-security,cas,Spring Security,Cas,是否有一个spring筛选器对象允许我选择通过spring安全链传递哪个身份验证令牌 我想检查httpsession,并选择使用CAS筛选器生成的令牌还是从httpsession生成的令牌。请执行以下操作: 1) 覆盖CasAuthenticationFilter 2) 实现您自己的attemptAuthentication方法(如下) 3) 配置您的过滤器 public Authentication attemptAuthentication(final HttpServletRequest
我想检查httpsession,并选择使用CAS筛选器生成的令牌还是从httpsession生成的令牌。请执行以下操作: 1) 覆盖CasAuthenticationFilter 2) 实现您自己的attemptAuthentication方法(如下) 3) 配置您的过滤器
public Authentication attemptAuthentication(final HttpServletRequest request, final HttpServletResponse response)
throws AuthenticationException, IOException {
// Access to HTTP request
if (it CAS authentication) {
return super.attemptAuthentication(request,response);
} else {
// provide username, password
final UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(username, password);
authRequest.setDetails(authenticationDetailsSource.buildDetails(request));
return this.getAuthenticationManager().authenticate(authRequest);
}
}
谢谢你的回复@Michael。我也有同样的想法。不幸的是,我们的应用程序使用的是org.jasig.cas.client.authentication.AuthenticationFilter,而不是org.springframework.security.cas.web.CasAuthenticationFilter。jasig滤波器是最终的。我正在用一个替换另一个,以便实现此解决方案。