我们有一个使用两个域名的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 security,这是我们需要避免的。
另一个问题是,既然是同一个web应用程序,为什么它需要用户登录两次?是不是因为tomcat web安全是基于域的?那么,即使另一个域只是原始域的别名?
谢谢!
发布于 2010-08-05 21:55:38
我认为问题在于身份验证是基于会话和域上的会话。如果你有一个两级认证系统,你真的应该考虑像CAS这样的单点登录。已弃用的Acegi插件和grails的新Spring Security插件都支持CAS。在互联网网站的场景中,OpenID也可能是一个简单而便宜(免费)的选择。具有更细粒度角色建模的一级身份验证系统也可以作为选项
https://stackoverflow.com/questions/3412454
复制相似问题