【发布时间】:2015-07-12 04:22:30
【问题描述】:
我在保护我的应用程序页面时遇到问题。这是我的 PrettyFaces 重写规则:
<url-mapping id="cms">
<pattern value="/administrator" />
<view-id value="/faces/backend/index.xhtml" />
</url-mapping>
这是我在 web.xml 中的安全配置:
<security-constraint>
<display-name>Admin Pages</display-name>
<web-resource-collection>
<web-resource-name>Protected Admin Area</web-resource-name>
<description/>
<url-pattern>/faces/backend/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>HEAD</http-method>
<http-method>PUT</http-method>
<http-method>OPTIONS</http-method>
<http-method>TRACE</http-method>
<http-method>DELETE</http-method>
</web-resource-collection>
<auth-constraint>
<description/>
<role-name>admin</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>JDBCRealm</realm-name>
<form-login-config>
<form-login-page>/faces/login/login.xhtml</form-login-page>
<form-error-page>/faces/login/loginerror.xhtml</form-error-page>
</form-login-config>
</login-config>
如您所见,我想保护以下所有视图:
/faces/backend/*
但问题是这样的。当我去 url (rewrite) 比如:
http://mydomain/administrator
应用程序应重定向到登录页面,因为此 url 导致 /faces/backend/* 下的安全视图。但是用户可以在这个页面上进入。
当我使用 url 时:
http://mydomain/faces/backend/index.xhtml
安全工作正确。但我也想确保重写规则。如何解决?我将不胜感激。
【问题讨论】:
标签: jakarta-ee jsf-2 url-rewriting glassfish prettyfaces