需要存储用户上传的身份证信息,怎么安全性高一点
类似身份证这些很私密,而且重要的东西,如果需要用户上传身份证图片,怎么存储和展示安全性高一点?
图片存到服务器,向用户展示的时候用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和存储地址。
去获取的时候不是直接获取其地址,而是通过其唯一标识符

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

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

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.
