我有一个网站,只有获得授权的人才能进入。如果有人没有授权,我的web.xml将他们重定向到一个403个错误页面。
但是,我的应用程序和错误页面都使用一些外部js和css文件(例如引导)。从逻辑上讲,403错误页不能访问这些js/css文件,因为除了错误页html之外,所有内容都禁止使用权限。
我该如何巧妙地解决这个问题呢?我应该公开我的库文件夹吗?如果是这样,我如何才能覆盖特定文件夹的安全规则?
我浏览了一下这里的文件,但是我没有看到提到过这个场景。我认为我必须在"/libraries“中添加一个安全约束,并以某种方式覆盖HTTP所需的角色?
我的web.xml的潜在相关部分:
<error-page>
<error-code>403</error-code>
<location>/errorPages/forbidden.jsp</location>
</error-page>
<security-role>
<role-name>myRole</role-name>
</security-role>
<security-constraint>
<display-name>MySecurityConstraint</display-name>
<web-resource-collection>
<web-resource-name>WebResource</web-resource-name>
<url-pattern>/*</url-pattern>
<http-method>GET</http-method>
<http-method>DELETE</http-method>
<http-method>PUT</http-method>
<http-method>HEAD</http-method>
<http-method>OPTIONS</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>myRole</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>发布于 2016-11-01 14:46:37
您可以简单地添加一个额外的安全约束,其中包含详细的路径,并且不需要auth约束。
<security-constraint>
<display-name>NoSecurityConstraint</display-name>
<web-resource-collection>
<web-resource-name>WebResource</web-resource-name>
<url-pattern>/library/*</url-pattern>
<http-method>GET</http-method>
<http-method>DELETE</http-method>
<http-method>PUT</http-method>
<http-method>HEAD</http-method>
<http-method>OPTIONS</http-method>
<http-method>POST</http-method>
</web-resource-collection>
</security-constraint>我希望这能解决你的问题
https://stackoverflow.com/questions/40356851
复制相似问题