Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Secure files for download

I want to have a folder, lets call it docs, that contains documents that logged in users can download. These have very sensitive information. How can I best secure the folder. I come from a PHP background so want to know if I have overlooked anything.

I will secure the folder with .htaccess and also when the users click download they are never shown the folder. The download is forced through to them via php removing the folder name.

Of course to secure the users area I am implementing sanitation and validation on all input fields plus watching out for SQLInjections. Using an SSL connection. Turned off all php warnings. The secure area uses SESSION variables to control access and re-verify users for special tasks such as changing passwords. Plus a timeout feature of 10 minutes, after which the user has to re-enter details.

I am trying to be as thorough as possible so any advice no matter how small will be welcomed.

like image 680
Somk Avatar asked May 31 '12 13:05

Somk


People also ask

How do I download a secure file from Azure DevOps?

You can utilize "Download Secure File task" to download from the library on to your agent. Yes, the task downloads the file under $(Agent. TempDirectory) on your agent machine and you can use copyFiles task to copy it to your target location which can reference in your properties file. Thanks!

Are https downloads secure?

HTTPS [also known as HTTP over Transport Layer Security (TLS), HTTP over SSL, or HTTP Secure] is the secure version of HTTP, and it's a widely-used protocol for secure communications online.

How do I access Azure DevOps secure file?

In Azure Pipelines, select the Library tab. Select the Secure files tab at the top.


1 Answers

Put the files outside of the webroot. Then using PHP pass the file though a script. That way no one can link to the file directly and bypass your controls. (Naturally make sure the script that does this only after verifying the user has permission to retrieve that file).

Sample PHP:

<?php
    if (!isset($_SESSION['authenticated'])) {
        exit;
    }
    $file = '/path/to/file/outside/www/secret.pdf';

    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename=' . basename($file));
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Pragma: public');
    header('Content-Length: ' . filesize($file));
    ob_clean();
    flush();
    readfile($file);
    exit;
?>
like image 92
John Conde Avatar answered Nov 10 '22 01:11

John Conde