Mik*_*ike 22 java tomcat web.xml struts2 security-constraint
我正在使用Tomcat作为我的Struts2应用程序.在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>
Run Code Online (Sandbox Code Playgroud)
如何更改上面列入黑名单的部分只使用白名单部分...例如,我需要将其他方法列入白名单,而不是黑名单PUT,DELTE但我不确定将它们列入白名单的语法以及将它们列入白名单的方法.
对于我上面的web.xml片段,我会很感激,如果有人可以为我提供whitelisitng对应部分xml.
编辑:另外,我如何真正验证解决方案是否有效?
谢谢
pal*_*int 20
我会尝试以下方法:
<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>
Run Code Online (Sandbox Code Playgroud)
第一个security-constraint没有auth-constraint,所以没有登录的任何人都可以使用GET和POST方法.第二个限制每个人的其他http方法.(我没试过.)
avi*_*ned 11
Java EE 6的新功能,简化了应用程序的安全配置.您现在可以在web.xml中将白名单与黑名单允许的HTTP方法配对:
<security-constraint>
<web-resource-collection>
<web-resource-name>Disable unneeded HTTP methods by 403 Forbidden them</web-resource-name>
<url-pattern>*</url-pattern>
<http-method-omission>GET</http-method-omission>
<http-method-omission>HEAD</http-method-omission>
<http-method-omission>POST</http-method-omission>
</web-resource-collection>
<auth-constraint />
</security-constraint>
Run Code Online (Sandbox Code Playgroud)
参考:https://blogs.oracle.com/nithya/entry/new_security_features_in_glassfish
| 归档时间: |
|
| 查看次数: |
35138 次 |
| 最近记录: |