{ "info": { "author": "InterSIS Foundation", "author_email": "dev@sigmaeducation.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: Dynamic Content" ], "description": "[![PyPI](https://img.shields.io/pypi/dm/django-rest-encrypted-lookup.svg)]()\n[![Build Status](https://travis-ci.org/InterSIS/django-rest-encrypted-lookup.svg?branch=master)](https://travis-ci.org/InterSIS/django-rest-encrypted-lookup)\n\ndjango-rest-encrypted-lookup\n=============\n\nDrop-in ViewSets, Serializers, and Fields that replace your IntegerField pk or id lookups with encrypted string lookups. \n\nUse a single cipher across your entire project, or provide a unique cipher for each serializer, model, user, and/or client.\n\nThe json representation of a poll:\n```\n {\n \"id\": 5,\n \"questions\": [\n 2,\n 10,\n 12,\n ]\n }\n```\nbecomes:\n```\n {\n \"id\": \"4xoh7gja2mtvz3i47ywy5h6ouu\",\n \"questions\": [\n \"t6y4zo26vutj4xclh5hpy3sc5m\",\n \"hp7c75ggggiwv6cs5zc4mpzeoe\",\n \"rqq5a2evfokyo7tz74loiu3bcq\",\n ]\n }\n```\n\nChoose a user-by-user cipher such that:\n```\n # User A GETs /api/polls/ and receives:\n \n {\n \"results\": [\n \"4xoh7gja2mtvz3i47ywy5h6ouu\",\n \"12gc75ggggiwv6cs5zc4mpzeoe\",\n ]\n }\n \n # User B GETs /api/polls/ and receives:\n \n {\n \"results\": [\n \"rqq5a2evfokyo7tz74loiu3bcq\",\n \"hp7c75g84g63v6cs5zc423zeoe\",\n ]\n }\n``` \n \n\nIf you prefer hyperlinked related fields:\n```\n {\n \"id\": \"4xoh7gja2mtvz3i47ywy5h6ouu\",\n \"questions\": [\n \"https://example.com/api/questions/t6y4zo26vutj4xclh5hpy3sc5m/\",\n \"https://example.com/api/questions/hp7c75ggggiwv6cs5zc4mpzeoe/\",\n \"https://example.com/api/questions/rqq5a2evfokyo7tz74loiu3bcq/\",\n ]\n }\n```\n\nThe endpoint:\n\n```\n /api/polls/5/\n```\nbecomes:\n```\n /api/polls/4xoh7gja2mtvz3i47ywy5h6ouu/\n```\n\nEncrypted lookups are *not* appropriate to use as a security measure against users guessing object URIs. Encrypted\nlookups *are* appropriate to use as a method of obfuscating object pks/ids.\n\n\nInstallation\n===============\n\nInstall the module in your Python distribution or virtualenv:\n\n $ pip install django-rest-encrypted-lookup\n\nAdd the application to your `INSTALLED_APPS`:\n\n```\n INSTALLED_APPS = (\n ...\n \"rest_framework_encrypted_lookup\",\n ...\n )\n```\n\nAnd in settings.py:\n\n```\n ENCRYPTED_LOOKUP = {\n 'lookup_field_name': 'id', # String value name of your drf lookup field, generally 'id' or 'pk'\n 'secret_key': 'uniquesecret', # Choose a string value unique secret key with which to encrypt your lookup fields\n },\n```\n\nHow it Works\n============\n\nEncrypted lookup strings are *not* stored in the database in association with the objects they represent. Encrypted\nlookups are generated by the model serializers during response composition. Encrypted lookups presented in the endpoint\nURI are decrypted in the call to dispatch, and encrypted lookups presented in data fields are decrypted by the model\ndeserializers.\n\nEncryption is provided by the PyCrypto AES library.\n\nUse\n===\n\ndjango-rest-encrypted-lookup provides three field classes:\n\n from rest_framework_encrypted_lookup.fields import EncryptedLookupField, EncryptedLookupRelatedField, EncryptedLookupHyperlinkedRelatedField\n \ntwo new serializer classes:\n\n from rest_framework_encrypted_lookup.serializers import EncryptedLookupModelSerializer, EncryptedLookupHyperlinkedModelSerializer\n \nand a generic view class:\n\n from rest_framework_encrypted_lookup.views import EncryptedLookupGenericViewSet\n \nUse these in place of the classes provided with Django Rest Framework 3.\n \nExample:\n\n``` \n # models.py\n ...\n class Poll(models.Model):\n ...\n \n \n # serializers.py\n ...\n class PollSerializer(EncryptedLookupModelSerializer):\n\n class Meta:\n model = Poll\n \n \n # views.py\n ...\n from rest_framework import viewsets\n \n class PollViewSet(EncryptedLookupGenericViewSet,\n viewsets.mixins.ListModelMixin,\n viewsets.mixins.RetrieveModelMixin,\n ...\n )\n \n queryset = Poll.objects.all()\n serializer_class = PollSerializer\n \n lookup_field = 'id'\n```\n\nOf the classes included in this package, the example above makes use of `EncryptedLookupModelSerializer`, and \n`EncryptedLookupGenericViewSet`.\n\nThe fields `EncryptedLookupField`, `EncryptedLookupRelatedField` are used implicitly\nby the EncryptedLookupModelSerializer. These fields may also be used explicitly, if needed.\n\nWe could have used `EncryptedLookupHyperlinkedModelSerializer` instead of `EncryptedLookupModelSerializer`:\n```\n # serializers.py\n ...\n class PollSerializer(EncryptedLookupHyperlinkedModelSerializer):\n\n class Meta:\n model = Poll\n```\n\nIn this case, PollSerializer would serialize related fields as hyperlinks, using the `EncryptedHyperlinkedLookupRelatedField`.\n\nBy default, every encrypted-lookup serializer class will use the same cypher. You can choose a non-default cypher by\noverwriting your serializer's `get_cypher` method. Here is a ```get_cypher``` method that will produce a unique cypher per-model:\n\n```\n from rest_framework_encrypted_lookup.utils import IDCipher\n from rest_framework_encrypted_lookup.settings import encrypted_lookup_settings\n\n class MyEncryptedLookupModelSerializer(EncryptedLookupModelSerializer):\n \n def get_cipher(self):\n return IDCipher(secret=encrypted_lookup_settings['secret_key']+self.Meta.model)\n\n```\n\nHere is a ```get_cypher``` method that will produce a unique cypher per-user:\n\n```\n from rest_framework_encrypted_lookup.utils import IDCipher\n from rest_framework_encrypted_lookup.settings import encrypted_lookup_settings\n\n class MyEncryptedLookupModelSerializer(EncryptedLookupModelSerializer):\n \n def get_cipher(self):\n # Let's suppose that a user must be logged in to reach this endpoint.\n \n return IDCipher(secret=encrypted_lookup_settings['secret_key']+self._context[\"request\"].user.username)\n\n```\n\n\nCompatibility\n=============\n\n* Django Rest Framework 3.0, 3.1\n* Django 1.6, 1.7, 1.8\n* Python 2.7, 3.3, 3.4\n\nSee tox.ini for specific minor versions tested.\n\nAdditional Requirements\n=======================\n\n* PyCrypto 2.6.1\n\nTodo\n====\n\n* Helpful exceptions.\n* Coverage.\n\nGetting Involved\n================\n\nFeel free to open pull requests or issues. GitHub is the canonical location of this project.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://intersis.org/", "keywords": null, "license": "GNU General Public License v3 (GPLv3)", "maintainer": null, "maintainer_email": null, "name": "django-rest-encrypted-lookup", "package_url": "https://pypi.org/project/django-rest-encrypted-lookup/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-rest-encrypted-lookup/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://intersis.org/" }, "release_url": "https://pypi.org/project/django-rest-encrypted-lookup/0.10.1/", "requires_dist": null, "requires_python": null, "summary": "Replace Rest Framework's IntegerField pk or id lookups with encrypted strings.", "version": "0.10.1" }, "last_serial": 1721375, "releases": { "0.10.0": [ { "comment_text": "", "digests": { "md5": "5b31e66b7406c35679aa2d9d22bc1014", "sha256": "bb84788fc91e0ee954a9e50a89be808942df738f5498e45405917bc1fc4ebe15" }, "downloads": -1, "filename": "django-rest-encrypted-lookup-0.10.0.tar.gz", "has_sig": false, "md5_digest": "5b31e66b7406c35679aa2d9d22bc1014", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21037, "upload_time": "2015-09-14T05:33:19", "url": "https://files.pythonhosted.org/packages/86/11/e9fe69cab8f27521ec6abd973d63aaef9475ef3b0778a8d5597eb95ae179/django-rest-encrypted-lookup-0.10.0.tar.gz" } ], "0.10.1": [ { "comment_text": "", "digests": { "md5": "61e2faef9ffc5946c67a0979066829ef", "sha256": "2685d501874475b8c4cbe74b284a55a109056181e07a7311f2034f578e1fff38" }, "downloads": -1, "filename": "django-rest-encrypted-lookup-0.10.1.tar.gz", "has_sig": false, "md5_digest": "61e2faef9ffc5946c67a0979066829ef", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21048, "upload_time": "2015-09-14T05:53:34", "url": "https://files.pythonhosted.org/packages/3d/af/94d96e8875e3c465c26c0485847fe5c38d7095efd8c08f069db641364d4d/django-rest-encrypted-lookup-0.10.1.tar.gz" } ], "0.8": [ { "comment_text": "", "digests": { "md5": "5208c25319f5310c1ba3e4a7afb65280", "sha256": "63b85369f996762c47e1732d41b728ff8a8fc15f907920ec07efcf06d6fda443" }, "downloads": -1, "filename": "django-rest-encrypted-lookup-0.8.tar.gz", "has_sig": false, "md5_digest": "5208c25319f5310c1ba3e4a7afb65280", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19198, "upload_time": "2014-12-25T00:02:06", "url": "https://files.pythonhosted.org/packages/2a/d4/bec470e047f89c1eb6a66070979ef919161bb186cf8fe4c7c1caf5482452/django-rest-encrypted-lookup-0.8.tar.gz" } ], "0.8.1": [ { "comment_text": "", "digests": { "md5": "e0ea13056dc8461bb479635af695f749", "sha256": "8e312dccf68ac53ad538f417bc996a0d8e49c6ef9800939651c47bc187061260" }, "downloads": -1, "filename": "django-rest-encrypted-lookup-0.8.1.tar.gz", "has_sig": false, "md5_digest": "e0ea13056dc8461bb479635af695f749", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19267, "upload_time": "2014-12-25T00:52:29", "url": "https://files.pythonhosted.org/packages/37/fb/9dd5740706ef5e1df35b9b2fb0d9baa292228d002cffedfc2854d5d8fabc/django-rest-encrypted-lookup-0.8.1.tar.gz" } ], "0.8.3": [ { "comment_text": "", "digests": { "md5": "8d1aba0a9a52d5e6cc69acb4d27df0ea", "sha256": "ff6bd15c6496ef4823e8ba10194186d182c0849f5e2a9040b7b92db1b9ed2cfd" }, "downloads": -1, "filename": "django-rest-encrypted-lookup-0.8.3.tar.gz", "has_sig": false, "md5_digest": "8d1aba0a9a52d5e6cc69acb4d27df0ea", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18555, "upload_time": "2014-12-30T20:55:23", "url": "https://files.pythonhosted.org/packages/ff/da/ae3278a44a084f6d6c0849b51b4062df3f58c9c1964750320a0defc5f366/django-rest-encrypted-lookup-0.8.3.tar.gz" } ], "0.9.0": [ { "comment_text": "", "digests": { "md5": "902fca4a8abae1b05d9c11c140391ddf", "sha256": "c86dc80951ddb8c18abae8d80c07e0cfc84a3c76f566409f5c32dff9249fdd93" }, "downloads": -1, "filename": "django-rest-encrypted-lookup-0.9.0.tar.gz", "has_sig": false, "md5_digest": "902fca4a8abae1b05d9c11c140391ddf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19433, "upload_time": "2015-03-16T05:22:01", "url": "https://files.pythonhosted.org/packages/47/ec/668908278e56fb7a4dfc1c0de5581b316ab069abad921d18239c4d6411e2/django-rest-encrypted-lookup-0.9.0.tar.gz" } ], "0.9.5": [ { "comment_text": "", "digests": { "md5": "78e92a2fba7ca38547699778a0a12c12", "sha256": "dfbccac8805b7838e0ca3a952ea67b62ca3ace0bea7d478a933f14f9a9322d8f" }, "downloads": -1, "filename": "django-rest-encrypted-lookup-0.9.5.tar.gz", "has_sig": false, "md5_digest": "78e92a2fba7ca38547699778a0a12c12", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20492, "upload_time": "2015-03-18T06:36:29", "url": "https://files.pythonhosted.org/packages/05/bc/bb3e3caa78fc6f2d55bcfd019a5268c446e48553840fc9e8a27fecfec6ff/django-rest-encrypted-lookup-0.9.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "61e2faef9ffc5946c67a0979066829ef", "sha256": "2685d501874475b8c4cbe74b284a55a109056181e07a7311f2034f578e1fff38" }, "downloads": -1, "filename": "django-rest-encrypted-lookup-0.10.1.tar.gz", "has_sig": false, "md5_digest": "61e2faef9ffc5946c67a0979066829ef", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21048, "upload_time": "2015-09-14T05:53:34", "url": "https://files.pythonhosted.org/packages/3d/af/94d96e8875e3c465c26c0485847fe5c38d7095efd8c08f069db641364d4d/django-rest-encrypted-lookup-0.10.1.tar.gz" } ] }