Guidance and Advice On How To Setup HTTP Authentication For File Download Webpage WordPress AWS EC2 Ubuntu

I have a wordpress site running on AWS EC2 Ubuntu. I don't know how to technically describe this but here it goes:
I need a page URL that when you go to the URL it will Automatically allow someone to download a CSV file after HTTP Authentication.

I have seen and tried tutorials for setting up a HTTP Authentication for my Admin Sign in page. But I can't find any help on setting up a single page.  I am also up to suggestions on how to setup this HTTP Authentication on AWS S3 Bucket. I hope this makes sense. Thank you for the help.
LVL 1
Dustin StanleyEntrepreneurAsked:
Who is Participating?
 
shalomcCTOCommented:
The <files> directive can be placed inside "directory" and can refer to a single file by name.
This should work.

<Location "/demo">
	<Files "cat.html">
		AuthBasicFake someuser somepass
	</Files>
</Location>

Open in new window


Apache docs of the <files> directive
https://httpd.apache.org/docs/2.4/mod/core.html#files

For S3, you can only do that by using a CDN in front of S3.
With many CDN services (Akamai, Edgecast, Fastly ...) it is a piece of cake.  

With Cloudfront, you have to inject a Lambda@Edge response. An example is to be found here.

https://gist.github.com/lmakarov/e5984ec16a76548ff2b278c06027f1a4

Or, adapt this AWS example. You have to check for the existence of a specific header with a specific value, and return a 401 error on failure.
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-examples.html#lambda-examples-redirect-to-signin-page

Authorization: Basic QWxhZGRpbjpPcGVuU2VzYW1l

Open in new window

The value is the user & password separated by a colon and base64 encoded.


An example of a full 401 response.
https://en.wikipedia.org/wiki/Basic_access_authentication#Server_side
0
 
Dave BaldwinFixer of ProblemsCommented:
I have never heard of using HTTP Authentication for a single file, just directories.
0
 
Dustin StanleyEntrepreneurAuthor Commented:
I thank you all for the help. Just to clarify what my developer has told me is I could use something like:
http://louis:znxah&jfja_@My-Site.com/Files/UploadFile.xml

Open in new window

to upload my file automatically.

The answers above...would this be the easiest route? Thanks.
0
 
Dustin StanleyEntrepreneurAuthor Commented:
Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.