Quote:
Originally Posted by Publisher Bucks
Is there any reason that I shouldnt put this in a .php script to allow a client to download a digital file they have purchased?
define('PROTECTED_USERNAME', 'username');
define('PROTECTED_PASSWORD', 'password');
This is to let a client download a file in a .htpasswd protected directory.
The download link is already limited to 30 minutes and before the links are given they have to enter a transaction id and their first and last name.
Any security issue is what I'm mainly concerned about.
Thanks.
|
It all comes down to how important the information you're protecting is. When I do development versions of software, I hide them behind HTTP basic authentication, because it's a minor problem if the information gets leaked. It's already going to go live soon anyway.
If you are fine with the security issues related to HTTP basic authentication, like issues related to brute forcing, password sharing, and the like, then there is no problem rolling a PHP variant.
I will always caution against storing passwords in plaintext. If someone does gain access this file or the information related to it, that information would be compromised. This is why the standard is to one-way salt and hash a password using an algorithm, like bcrypt.
I wouldn't consider the other metadata you're collecting to be secure, but again, it depends on how important the protected information is.
If you decide to do HTTP basic authentication, I would recommend just implementing actual standard http basic authentication through the htpasswd command and use the bcrypt flag:
https://httpd.apache.org/docs/2.4/howto/auth.html
https://httpd.apache.org/docs/trunk/.../htpasswd.html
You can even access that data in PHP:
https://www.php.net/manual/en/features.http-auth.php
Nginx has an equivalent.
As an aside, if you have a database of users and passwords, you may be better off with an actual login manager, but that might be a level above what you're trying to do.