如何通过 Node.js 保护敏感图像/文件免遭直接 URL 访问
各位开发人员大家好,
我在 NodeJS 中遇到了一个(至少对我来说)具有挑战性的问题。我将非常感谢一些帮助。
考虑一个带有 NodeJS 后端和 MariahDB-DB 的 React 社区 Web 应用程序。每个用户都可以在他或她的个人相册中上传照片或视频。 仅允许登录用户查看。
现在,乍一看实施起来并不困难。但问题来了:
一旦登录用户看到图像 URL,他或她就可以直接通过浏览器访问图像/文件,甚至将其转发给未经授权的人员。
为了获得解决这个问题的灵感,我研究了 Instagram 的做法,他们似乎在图像中附加了某种哈希值。但我还没有找到有关该技术的更多信息。
那么,问题是:如何防止未经授权的直接访问?什么是最佳实践?
预先非常感谢,
Wiwi
Hello fellow developers,
I am stuck with a (at least to me) challenging problem in NodeJS. I would greatly appreciate some help.
Consider a community webapp in React with a NodeJS-Backend and a MariahDB-DB. Each user can upload photos or videos in his or her personal album.
Only logged-in users are allowed to see it.
Now, the implementation is not hard on first view. But here comes the problem:
Once an logged-in user is shown the image-URL, he or her can access the image/file directly through the browser and even forward it to unauthorized persons.
To get some inspiration to solve this I have looked how Instagram does ist and they seem to append some kind of hash to their images. But I have not found further information about that technique.
So, the question is: How can I prevent unauthorized direct access? What are best-practices?
Thanks so much in advance,
Wiwi
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论