2010-08-05 90 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可能也是一个简单而便宜的(免费)选项。具有更细晶粒角色建模的一级验证系统可能也是可选项