{ "info": { "author": "Tomasz Jakub Rup", "author_email": "tomasz.rup@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Framework :: Django", "Framework :: Django :: 1.10", "Framework :: Django :: 1.11", "Framework :: Django :: 1.4", "Framework :: Django :: 1.5", "Framework :: Django :: 1.6", "Framework :: Django :: 1.7", "Framework :: Django :: 1.8", "Framework :: Django :: 1.9", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Software Development", "Topic :: Software Development :: Libraries", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Utilities" ], "description": "================\ndjango-auth-role\n================\n\n.. image:: https://codeclimate.com/github/tomi77/django-auth-role/badges/gpa.svg\n :target: https://codeclimate.com/github/tomi77/django-auth-role\n :alt: Code Climate\n.. image:: https://travis-ci.org/tomi77/django-auth-role.svg?branch=master\n :target: https://travis-ci.org/tomi77/django-auth-role\n.. image:: https://coveralls.io/repos/github/tomi77/django-auth-role/badge.svg?branch=master\n :target: https://coveralls.io/github/tomi77/django-auth-role?branch=master\n\nAdd roles to django-auth\n\nRole are set of group of permissions and permissions. It's fully customizable. Everything is in database.\n\nAdmin application allow to manage roles.\n\nInstallation\n============\n\n.. sourcecode:: sh\n\n pip install django-auth-role\n\nQuick start\n===========\n\nAdd ``authrole`` to `INSTALLED_APPS` (``django.contrib.auth`` and ``django.contrib.contenttypes`` are also required)\nand ``AuthRoleBackend`` to `AUTHENTICATION_BACKENDS`.\n\n.. sourcecode:: python\n\n INSTALLED_APPS = [\n ...\n 'django.contrib.contenttypes',\n 'django.contrib.auth',\n 'authrole',\n ]\n\n AUTHENTICATION_BACKENDS = (\n 'authrole.auth.backends.AuthRoleBackend',\n )\n\nExtend ``auth.User``.\n\n.. sourcecode:: python\n\n from authrole.mixins import RoleMixin\n from django.db import models\n\n class MyUser(RoleMixin, models.Model):\n user = models.OneToOneField('auth.User', related_name='user')\n\nor create new auth user model:\n\n.. sourcecode:: python\n\n from authrole.mixins import RoleMixin\n from django.contrib.auth.models import AbstractUser\n from django.db import models\n\n class MyUser(RoleMixin, AbstractUser):\n pass\n\nIn this case remember to set ``AUTH_USER_MODEL`` to Your model.\n\nCreate tables.\n\n.. sourcecode:: sh\n\n ./manage.py migrate\n\nAdvanced usage\n==============\n\nOwn authentication backend\n--------------------------\n\nIf You need Your own authentication backend, simply extend ``BaseAuthRoleBackend``.\n``fetch_role_permissions`` function must return a list of ``auth.Permission`` objects:\n\n.. sourcecode:: python\n\n from authrole.auth.backends import BaseAuthRoleBackend\n from django.contrib.auth.models import Permission\n\n class MyBackend(BaseAuthRoleBackend):\n def fetch_role_permissions(self, user_obj):\n if user_obj.username == 'admin':\n return Permission.objects.all()\n else:\n return Permission.objects.none()\n\nExtend role\n-----------\n\nAdd ``OneToOneField`` to Your model:\n\n.. sourcecode:: python\n\n from django.db import models\n\n class MyRole(models.Model):\n role = models.OneToOneField('authrole.Role', null=False, blank=False, related_name='myrole')\n extra_field = models.CharField(max_length=10)\n\nAnd use:\n\n.. sourcecode:: python\n\n from authrole.models import Role\n\n role = Role.objects.all()[0]\n\n print(role.myrole.extra_field)\n\nOr write Your own role class based on ``AbstractRole`` (Django >= 1.5):\n\n.. sourcecode:: python\n\n from authrole.model import AbstractRole\n\n class MyRole(AbstractRole):\n extra_field = models.CharField(max_length=10)\n\nPoint `AUTHROLE_ROLE_MODEL` to Your new model:\n\n.. sourcecode:: python\n\n AUTHROLE_ROLE_MODEL = 'app.MyRole'\n\nAnd use:\n\n.. sourcecode:: python\n\n from app.models import MyRole\n\n role = MyRole.objects.all()[0]\n\n print(role.extra_field)\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/tomi77/django-auth-role", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "django-auth-role", "package_url": "https://pypi.org/project/django-auth-role/", "platform": "", "project_url": "https://pypi.org/project/django-auth-role/", "project_urls": { "Homepage": "https://github.com/tomi77/django-auth-role" }, "release_url": "https://pypi.org/project/django-auth-role/0.4.0/", "requires_dist": null, "requires_python": "", "summary": "Add user roles to django-auth", "version": "0.4.0" }, "last_serial": 2864912, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "3cb146b5b844181b971401fb6650834e", "sha256": "b62bf5ca649cf8ad032d7d800c98689e95eb714a81c51723ce48dfc11ec4d8ab" }, "downloads": -1, "filename": "django_auth_role-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "3cb146b5b844181b971401fb6650834e", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 9229, "upload_time": "2017-05-07T16:02:56", "url": "https://files.pythonhosted.org/packages/89/97/037ca3b61572dfe7bcff11bfed4fb63d450ddae7b85ff8212c93b3650f37/django_auth_role-0.1.0-py2.py3-none-any.whl" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "8230dce5fb5e879b4d15f986a5883f74", "sha256": "5da240c0c8389d1be060723c3d9d201f763447a275b84823de4a1a8749048e17" }, "downloads": -1, "filename": "django_auth_role-0.2.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "8230dce5fb5e879b4d15f986a5883f74", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 10206, "upload_time": "2017-05-08T10:12:22", "url": "https://files.pythonhosted.org/packages/dd/dc/18ed089bcf3bcf3568fc4dd2ca983e23b38099d96c05a7514fb4d6f75827/django_auth_role-0.2.0-py2.py3-none-any.whl" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "0aee9e9318d4485409a918da0f7381be", "sha256": "fdcbfc70af7e8e3d240069aa40da1aaf9b56ade56e0de9a77b4dcfbca882d4d0" }, "downloads": -1, "filename": "django_auth_role-0.3.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "0aee9e9318d4485409a918da0f7381be", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 11795, "upload_time": "2017-05-08T14:09:23", "url": "https://files.pythonhosted.org/packages/6c/0b/2b4ab3616094bc6de6f86d894f7cc2dcf526c9785fb350e5ffe662b253de/django_auth_role-0.3.0-py2.py3-none-any.whl" } ], "0.4.0": [ { "comment_text": "", "digests": { "md5": "cb9c299d6cbd2a923eaf2c376b4853b9", "sha256": "1ba022ae540891bd987679d759bb55343f8416c277f5d59646dfef3a572661cc" }, "downloads": -1, "filename": "django_auth_role-0.4.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "cb9c299d6cbd2a923eaf2c376b4853b9", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 12529, "upload_time": "2017-05-10T16:53:19", "url": "https://files.pythonhosted.org/packages/cd/66/11677a005d2828f20a5affc8604791cf61ca980d544db370975d1ef08ec3/django_auth_role-0.4.0-py2.py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "cb9c299d6cbd2a923eaf2c376b4853b9", "sha256": "1ba022ae540891bd987679d759bb55343f8416c277f5d59646dfef3a572661cc" }, "downloads": -1, "filename": "django_auth_role-0.4.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "cb9c299d6cbd2a923eaf2c376b4853b9", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 12529, "upload_time": "2017-05-10T16:53:19", "url": "https://files.pythonhosted.org/packages/cd/66/11677a005d2828f20a5affc8604791cf61ca980d544db370975d1ef08ec3/django_auth_role-0.4.0-py2.py3-none-any.whl" } ] }