Question

How would I only allow users authenticated via Python code to access certain files on the server?

For instance, say I have /static/book.txt which I want to protect. When a user accesses /some/path/that/validates/him, a Python script deems him worthy of accessing /static/book.txt and redirects him to that path.

How would I stop users who bypass the script and directly access /static/book.txt?

Was it helpful?

Solution

Lighttpd has mod_secdownload for this. Basically, it won't serve the static content directly unless you generate a short-lived static URL for it.

Note that you can do similar things on S3 for static content. It's a quite useful feature.

OTHER TIPS

You might want to just have your Python script open the file and dump the contents as its output if the user is properly authenticated. Put the files you want to protect in a folder that is outside of the webserver root.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top