我一直在努力保护我的项目。我有一个使用 LDAP 服务器进行身份验证的登录页面,如果不正确,它会显示一个错误页面等。我现在刚刚添加
<auth-constraint> <!-- Currently causing a 403, looks like stoping .css files -->
<role-name>*</role-name>
</auth-constraint>
to my web.xml,以确保用户在可以查看任何页面之前经过身份验证,但是它似乎阻止了我的 .css 文件,我认为现在登录页面根本不显示任何 css,并且只是白色基本的,当我按提交我得到:
- http://localhost:8080/fileuploadWithPreview/javax.faces.resource/theme.css.xhtml?ln=primefaces-aristo http://localhost:8080/fileuploadWithPreview/javax.faces.resource/theme.css.xhtml?ln=primefaces-aristo
出现此错误:
HTTP 状态 403 - 对请求的资源的访问已被拒绝
type状况报告
message对所请求资源的访问已被拒绝
描述对指定资源的访问(对所请求的资源的访问已被拒绝)已被禁止。
GlassFish 服务器开源版 3.1.2.2
这是我的web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<filter>
<filter-name>Upload Filter</filter-name>
<filter-class>richard.fileupload.UploadFilter</filter-class>
<init-param>
<param-name>sizeThreshold</param-name>
<param-value>1024</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Upload Filter</filter-name>
<url-pattern>/upload/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<context-param>
<param-name>facelets.LIBRARIES</param-name>
<param-value>/WEB-INF/corejsf.taglib.xml</param-value>
</context-param>
<context-param>
<param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
<param-value>true</param-value>
</context-param>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>LDAP</realm-name>
<form-login-config>
<form-login-page>/login.xhtml</form-login-page>
<form-error-page>/login-failed.xhtml</form-error-page>
</form-login-config>
</login-config>
<security-role>
<role-name>user</role-name>
</security-role>
<security-constraint>
<web-resource-collection>
<web-resource-name>Allowed resources</web-resource-name>
<url-pattern>/javax.faces.resources/*</url-pattern>
</web-resource-collection>
<!-- web resources that are protected -->
<web-resource-collection>
<web-resource-name>All Resources</web-resource-name>
<url-pattern>/*</url-pattern>
<!-- this is currently causing a 404 -->
<http-method>GETLIB</http-method>
<http-method>COPY</http-method>
<http-method>MOVE</http-method>
<http-method>DELETE</http-method>
<http-method>PROPFIND</http-method>
<http-method>GET</http-method>
<http-method>HEAD</http-method>
<http-method>PUT</http-method>
<http-method>MKCOL</http-method>
<http-method>PROPPATCH</http-method>
<http-method>LOCK</http-method>
<http-method>UNLOCK</http-method>
<http-method>VERSION-CONTROL</http-method>
<http-method>CHECKIN</http-method>
<http-method>CHECKOUT</http-method>
<http-method>UNCHECKOUT</http-method>
<http-method>REPORT</http-method>
<http-method>UPDATE</http-method>
<http-method>CANCELUPLOAD</http-method>
</web-resource-collection>
<auth-constraint> <!-- Currently causing a 403, looks like stoping .css files -->
<role-name>*</role-name>
</auth-constraint>
</security-constraint>
</web-app>
基本上,是什么阻止了我的 css 文件以及如何允许它?
您的安全限制还会阻止对 CSS 文件的请求(基本上,它会阻止一切与指定的 URL 模式匹配/*
期望指定的登录页面)。您需要添加另一个安全约束,该约束应允许对 JSF 资源的请求。关键是省略身份验证约束,使每个人都可以访问这些资源。
<security-constraint>
<web-resource-collection>
<web-resource-name>Allowed resources</web-resource-name>
<url-pattern>/javax.faces.resource/*</url-pattern>
</web-resource-collection>
<!-- No Auth Contraint! -->
</security-constraint>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)