我正在尝试从登录身份验证中排除一个JSF页面。我在 web.xml 中添加了一个没有身份验证约束标签的安全约束,如下所述:https://blog.mafr.de/2011/04/17/excluding-pages-from-auth/
这并不能解决问题,因为我使用的是在我的 web.xml 中配置的基于容器的登录配置。
有没有办法在保持当前登录配置的同时,只访问一个 JSF 页面而无需登录?
这是我的登录和安全约束配置:
<security-constraint>
<web-resource-collection>
<web-resource-name>Restricted Employees</web-resource-name>
<url-pattern>/employee</url-pattern>
<http-method>POST</http-method>
<http-method>GET</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>team_leaders</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>Public</web-resource-name>
<description>No login required for accepting requests</description>
<url-pattern>/acceptRequests</url-pattern>
<http-method>POST</http-method>
<http-method>GET</http-method>
</web-resource-collection>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<form-login-config>
<form-login-page>/login.xhtml</form-login-page>
<form-error-page>/login.xhtml</form-error-page>
</form-login-config>
</login-config>
原来 web.xml 中的配置没有被使用,并且有一个提供授权的过滤器类。它仅限于 xhtml 文件,所以这就是为什么我对 html 文件没有问题。