gpt4 book ai didi

javascript - 阻止用户访问 Apache Tomcat 上托管的资源文件夹中的文件

转载 作者:行者123 更新时间:2023-11-28 23:34:12 30 4
gpt4 key购买 nike

你好我的网址是

www.abcdef.com/context/index.html

但是用户也可以访问

www.abcdef/context/resources/somPngFile.png

我不想要

(这里的资源是我保存图像文件的文件夹)

此外,我还在 index.html 中进行所有验证和 session 检查。如果用户直接从 url 访问 png 文件,他就能够获取它。任何关于如何避免这种情况的解决方案都将受到赞赏。我使用 apache tomcat 作为服务器并在 jquery 中编码。

最佳答案

我通过将下面的代码放在 web.xml 中解决了这个问题..不过感谢您的评论..

<security-constraint>
<web-resource-collection>
<web-resource-name>HTTP-Protected-Resource-1</web-resource-name>
<description>Description here</description>
<url-pattern>/resources/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>NOSOUPFORYOU</role-name>
</auth-constraint>
</security-constraint>

关于javascript - 阻止用户访问 Apache Tomcat 上托管的资源文件夹中的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26363119/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com