{
"info": {
"author": "Pi Delport",
"author_email": "pjdelport@gmail.com",
"bugtrack_url": null,
"classifiers": [
"Development Status :: 3 - Alpha",
"Environment :: Web Environment",
"Framework :: Django",
"Intended Audience :: Developers",
"License :: Public Domain",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 3",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Security",
"Topic :: Software Development :: Libraries",
"Topic :: Utilities"
],
"description": "=================\ndjango-auth-utils\n=================\n\nDjango authentication and authorization utilities.\n\n.. image:: https://img.shields.io/pypi/v/django-auth-utils.svg\n :target: https://pypi.python.org/pypi/django-auth-utils\n\n.. image:: https://img.shields.io/badge/source-GitHub-lightgrey.svg\n :target: https://github.com/pjdelport/django-auth-utils\n\n.. image:: https://img.shields.io/github/issues/pjdelport/django-auth-utils.svg\n :target: https://github.com/pjdelport/django-auth-utils/issues?q=is:open\n\n.. image:: https://travis-ci.org/pjdelport/django-auth-utils.svg?branch=master\n :target: https://travis-ci.org/pjdelport/django-auth-utils\n\n.. image:: https://codecov.io/github/pjdelport/django-auth-utils/coverage.svg?branch=master\n :target: https://codecov.io/github/pjdelport/django-auth-utils?branch=master\n\n.. contents::\n\nInstallation\n============\n\n.. code:: shell\n\n pip install django-auth-utils\n\nSupported and tested on:\n\n* Python: 2.7, 3.4, 3.5, 3.6, PyPy, PyPy3\n* Django: 1.8, 1.10, 1.11\n\n\nConfiguration\n=============\n\nIn order to use the ``auth_utils`` template tag library, add ``auth_utils`` to your ``INSTALLED_APPS``.\n\nAlternatively, since Django 1.9, you can add ``auth_utils.templatetags.auth_utils`` to your\nDjangoTemplates_ OPTIONS.\n\n\n.. _DjangoTemplates:\n https://docs.djangoproject.com/en/1.9/topics/templates/#django.template.backends.django.DjangoTemplates\n\n\nUsage\n=====\n\n\nPermission-checking views\n-------------------------\n\nThe ``ObjectPermissionRequiredMixin`` view combines Django's PermissionRequiredMixin_ and\nSingleObjectMixin_ views, and performs the permission check against the object that was looked up.\n\n.. _PermissionRequiredMixin:\n https://docs.djangoproject.com/en/1.9/topics/auth/default/#the-permissionrequiredmixin-mixin\n\n.. _SingleObjectMixin:\n https://docs.djangoproject.com/en/1.9/ref/class-based-views/mixins-single-object/#singleobjectmixin\n\nUse it like the base classes:\n\n.. code:: python\n\n from auth_utils.views import ObjectPermissionRequiredMixin\n\n\n class ArticleDetail(ObjectPermissionRequiredMixin, generic.DetailView):\n model = Article\n permission_required = ['news.read_article']\n\n\n class ArticleUpdate(ObjectPermissionRequiredMixin, generic.UpdateView):\n model = Article\n permission_required = ['news.change_article']\n\n\nPermission-checking in templates\n--------------------------------\n\nLoad the template tag library:\n\n.. code:: django\n\n {% load auth_utils %}\n\nThe ``perms`` filter allows checking object-level permissions with a convenient syntax:\n\n.. code:: django\n\n {% if perm in user|perms:object %} ... {% endif %}\n\nThe ``object`` argument is optional. If omitted, the global permission is checked,\nsimilar to Django's `perms object`_.\n\n.. _perms object:\n https://docs.djangoproject.com/en/1.9/topics/auth/default/#permissions\n\nExamples:\n\n.. code:: html+django\n\n\n {% if 'news.read_article' in user|perms:article %}\n {{ article.text }}\n {% else %}\n You do not have permission to read this article.\n {% endif %}\n\n\n {% if 'news.change_article' in user|perms:article %}\n Edit article\n {% endif %}\n\n {% if 'news.delete_article' in user|perms:article %}\n Delete article\n {% endif %}\n\nThe library provides ``can_change`` and ``can_delete`` shorthands for checking Django's default\n``app.change_model`` and ``app.delete_model`` model permissions:\n\n.. code:: html+django\n\n {% if user|can_change:article %} Edit {% endif %}\n {% if user|can_delete:article %} Delete {% endif %}\n\n\n``BaseAuthorizationBackend``\n----------------------------\n\nThis base class provides all the boilerplate code necessary for a Django `authentication backend`_\nto work, without performing any user authentication or permission authorization itself.\n\nThis is intended to make it easy to write `custom authorization`_ policies that only implement the backend\nmethods they're interested in:\n\n.. _authentication backend:\n https://docs.djangoproject.com/en/1.9/topics/auth/customizing/#writing-an-authentication-backend\n\n.. _custom authorization:\n https://docs.djangoproject.com/en/1.9/topics/auth/customizing/#handling-authorization-in-custom-backends\n\n.. code:: python\n\n from auth_utils.backends import BaseAuthorizationBackend\n\n\n class ArticleEditPolicy(BaseAuthorizationBackend):\n \"\"\"\n Allow authors to change and delete their own articles.\n \"\"\"\n\n def get_user_permissions(self, user_obj, obj=None):\n is_author = isinstance(obj, Article) and article.author == user_obj\n if user_obj.is_active and is_author:\n return {'news.change_article', 'news.delete_article'}\n else:\n return set()\n\n\n class GuestAccessPolicy(BaseAuthorizationBackend):\n \"\"\"\n Allow anonymous users to read non-premium articles.\n \"\"\"\n\n def get_user_permissions(self, user_obj, obj=None):\n guest_readable = isinstance(obj, Article) and not article.is_premium\n if not user_obj.is_authenticated() and guest_readable:\n return {'news.read_article'}\n else:\n return set()\n\nOnce defined, these policies can be enabled in AUTHENTICATION_BACKENDS_:\n\n.. code:: python\n\n AUTHENTICATION_BACKENDS = [\n 'django.contrib.auth.backends.ModelBackend',\n\n # Custom authorization policies\n 'news.auth.ArticleEditPolicy',\n 'news.auth.GuestAccessPolicy',\n ]\n\n.. _AUTHENTICATION_BACKENDS:\n https://docs.djangoproject.com/en/1.9/ref/settings/#std:setting-AUTHENTICATION_BACKENDS\n\n\nRelated work\n============\n\nInspiration: `django-model-utils`_\n\n`django-guardian`_ provides object-based permission checking utilities:\n\n* View: An `alternative PermissionRequiredMixin`_, predating Django's one\n* Template tag: `get_obj_perms`_, using somewhat clunkier assignment syntax\n\n\n.. _django-model-utils: https://django-model-utils.readthedocs.org/\n\n.. _django-guardian: http://django-guardian.readthedocs.org/\n.. _alternative PermissionRequiredMixin:\n http://django-guardian.readthedocs.org/en/stable/api/guardian.mixins.html#permissionrequiredmixin\n.. _get_obj_perms:\n http://django-guardian.readthedocs.org/en/stable/api/guardian.templatetags.guardian_tags.html#get-obj-perms",
"description_content_type": null,
"docs_url": null,
"download_url": "",
"downloads": {
"last_day": -1,
"last_month": -1,
"last_week": -1
},
"home_page": "https://github.com/pjdelport/django-auth-utils",
"keywords": "",
"license": "Public Domain",
"maintainer": "",
"maintainer_email": "",
"name": "django-auth-utils",
"package_url": "https://pypi.org/project/django-auth-utils/",
"platform": "",
"project_url": "https://pypi.org/project/django-auth-utils/",
"project_urls": {
"Homepage": "https://github.com/pjdelport/django-auth-utils"
},
"release_url": "https://pypi.org/project/django-auth-utils/0.1.1/",
"requires_dist": null,
"requires_python": "",
"summary": "Django authentication and authorization utilities",
"version": "0.1.1"
},
"last_serial": 3247562,
"releases": {
"0.1": [
{
"comment_text": "",
"digests": {
"md5": "38a7cf71ca47e84cc8e5da5ddb3a45e5",
"sha256": "42aff2b3f78cb672da77189f57530fed65113cdd921f194ba5a45207f9bf32d6"
},
"downloads": -1,
"filename": "django_auth_utils-0.1-py2-none-any.whl",
"has_sig": false,
"md5_digest": "38a7cf71ca47e84cc8e5da5ddb3a45e5",
"packagetype": "bdist_wheel",
"python_version": "py2",
"requires_python": null,
"size": 5657,
"upload_time": "2016-03-04T14:33:10",
"url": "https://files.pythonhosted.org/packages/f6/b1/3fae9a4dd984d3dc44378d01f94ee3208fbbaa30ecda0484a1d995d6c2fc/django_auth_utils-0.1-py2-none-any.whl"
},
{
"comment_text": "",
"digests": {
"md5": "42fef9595b795e97f0973f0b43118fc3",
"sha256": "6c9531c0f4364a808ca559b45ab71a152d5fe81be0b9f6482d69fd93143c9c88"
},
"downloads": -1,
"filename": "django_auth_utils-0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "42fef9595b795e97f0973f0b43118fc3",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 5658,
"upload_time": "2016-03-04T14:33:21",
"url": "https://files.pythonhosted.org/packages/3e/a2/4bb87db1ab0c600c62c2ef97ff4a5d7988ddb8c9e3dde366e03b05adf1ac/django_auth_utils-0.1-py3-none-any.whl"
},
{
"comment_text": "",
"digests": {
"md5": "aae05da74cdf70ad98474567ff0b96aa",
"sha256": "c9fd42554f41f69053c072635e56e0c10a2ef4648d1a4c3827bc2fcaa53dee2a"
},
"downloads": -1,
"filename": "django-auth-utils-0.1.tar.gz",
"has_sig": false,
"md5_digest": "aae05da74cdf70ad98474567ff0b96aa",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 9948,
"upload_time": "2016-03-04T14:32:19",
"url": "https://files.pythonhosted.org/packages/dc/21/48fc01cce3bbc50811fbbc890292228b17757fd2b747fc4bc9b6aaf6fd2a/django-auth-utils-0.1.tar.gz"
}
],
"0.1.1": [
{
"comment_text": "",
"digests": {
"md5": "eacfe7ea870ef027851f9d2d693de794",
"sha256": "0064eea83a530da6d89adbc84b4e357c82eef6086ce620028e977918d530dcf7"
},
"downloads": -1,
"filename": "django_auth_utils-0.1.1-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "eacfe7ea870ef027851f9d2d693de794",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 9607,
"upload_time": "2017-10-13T11:23:59",
"url": "https://files.pythonhosted.org/packages/c9/ce/830e1f303440c4d17987462591758d60a75d685f9e8a40d3ac053154781f/django_auth_utils-0.1.1-py2.py3-none-any.whl"
},
{
"comment_text": "",
"digests": {
"md5": "6a6539f83f9cf8f8509777ada88fa382",
"sha256": "735cee46eef1ad82e43394d405f4fe678e2af9123cd7f270ce07d0615330e51a"
},
"downloads": -1,
"filename": "django-auth-utils-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "6a6539f83f9cf8f8509777ada88fa382",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 12464,
"upload_time": "2017-10-13T11:23:48",
"url": "https://files.pythonhosted.org/packages/3c/ac/ff3c6ed433ea5d8b85f686c09ece258020d022a84b069c08cdefd43b9434/django-auth-utils-0.1.1.tar.gz"
}
],
"0.1rc1": [
{
"comment_text": "",
"digests": {
"md5": "b845a99dd41e09d6351f7b9f740c3c0e",
"sha256": "026dfb11d9c32c74e0d044130421eaf05914d1bf7cb07e3f9c757a2d9ee20f91"
},
"downloads": -1,
"filename": "django_auth_utils-0.1rc1-py2-none-any.whl",
"has_sig": false,
"md5_digest": "b845a99dd41e09d6351f7b9f740c3c0e",
"packagetype": "bdist_wheel",
"python_version": "py2",
"requires_python": null,
"size": 5700,
"upload_time": "2016-02-03T01:04:54",
"url": "https://files.pythonhosted.org/packages/bb/6d/7782296ed8e0a2f39e72320d918e3ef26adabb3935a6bf1fa042ae668da8/django_auth_utils-0.1rc1-py2-none-any.whl"
},
{
"comment_text": "",
"digests": {
"md5": "b27dffea5faa32546f55ce6b5eef7e30",
"sha256": "720aee9a64c365b932eb5158cd4cf1cfd957d917b281f980d0b1505b416d1d1d"
},
"downloads": -1,
"filename": "django_auth_utils-0.1rc1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b27dffea5faa32546f55ce6b5eef7e30",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 5700,
"upload_time": "2016-02-03T01:05:01",
"url": "https://files.pythonhosted.org/packages/59/95/656836572148641c84e95dc090eb911ea7c72882215f44b795db14a5468a/django_auth_utils-0.1rc1-py3-none-any.whl"
},
{
"comment_text": "",
"digests": {
"md5": "5f0d32cf663a137000647eca7a58fbbe",
"sha256": "45b9646b3e717674f4fce5c282cdb3737c30141451d33b39afbcbe8858188ced"
},
"downloads": -1,
"filename": "django-auth-utils-0.1rc1.tar.gz",
"has_sig": false,
"md5_digest": "5f0d32cf663a137000647eca7a58fbbe",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 8842,
"upload_time": "2016-02-03T01:05:06",
"url": "https://files.pythonhosted.org/packages/a8/47/7b2a8bee706b9b405b6f6b34299eb555b20d1749c9ee33e0b7444d9a1c2d/django-auth-utils-0.1rc1.tar.gz"
}
]
},
"urls": [
{
"comment_text": "",
"digests": {
"md5": "eacfe7ea870ef027851f9d2d693de794",
"sha256": "0064eea83a530da6d89adbc84b4e357c82eef6086ce620028e977918d530dcf7"
},
"downloads": -1,
"filename": "django_auth_utils-0.1.1-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "eacfe7ea870ef027851f9d2d693de794",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 9607,
"upload_time": "2017-10-13T11:23:59",
"url": "https://files.pythonhosted.org/packages/c9/ce/830e1f303440c4d17987462591758d60a75d685f9e8a40d3ac053154781f/django_auth_utils-0.1.1-py2.py3-none-any.whl"
},
{
"comment_text": "",
"digests": {
"md5": "6a6539f83f9cf8f8509777ada88fa382",
"sha256": "735cee46eef1ad82e43394d405f4fe678e2af9123cd7f270ce07d0615330e51a"
},
"downloads": -1,
"filename": "django-auth-utils-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "6a6539f83f9cf8f8509777ada88fa382",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 12464,
"upload_time": "2017-10-13T11:23:48",
"url": "https://files.pythonhosted.org/packages/3c/ac/ff3c6ed433ea5d8b85f686c09ece258020d022a84b069c08cdefd43b9434/django-auth-utils-0.1.1.tar.gz"
}
]
}