使用虚拟主机和别名的Tomcat的安全配置

时间:2010-08-05 07:07:15

标签: tomcat grails

我们有一个使用两个域名的grails应用程序,Tomcat配置为使用虚拟主机和别名。这是server.xml片段:

<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之前,他/她需要为基本身份验证弹出窗口输入相同的凭据。基本上,用户需要两次使用tomcat web安全性,这是我们需要避免的。

问题还在于,由于它是同一个网络应用程序,为什么需要用户登录两次?是因为tomcat web安全是基于域的吗?那么,即使其他域只是原始域的别名?

谢谢!

1 个答案:

答案 0 :(得分:1)

我认为问题在于auth基于域上的会话和会话。 如果您有两级身份验证系统,您应该考虑使用SSO这样的CAS。已弃用的Acegi插件和用于grails的新Spring Security插件都支持CAS。在互联网网站场景中,OpenID也可以是一个简单而便宜(免费)的选项。具有更细粒度角色建模的一级auth系统也可以选择

相关问题