Django storage backend that can be used to serve files via lighttpd’s mod_secdownload module. This storage backend is an extension to the reqular FileSystemStorage that will generate proper signed download urls.
Installation
pip install django-secdownload-storage
or:
easy_install django-secdownload-storage
or via source checkout:
hg clone https://bitbucket.org/ionelmc/django-secdownload-storage cd django-secdownload-storage python setup.py install
Usage
In your django models you should add storage=SecDownloadFileSystemStorage() to the fields you want served via secdownload.
Required settings:
SEC_DOWNLOAD_ENABLED = True SEC_DOWNLOAD_SECRET_KEY = 'VERYVERYSECRET' SEC_DOWNLOAD_MEDIA_URL = MEDIA_URL + 'dl/'
Example model:
import secdownload_storage class Foo(models.Model): secret_picture = models.ImageField(upload_to='secret-pictures', storage=secdownload_storage.SecDownloadFileSystemStorage())
You need to enable mod_secdownload and have configuration similar to this (see http://redmine.lighttpd.net/wiki/1/Docs:ModSecDownload for more info):
secdownload.secret = "VERYVERYSECRET" secdownload.document-root = "/path/to/media" secdownload.uri-prefix = "/dl/" secdownload.timeout = 3600
Also, note that you should disallow access to those files in the lighttpd configuration as they would be served with your regular media files. Eg:
$HTTP["url"] =~ "^/media/secret-pictures" {
url.access-deny = ("")
}
Configuration
SEC_DOWNLOAD_ENABLED - set this to False to disable signing the urls and generate them like FileSystemStorage. This is useful for development (if you use django’s devserver).
SEC_DOWNLOAD_SECRET_KEY - this is the secret key that is used to sign the requests
SEC_DOWNLOAD_MEDIA_URL - this is the prefix path that’s used instead of MEDIA_URL when SEC_DOWNLOAD_ENABLED is set to True. If SEC_DOWNLOAD_ENABLED is set to False SecDownloadFileSystemStorage will use MEDIA_URL for the prefix instead.
Metadata
Release files for django-secdownload-storage 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-secdownload-storage-0.1.1.tar.gz | 2.7 kB | Without provenance | Details for django-secdownload-storage-0.1.1.tar.gz |
Release files / django-secdownload-storage-0.1.1.tar.gz
| Download URL | django-secdownload-storage-0.1.1.tar.gz |
|---|---|
| Size | 2.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
565e0fd05fcc0c7f12ecd621b99d29361f89000620d408c391cd6cdab082c105
|
|
BLAKE2b-256 checksum How to use checksums |
1e45bb2eeb77217d654ee66ebcc0bf809f957331cb22fe5a989cc9cfcde28a32
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-secdownload-storage 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.