如果我们只使用表单身份验证,如何存储机密 PDF 文档(文件系统与 SQL)
这是我的情况。我们有一个处理案例管理的网络应用程序。对于每种情况,通常都有多个 PDF 文档。我的公司以前将这些文件存储在标准文件柜中。当我们必须查找案例时,这让事情变得很头痛,因为我们需要访问网络应用程序,查找案例信息,然后转到文件柜。我想开发一种方法,以便用户可以通过网络应用程序上传文档并将它们链接在一起,这样当您在网络应用程序上找到它时,只需单击链接即可获取关联的文件。
在网络应用程序上,我们使用表单身份验证。对于每个 ASPX 页面,我都会检查 cookie,如果存在则可以使用。否则,他们将被重定向到登录页面。
然而,我现在遇到了障碍。我计划将 PDF 上传到服务器,并在 Cases 表中创建一个列,该列将返回文件服务器上文档的链接。那么问题是,如果用户没有登录(或者他们已经离开公司),他们只需将链接复制并粘贴到地址栏中,然后他们现在就可以访问该案例的文件信息。这不可能发生。
另一种解决方案是将文件存储在 SQL Server 2008 R2 中。但是,我阅读了很多有关性能问题等的信息。因此,我不完全确定这是否是最佳解决方案。目前它是唯一的一个。
如果有人对我如何处理这种情况有一些想法,我将非常感谢任何和所有反馈。
谢谢, 安德鲁
So here's my situation. We have a web app that handles case management. For each case, there are typically several PDF documents. My company previously stored these documents in a standard filing cabinet. This made things a headache when we had to look up a case as we'd go to the web app, find the case information, then go to the filing cabinet. I want to develop a method so that users can upload the documents via the web app and link them together, so that when you find it on the web app you can just click a link to get the associated files.
On the web app, we utilize forms authentication. For each ASPX page, I check for the cookie and if one exists they're good to go. Otherwise, they're redirected to the login page.
However, I've now hit a roadblock. I was planning on just uploading the PDFs to the server and create a column in the Cases table that would return the link to the document on the file server. The issue then, is if the user isn't logged in (or they've left the company) and they just copy and paste the link into the address bar and BAM they now have access to that case's file information. This cannot happen.
The other solution is just storing the files in SQL Server 2008 R2. However, I've read a lot of information about performance issues, etc. So, I'm not entirely sure if that's the best solution. Currently it's the only one.
If anyone has some thoughts as to how else I could handle this scenario, I would greatly appreciate any and all feedback.
Thanks,
Andrew
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您实际上在这里处理两个不同的问题:文档的存储系统和文档的安全性。
在存储位置方面,可以直接存储在文件系统中,也可以使用SQL 2008的FileStream功能存储。
在确保它们安全方面,我会采用类似于 FreudianSlip 建议的方法。拥有一个页面,向其传递文档名称(或其他一些键,例如将其存储在 SQL Server 中的 ID),并让该页面验证用户的授权、读取文件并将其推回响应流中。
无论如何,我建议更新您的 web.config 以使用实际的表单身份验证和授权,这样您就不需要每次都显式检查 cookie。它将由asp.net 平台处理。
You are really dealing with two different issues here: storage system for the documents and security for the documents.
In terms of storage location, you can store them directly in the file system or store them using SQL 2008's FileStream feature.
In terms of securing them, I would go with something similar to what FreudianSlip suggested. Have a page where you pass it the document name (or some other key, such as the ID if storing it in SQL Server), and have that page verify the user's authorization, read the file, and push it back in the response stream.
No matter what, I would recommend updating your web.config to use actual Forms Authentication and authorization so you don't need to explicitly check the cookie each time. It will be handled by the asp.net platform.
您可以不将链接设置为指向 pdf 文档的直接链接,而是将其设置为验证任何所需凭据的脚本,然后如果一切正常,则提供文件。
http://link.to.pdf/servePDF.asp?docname=mycasedoc.pdf
servePDF.asp 验证所有会话/cookie,如果一切正常则推送文档。
You could, instead of making the link a direct link to the pdf document, make it to a script that validates any needed credentials, then if all is good, feeds the file.
http://link.to.pdf/servePDF.asp?docname=mycasedoc.pdf
servePDF.asp validates any sessions/cookies and if all is ok pushes the doc.
像这样的东西。
此选项将允许您完全混淆文件的真实位置。
something like this.
this option would allow you to completely obfuscate the true location of the file.
您可以使用 Global.asax Application_AuthenticateRequest 事件并基于静态文件夹(如 /assets/)编写自定义逻辑,并在那里进行自定义验证。
同样,您也可以注册一个 HTTP 模块并执行相同的操作。
http://support.microsoft.com/kb/307996
您还可以实现 HTTP Handeler接受对给定路径的请求,然后进行一些验证并返回文件内容,如 Jeff Turner 建议的那样。
请参阅http://support.microsoft.com/kb/308001
You can use the Global.asax Application_AuthenticateRequest event and write custom logic based on a static folder (like /assets/) and do your custom validation there.
Likewise, you can also register a HTTP Module and do the same thing.
http://support.microsoft.com/kb/307996
You could also implement a HTTP Handeler to accept requests to a given path and then doing some validation and return the file contents like Jeff Turner suggested.
See http://support.microsoft.com/kb/308001
我建议将 PDF 保存在单独的目录中。然后在同一目录中构建一个附加的 web.config 文件以指定表单身份验证访问。例如:
I would suggest keeping the PDFs in their separate directory. Then build an additional web.config file in that same directory to specify form authentication access. For example: