类似身份证这些很私密,而且重要的东西,如果需要用户上传身份证图片,怎么存储和展示安全性高一点?
图片存到服务器,向用户展示的时候用URL的形式?
就比如淘宝等的卖家验证的时候,需要传身份证图片,整个流程应该是怎么样的?
回复内容:
类似身份证这些很私密,而且重要的东西,如果需要用户上传身份证图片,怎么存储和展示安全性高一点?
图片存到服务器,向用户展示的时候用URL的形式?
就比如淘宝等的卖家验证的时候,需要传身份证图片,整个流程应该是怎么样的?
首先不要在常识上作死:
- 涉及敏感身份信息时,HTTPS是必须的。
- 图片千万不要给出直接访问到图片文件的地址。
- 图片文件本身一定要在www根目录之外,实在不行那就要用http服务器的规则(
.htaccess
等)卡死一切访问。 - 千万不要用referer之类自欺欺人的限制方法。
- 敏感信息必须分库,测试环境和生产环境必须严格分离,DBA和开发必须严格分权。严禁开发人员在真正的敏感信息库中“畅通无阻”。
常识没问题的基础上,从访问控制技术来说:
- 实际上只要敏感信息(身份证图,以及姓名性别身份证号等文字)HTTPS就可以了。完全可以HTTP页面+JS脚本动态请求HTTPS内容,甚至
<iframe></iframe>
也是个选择。如果条件不允许,其实不一定要一步到位全程HTTPS。 - 图片务必用PHP请求直接写给用户,这样才有可能用代码来保证卡住图片的访问权。
从安全策略来说:
- 社会工程学才是杀招。真正最不安全的地方是用户自己。
- 用户只要完成普通登录,就获得操作自己的数据的全部权力,这是极其危险的。
- 所以一定要引入两步验证。一般的操作,普通登录即可;但对敏感数据的操作,必须二次验证。
- 二次验证时验密是肯定的,必要时还可以考虑加验安全问题/手机验证码/出生日期等其他信息。
- 二次验证成功后(允许操作敏感信息)的超时时间,必须比一次验证(用户普通登录)的要短。造成用户即使尚未退出登录,但对敏感信息的操作已经需要重输密码的效果就对了。
- 二次验证绝对不能有任何的“保存密码”一类的设计。
- 允许用户在多个浏览器(或多个终端)上同时登录(一次验证)没有问题,但二次验证必须卡死:同一时刻只有一个终端,能够获得二次验证之后的登录权。
- 终端的识别办法很多。用session识别是最基本的,如果还能记录用户ip那就很安全了。
那么总结一下:
- 部署二次验证。
- 二次验证成功后,后台在数据库(或缓存)中记录:用户u,在IP地址为x的y终端上,在z时刻之前对敏感数据有访问权。
- 对敏感数据的一切操作(上传表单、下载图片、下载文字信息等),后台都要验证xyz是否符合。符合才能放行。
- 连一次登录都对不上的(登录者根本不是u),阻止就好了。
- 麻烦的是一次认证正确(登录者确实是用户u),但二次认证信息xyz不符。
- 此时必须:【一】阻止请求敏感信息 【二】提示客户端重新做二次验证 【三】把数据库中的xyz清除,即只要发现这个用户一切的可疑访问,就认为这个用户有安全风险,把他从二次验证里踢出去。
你应该把这些身份证图片当成私人附件来存储。这些图片肯定是不能直接通过URL来访问的,比如你可以把这些图片存储在网站根目录外的其他目录。输出时由程序输出:
<code><?php auth(); //用户身份认证 header('Content-type: image/png'); //文件类型 readfile($file_path); //显示图片,$file_path是图片存储的路径 </code></code>
授权访问,为图片设置一个id和存储地址。
去获取的时候不是直接获取其地址,而是通过其唯一标识符

The article discusses the differences between unset() and unlink() functions in programming, focusing on their purposes and use cases. Unset() removes variables from memory, while unlink() deletes files from the filesystem. Both are crucial for effec

PHP traits enable code reuse in single inheritance contexts, offering benefits like reusability and simplified inheritance. They can be effectively combined with traditional inheritance to enhance class flexibility and modularity.

PHP does not support multiple inheritance but uses interfaces and traits as alternatives to achieve similar functionality, avoiding issues like the diamond problem.

Inheritance in PHP allows classes to inherit properties and methods, promoting code reuse and hierarchical organization. Key benefits include reusability, abstraction, and polymorphism. Common mistakes to avoid are overuse of inheritance and ignoring

The article discusses three main error types in programming: syntax, runtime, and logical errors. It explains their causes, prevention strategies, impacts on performance and user experience, and methods for diagnosis and resolution.

Article discusses PHP and HTML interaction, best practices for embedding PHP in HTML, dynamic HTML content generation, and recommended development tools.

The article discusses the differences between for and foreach loops in PHP, focusing on syntax, usage, control, and performance. Foreach is preferred for array iteration due to simplicity and efficiency, but for loops are better for index-based opera

The article discusses the crucial role of the PHP parser in script execution, focusing on its tasks in syntax analysis, error handling, and code optimization, and how its efficiency impacts web application performance.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 English version
Recommended: Win version, supports code prompts!

SublimeText3 Linux new version
SublimeText3 Linux latest version

Notepad++7.3.1
Easy-to-use and free code editor
