我爲幾個應用程序設置了一個Spring Jasig CAS SSO。這使用CasAuthenticationFilter
。所以我有這樣的webapps設置 -爲CasAuthenticationFilter設置預授權過濾器
Cas Server (Cas 3.5.2) - Cas.war
,App1 - App1.war
和App2 - App2.war
。應用程序使用Spring 3.2.3和Spring Security 3.1.4.RELEASE。
Spring Security Config
:http://pastie.org/private/qxcx1h8i9ys0w3lmwegiw
事情似乎與此設置正常工作。現在,當我在Cas服務器上啓用OAuth(而不是通過Spring Cas)時,我無法將該身份驗證與我設置的通常基於表單的身份驗證集成在一起。 Facebook的OAuth集成似乎工作正常,因爲我可以看到在日誌中成功檢索的Facebook配置文件屬性。問題是,後facebook的登錄,CasAuthenticationFilter嘗試驗證用戶「FacebookProfile#XYZXYZ」與基於窗體的登錄類似的機制,顯然它沒有在用戶的數據庫表中找到該用戶。我的猜測是,我需要寫一個擴展AbstractPreAuthenticatedProcessingFilter
與PRE_AUTH_FILTER
前位置(查看以上的pastie配置),並且應該以某種方式設置Authentication
權利,所以CasAuthenticationFilter
應該知道用戶已經登錄在自定義過濾器。
這是URL被CasAuthenticationFilter
認證爲每日誌 - /j_spring_cas_security_proxyreceptor?pgtIou=PGTIOU-1-pR9r9LVJvB5EkezbMJHN-talenteye.in&pgtId=TGT-2-QXvAHIRciBNR9HU5FOvpOaHcJaBj5OJTUPPz5ZwA7yK1xH54iL-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;
}
和日誌s說 -
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
我很困惑如何使這項工作在一起。我想知道我是否有點太複雜了。任何指針都會非常有用,因爲我已經浪費了幾天的時間。