2010-08-05 91 views
0

我們有一個grails應用程序,它使用兩個域名,Tomcat配置爲使用虛擬主機和別名。這裏的server.xml的片段:使用虛擬主機和別名的Tomcat安全配置

<Host name="domain1.com" appBase="myApp" 
     unpackWARs="true" autoDeploy="true" 
     xmlValidation="false" xmlNamespaceAware="false"> 
    <Alias>domain2.com</Alias> 
</Host> 

我們也想限制訪問Web應用程序(從登錄不同使用部位),所以我們利用Tomcat安全的。

這裏是安全性約束在應用程序的web.xml片段:

<security-constraint> 
    <web-resource-collection> 
     <web-resource-name>HTMLManger and Manager command</web-resource-name> 
     <url-pattern>/*</url-pattern> 
    </web-resource-collection> 
    <auth-constraint> 
     <!-- NOTE: This role is not present in the default users file --> 
     <role-name>manager</role-name> 
    </auth-constraint> 
</security-constraint> 

<!-- Define the Login Configuration for this Application --> 
<login-config> 
    <auth-method>BASIC</auth-method> 
    <realm-name>My Realm</realm-name> 
</login-config> 

<!-- Security roles referenced by this web application --> 
<security-role> 
    <description> 
     The role that is required to log in to the Manager Application 
    </description> 
    <role-name>manager</role-name> 
</security-role> 

<error-page> 
    <error-code>401</error-code> 
    <location>/401.jsp</location> 
</error-page> 

所以這裏的情景:當用戶瀏覽到domain1.com的,基本的身份驗證彈出窗口將被顯示。用戶然後輸入用戶名和密碼組合以進入該站點。用戶然後希望登錄到Web應用程序(以便能夠使用更多功能)。登錄機制(使用acegi)也需要登錄到domain2.com。現在,在用戶可以登錄到domain2.com之前,他/她需要爲基本auth彈出窗口輸入相同的憑證。所以基本上,用戶需要兩次使用tomcat Web安全性,這是我們需要避免的。

問題還在於,因爲它是同一個網絡應用程序,爲什麼它需要用戶登錄兩次?是否因爲tomcat網絡安全是基於域的?那麼即使其他域只是原始域的別名?

謝謝!

回答

1

我認爲問題在於auth基於域上的會話和會話。 如果你有一個兩級認證系統,你應該真的考慮一個SSO這樣的CAS。已棄用的Acegi插件和Grails新的Spring Security Plugin都有CAS支持。在互聯網網站場景中,OpenID可能也是一個簡單而便宜的(免費)選項。具有更細晶粒角色建模的一級驗證系統可能也是可選項