Spring security 为CasAuthenticationFilter设置预验证筛选器

Spring security 为CasAuthenticationFilter设置预验证筛选器,spring-security,cas,jasig,spring-security-cas,Spring Security,Cas,Jasig,Spring Security Cas,我已经为几个应用程序设置了Spring Jasig CAS SSO。这将使用CasAuthenticationFilter。所以我有这样的网络应用- Cas服务器(Cas 3.5.2)-Cas.war,App1-App1.war和App2-App2.war。应用程序使用Spring 3.2.3和Spring Security 3.1.4.1版本 Spring安全配置: 使用此设置,一切似乎正常。现在,当我在Cas服务器上启用OAuth时(不是通过SpringCAS),我无法将该身份验证与我设置的

我已经为几个应用程序设置了Spring Jasig CAS SSO。这将使用
CasAuthenticationFilter
。所以我有这样的网络应用-

Cas服务器(Cas 3.5.2)-Cas.war
App1-App1.war
App2-App2.war
。应用程序使用Spring 3.2.3和Spring Security 3.1.4.1版本

Spring安全配置

使用此设置,一切似乎正常。现在,当我在Cas服务器上启用OAuth时(不是通过SpringCAS),我无法将该身份验证与我设置的通常基于表单的身份验证集成。FacebookOAuth集成似乎工作正常,因为我可以看到在日志中成功检索到Facebook个人资料属性。问题是,在facebook登录后,CasAuthenticationFilter尝试使用类似的基于表单的登录机制对用户“FacebookProfile#XYZXYZ”进行身份验证,但显然它在用户的数据库表中找不到该用户。我的猜测是,我需要编写一个自定义过滤器,它扩展了
AbstractPreAuthenticatedProcessingFilter
,并在
PRE\u Authentication\u filter
之前具有位置(检查上面的Paste配置),并且应该以某种方式将
身份验证设置为正确,因此,
CasAuthenticationFilter
应该知道用户已经登录

这是由
CasAuthenticationFilter
根据日志验证的URL-
/j_spring\u cas\u security\u proxyreceptor?pgtIou=pgtIou-1-pR9r9LVJvB5EkezbMJHN-talenteye.in&pgtId=TGT-2-qxvahircibnr9hu5fovpoahcjabj5ojtuppzw7yk1xh54il-myorg.in

CasAuthenticationFilter
的实现
requiresAuthentication
如下所示:

protected boolean requiresAuthentication(final HttpServletRequest request, final HttpServletResponse response) {
    final boolean serviceTicketRequest = serviceTicketRequest(request, response);
    final boolean result = serviceTicketRequest || proxyReceptorRequest(request) || (proxyTicketRequest(serviceTicketRequest, request));
    if(logger.isDebugEnabled()) {
        logger.debug("requiresAuthentication = "+result);
    }
    return result;
}
日志上说-

19:23:42.835 [http-bio-8080-exec-8] DEBUG o.s.s.c.web.CasAuthenticationFilter -     serviceTicketRequest = false
19:23:42.835 [http-bio-8080-exec-8] DEBUG o.s.s.c.web.CasAuthenticationFilter - proxyReceptorConfigured = true
19:23:42.835 [http-bio-8080-exec-8] DEBUG o.s.s.c.web.CasAuthenticationFilter - proxyReceptorRequest = true
19:23:42.835 [http-bio-8080-exec-8] DEBUG o.s.s.c.web.CasAuthenticationFilter - requiresAuthentication = true
19:23:42.835 [http-bio-8080-exec-8] DEBUG o.s.s.c.web.CasAuthenticationFilter - Request is to process authentication
19:23:42.835 [http-bio-8080-exec-8] DEBUG o.s.s.c.web.CasAuthenticationFilter - proxyReceptorConfigured = true
19:23:42.835 [http-bio-8080-exec-8] DEBUG o.s.s.c.web.CasAuthenticationFilter - proxyReceptorRequest = true
19:23:42.835 [http-bio-8080-exec-8] DEBUG o.s.s.c.web.CasAuthenticationFilter - Responding to proxy receptor request

我不知道该如何使这一点协同工作。我不知道我是否把事情复杂化了一点。任何建议都会非常有用,因为我已经在这上面浪费了几天时间。

我自己解决了这个问题,因此在这里为其他面临类似问题的人发帖


使用CAS的全部目的是集中身份验证。我编写了一个自定义类,它扩展了
AbstractCasAssertionUserDetailsService
。这不会进行身份验证。它必须在CAS服务器上完成。这只是准备一个
UserDetails
对象,供CAS客户端web应用程序使用。因此,在我的案例中不需要预授权。此外,我摆脱了不必要的代理受体配置。它现在运行良好。

我自己解决了这个问题,因此在这里为其他面临类似问题的人发帖

使用CAS的全部目的是集中身份验证。我编写了一个自定义类,它扩展了
AbstractCasAssertionUserDetailsService
。这不会进行身份验证。它必须在CAS服务器上完成。这只是准备一个
UserDetails
对象,供CAS客户端web应用程序使用。因此,在我的案例中不需要预授权。此外,我摆脱了不必要的代理受体配置。它现在运行良好