我正在为我的 Struts2 应用程序使用 Tomcat。这web.xml
具有某些条目,如下所示:
<security-constraint>
<web-resource-collection>
<web-resource-name>restricted methods</web-resource-name>
<url-pattern>/*</url-pattern>
<http-method>PUT</http-method>
<http-method>DELETE</http-method>
<http-method>TRACE</http-method>
</web-resource-collection>
<auth-constraint />
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>no_access</web-resource-name>
<url-pattern>/jsp/*</url-pattern>
</web-resource-collection>
<auth-constraint/>
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>no_access</web-resource-name>
<url-pattern>/myrrunner/*</url-pattern>
</web-resource-collection>
<auth-constraint/>
</security-constraint>
如何更改上述黑名单部分以仅使用白名单部分...例如,而不是黑名单PUT
, DELTE
http 方法,我需要将其他方法列入白名单,但我不确定将它们列入白名单的语法以及将它们列入白名单的方法。
对于我上面的web.xml
片段,如果有人能为我提供上面的白名单对应部分,我将不胜感激xml
.
编辑:另外,我如何真正验证该解决方案是否有效?
Thanks
我会尝试以下操作:
<security-constraint>
<web-resource-collection>
<url-pattern>/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<!-- no auth-constraint tag here -->
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>restricted methods</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint/>
</security-constraint>
首先security-constraint
没有任何auth-constraint
,因此任何人无需登录即可使用 GET 和 POST 方法。第二个限制每个人的其他 http 方法。 (我没试过。)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)