{ "info": { "author": "Cobus Carstens", "author_email": "cobus.carstens@gmail.com", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Framework :: Django", "Framework :: Django :: 1.9", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: Dynamic Content" ], "description": "![Build Status](https://www.travis-ci.org/cobusc/protected-media-prototype.svg?branch=master)\n\nDjango Protected Media\n======================\n\nDjango Protected Media is a Django app that manages media that are considered\nsensitive in a protected fashion.\n\nNot only does the media get stored in a separate filesystem location, but authorisation\nis also required to access it.\n\nThe application allows for setups where Django performs the authorisation, but\nhands off the serving of the file to a web server, like Nginx.\n\nQuick start\n-----------\n\n1. Add \"protected_media\" to your INSTALLED_APPS setting like this:\n```python\nINSTALLED_APPS = [\n ...\n 'protected_media',\n]\n```\n\n2. Include the URLconf in your project urls.py like this::\n```\nurl(r'^protected/', include('protected_media.urls')),\n```\n\n3. Add the following settings to `settings.py` if the defaults need to be tweaked:\n```python\nPROTECTED_MEDIA_ROOT = \"%s/protected/\" % BASE_DIR\nPROTECTED_MEDIA_URL = \"/protected\"\nPROTECTED_MEDIA_SERVER = \"nginx\" # Defaults to \"django\"\nPROTECTED_MEDIA_LOCATION_PREFIX = \"/internal\" # Prefix used in nginx config\nPROTECTED_MEDIA_AS_DOWNLOADS = False # Controls inclusion of a Content-Disposition header\n```\n\n4. Use the new field classes in your models:\n```python\ndef SomeModel(models.Model):\n document = ProtectedFileField(upload_to=\"uploads/\")\n picture = ProtectedImageField(upload_to=\"uploads/\")\n # Files will be stored under PROTECTED_MEDIA_ROOT + upload_to\n```\n\nOverview\n--------\n\nDjango manages media based on the following definitions:\n```python\nBASE_DIR = \"/some/application/dir/\"\nMEDIA_ROOT = \"%s/media/\" % BASE_DIR\nMEDIA_URL = \"/media/\"\n```\n\nFile- and image fields are typically defined as:\n```python\ndocument = models.FileField(upload_to=\"uploads/\")\npicture = models.ImageField(upload_to=\"uploads/\")\n# Files will be stored under MEDIA_ROOT + upload_to\n```\n\nIn a typical production environment one would let `nginx` (or some other server) serve the media:\n```\n# Publicly accessible media\nlocation ^~ /media/ {\n alias /some/application/dir/media\n}\n```\n\nThis works well when the media should be publically accessible. However, if the media should be protected, we need a way for Django to check whether the request for the media should only be allowed for logged in (or more stringent criteria) users.\n\nThe `protected_media` application\n--------------------------------\nThe `protected_media` application consists of\n* new `settings.py` attributes,\n* a customized FileSystemStorage class,\n* a custom handler for the protected media URL and\n* additional web server configuration if serving via `nginx` or something similar.\n\nProtected media is stored in a different physical location to publically accessible media. The following settings can be specified in `settings.py`:\n```python\nPROTECTED_MEDIA_ROOT = \"/some/application/dir/protected/\"\nPROTECTED_MEDIA_URL = \"/protected\"\nPROTECTED_MEDIA_SERVER = \"nginx\" # Defaults to \"django\"\nPROTECTED_MEDIA_LOCATION_PREFIX = \"/internal\" # Prefix used in nginx config\n```\n\nWhen defining a file or image field that needs to be protected, we use one of the\nclasses provided by the `protected_media` application:\n* `ProtectedFileField`\n* `ProtectedImageField`\n\nProtected file- and image fields are typically defined as:\n```python\ndocument = ProtectedFileField(upload_to=\"uploads/\")\npicture = ProtectedImageField(upload_to=\"uploads/\")\n# Files will be stored under PROTECTED_MEDIA_ROOT + upload_to\n```\n\nThese classes have a custom storage backend `ProtectedFileSystemStorage` which mananges the filesystem location and URLs associated with protected media.\n\nWhen `nginx` is used, the configuration must be updated to look like this:\n```\n# Publicly accessible media\nlocation /media {\n alias /some/application/dir/media;\n}\n\n# Protected media\nlocation /internal {\n internal;\n alias /some/application/dir/protected;\n}\n```", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://www.example.com/", "keywords": "", "license": "BSD License", "maintainer": "", "maintainer_email": "", "name": "django-protected-media", "package_url": "https://pypi.org/project/django-protected-media/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-protected-media/", "project_urls": { "Homepage": "https://www.example.com/" }, "release_url": "https://pypi.org/project/django-protected-media/0.0.3/", "requires_dist": null, "requires_python": "", "summary": "A simple Django app to serve protected media", "version": "0.0.3" }, "last_serial": 4711131, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "d7f75655e08657a96b1ffb67f709e928", "sha256": "8d7ce7879fcc9b3c64fe13de165f907fbd59778003e04946c83217a8892f6ba6" }, "downloads": -1, "filename": "django-protected-media-0.0.1.tar.gz", "has_sig": false, "md5_digest": "d7f75655e08657a96b1ffb67f709e928", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6397, "upload_time": "2017-05-12T12:12:07", "url": "https://files.pythonhosted.org/packages/e2/3a/7286f5680863dde0bf4f224544ea1dce4b76ef717864361f21968e34149c/django-protected-media-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "7ee522f5a34a691f27e13f8a42395be9", "sha256": "6db4872ef5a9f2ea9f4facb62da743d495fffa3c58add7c7f7c8c10498d6ffcb" }, "downloads": -1, "filename": "django-protected-media-0.0.2.tar.gz", "has_sig": false, "md5_digest": "7ee522f5a34a691f27e13f8a42395be9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7470, "upload_time": "2017-05-12T13:40:52", "url": "https://files.pythonhosted.org/packages/b3/b2/9abf6d603fa2ebb4a05181f8fb0e4ad9533495dbd79b122624eb841ec88d/django-protected-media-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "5824ca26c9a670d2d03a45ef760ba6c6", "sha256": "08706f2527ae4a6fcf09f5c49a6e386ca6fe542476c3f65551b0045c8db8c181" }, "downloads": -1, "filename": "django-protected-media-0.0.3.tar.gz", "has_sig": false, "md5_digest": "5824ca26c9a670d2d03a45ef760ba6c6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7974, "upload_time": "2017-05-15T11:43:00", "url": "https://files.pythonhosted.org/packages/45/43/dc6d161adc19f996aa0e67c08ebdbbe6a46f7ac05e799936de1e68814bb6/django-protected-media-0.0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "5824ca26c9a670d2d03a45ef760ba6c6", "sha256": "08706f2527ae4a6fcf09f5c49a6e386ca6fe542476c3f65551b0045c8db8c181" }, "downloads": -1, "filename": "django-protected-media-0.0.3.tar.gz", "has_sig": false, "md5_digest": "5824ca26c9a670d2d03a45ef760ba6c6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7974, "upload_time": "2017-05-15T11:43:00", "url": "https://files.pythonhosted.org/packages/45/43/dc6d161adc19f996aa0e67c08ebdbbe6a46f7ac05e799936de1e68814bb6/django-protected-media-0.0.3.tar.gz" } ] }