{ "info": { "author": "PythonUnited", "author_email": "info@pythonunited.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Framework :: Django", "Intended Audience :: Developers", "License :: Freely Distributable", "Programming Language :: Python", "Topic :: Internet :: WWW/HTTP :: Site Management", "Topic :: Software Development :: Libraries :: Application Frameworks" ], "description": "djinn_auth\n==========\n\nRole based auth module for Djinn. The package is also usable as\nstandalone module, since it has no relation to other djinn packages.\n\nThis module builds upon the django.contrib.auth module, and extends it\nwith role based authorisation, both global roles and local roles (or:\nroles on a specific model instance). Roles can be assigned to a user\nand a group.\n\nFor (un)assignments you can use the API specified in\ndjinn_auth.utils. This provides functions to assign roles to\nusers/groups globally and locally, and to check on global and local\nroles. Specific checks enable you to check whether a user has a role,\neither directly or through one of it's groups.\n\nNote that while this module is agnostic of the specific User model\n(since this is a swappable model), it will assume at least the\nexistence of the user_permissions relation.\n\n\nGlobal permissions\n------------------\n\nGlobal permissions provide a means of granting permissions to a user\nor group globally. This means that a check on a local permission on a\ngiven model instance, will also return the global permissions.\n\nYou can give a user a permission by:\n\n 1. give the user a permission through the User.user_permissions attribute\n 2. give the user a role that has this permission\n 3. add the user to a group that has a role that has this permission\n 4. add the user to a group that has the permission\n\n\nLocal permissions\n-----------------\n\nYou can enable permissions for a given user or group on a specific\nmodel instance by:\n\n 1. giving the user a local role on the object with that permission\n 2. giving a group the user is part of a local role with that permission\n 3. giving the permission to the user on the object\n 4. giving the permission to a group the user is part of on the object\n\nTo prevent acquisition of the global permissions on an instance,\nimplement the `acquire_global_roles` property and return False. This\nenables the scenario where users have a global 'allow', but some local\n'forbiddens'. Please note that this only disallows global _roles_, not\ndirect permissions on the user or it's groups itself.\n\nIf you need to add some sort of hierarchy, you may do so using the\n`acquire_from` attribute on your instance, that must return a list of\ninstances it wishes to obtain roles/permissions from.\n\n\nInstallation\n------------\n\nInstall the usual way using _pip_ or _easy\\_install_. Add djinn\\_auth\nto your INSTALLED\\_APPS. Add the djinn\\_auth backend to the\nAUTHENTICATION\\_BACKENDS setting:\n\n AUTHENTICATION_BACKENDS = (\n 'django.contrib.auth.backends.ModelBackend',\n 'djinn_auth.authbackend.AuthBackend'\n )\n\n\nUsage\n-----\n\nBasic use of the djinn\\_auth module is not different from using the\nbuiltin Django authorisation. You can use the same decorators or\ncalls, since djinn\\_auth adds it's own backend to the autorisation\nchain. Following, are some simpe cases. Check the utils.py file for\nthe full API. Yes, you will need to read Python code..!\n\nCreate a role and add permissions:\n\n from djinn_auth.models import Role\n from django.contrib.auth.models import Permission\n\n owner_role = Role.objects.create(name=\"owner\")\n\n do_something = Permission.objects.get(codename=\"myapp.do_something\")\n\n owner_role.add_permission(do_something)\n\n\nTo assign a global role for a user or group (assuming you have a user\n_bobdobalina_):\n\n >> from djinn_auth.utils import assign_global_role, has_global_role\n >> assign_global_role(bobdobalina, owner_role)\n >> has_global_role(bobdobalina, owner_role)\n True\n >>\n\nThis should give us the permission granted to the role (please note that\nthe backend is normally called by the Django auth machinery using the\n_User.has_perm_ call:\n\n >> from djinn_auth.authbackend import AuthBackend\n >> backend = AuthBackend()\n >> backend.has_perm(bobdobalina, \"myapp.do_something\")\n True\n\nRevoke it:\n\n >> from djinn_auth.utils import unassign_global_role\n >> unassign_global_role(bobdobalina, owner_role)\n >> has_global_role(bobdobalina, owner_role)\n False\n >> backend.has_perm(bobdobalina, \"myapp.do_something\")\n False\n\nAssign a local role:\n\n >> from djinn_auth.utils import assign_local_role, has_local_role\n >> instance = MyContentType.objects.get(pk=666)\n >> assign_local_role(bobdobalina, instance, owner_role)\n >> has_local_role(bobdobaline, instance, owner_role)\n True\n >> backend.has_perm(bobdobalina, \"myapp.do_something\")\n False\n >> backend.has_perm(bobdobalina, \"myapp.do_something\", obj=instance)\n True\n\n\nViews\n-----\n\nTo protect class based views, djinn\\_auth provides a mixin class that\nadds a permission check: djinn_auth.views.base.PermissionProtectedMixin.\n\nUse like so:\n\n from django.views.generic.base import View\n from djinn_auth.views.base import PermissionProtectedMixin\n\n class MyView(PermissionProtectedMixin, View):\n\n permission = \"myapp.view\"\n\nor even:\n\n class MyView(PermissionProtectedMixin, View):\n\n permission = {'GET': 'myapp.view', 'POST': 'myapp.edit'}\n\n\n1.0.7\n=====\n* import fixes. Some libraries were updated\n\n1.0.6\n=====\n* django 1.8+ and backward compatibility\n\n1.0.5\n=====\n* convenience on get_local_roles\n* admin enhancement\n\n1.0.4\n=====\n* Added group base implementation\n* Made auth backend 'acquisition' enabled\n\n1.0.3\n=====\n* Some more support for roles as string repr in utils methods\n\n1.0.2\n=====\n* Added admin.py for management ui\n* Made has_*_role functions in utils accept role names as well as objects\n* fix for swapped user model\n* Added protected view mixin\n\n1.0.1\n=====\n* Added unit test for global roles\n* More to README\n* Fixed repr issue in LocalRole\n\n1.0.0\n=====\nInitial version", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/PythonUnited/djinn_auth", "keywords": "Djinn role base auth", "license": "beer-ware", "maintainer": null, "maintainer_email": null, "name": "djinn_auth", "package_url": "https://pypi.org/project/djinn_auth/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/djinn_auth/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/PythonUnited/djinn_auth" }, "release_url": "https://pypi.org/project/djinn_auth/1.0.7/", "requires_dist": null, "requires_python": null, "summary": "Djinn Intranet auth module, role based", "version": "1.0.7" }, "last_serial": 2204197, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "52a8eb8145a6525a34b9b68145b72f3c", "sha256": "4f3b8e50b6746e34cd5a8ff45190c810f6fa05053a72a48db9f5f89d0568f261" }, "downloads": -1, "filename": "djinn_auth-1.0.0.tar.gz", "has_sig": false, "md5_digest": "52a8eb8145a6525a34b9b68145b72f3c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8041, "upload_time": "2014-10-03T15:07:11", "url": "https://files.pythonhosted.org/packages/dd/4f/4c11b6a6c326760e7855b86a3ac1f7369ec30ca9e9488b0b30cd9f243fff/djinn_auth-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "c297d2f0f9a599a7cce47439d21ee9a7", "sha256": "4c593dbfb7b9e67d5402fc23253cb3a78e91956187042df377bf029e0e1850ac" }, "downloads": -1, "filename": "djinn_auth-1.0.1.tar.gz", "has_sig": false, "md5_digest": "c297d2f0f9a599a7cce47439d21ee9a7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8629, "upload_time": "2014-11-07T14:30:54", "url": "https://files.pythonhosted.org/packages/7c/3f/8bfe553999e334bb48b8e77a76863e934ff87279d0569f96e4ab01c43501/djinn_auth-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "e2a3bce1764fb052d545a1dcb62a6a59", "sha256": "5205461ef7696397ae347d0351381823a538897b7ff3f09efb2b92184f153ea1" }, "downloads": -1, "filename": "djinn_auth-1.0.2.tar.gz", "has_sig": false, "md5_digest": "e2a3bce1764fb052d545a1dcb62a6a59", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9972, "upload_time": "2014-11-15T11:55:11", "url": "https://files.pythonhosted.org/packages/d9/53/e6acb87e15a7b60f31c779f69bba47d678bc97b66510cd289a95db9256a9/djinn_auth-1.0.2.tar.gz" } ], "1.0.3": [ { "comment_text": "", "digests": { "md5": "6cb051af97cfa75e501301fff55b64d6", "sha256": "9132b9124fe8987da67b703bf2f2d2a3d6adf8b5b4bfc2907724cc1b5703823d" }, "downloads": -1, "filename": "djinn_auth-1.0.3.tar.gz", "has_sig": false, "md5_digest": "6cb051af97cfa75e501301fff55b64d6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 23423, "upload_time": "2014-12-02T09:37:03", "url": "https://files.pythonhosted.org/packages/b5/0a/487dce2f328a6cc10cc5205db50d8b80ec618e26d850c312d91a2804856a/djinn_auth-1.0.3.tar.gz" } ], "1.0.4": [ { "comment_text": "", "digests": { "md5": "97d33985efbd753be7192a3b2347b5b2", "sha256": "2c8b7ef89ab32bbcff4ff4f8eb57c0e4f597dc630aa87a5b02f866999ce58ff6" }, "downloads": -1, "filename": "djinn_auth-1.0.4.tar.gz", "has_sig": false, "md5_digest": "97d33985efbd753be7192a3b2347b5b2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 24725, "upload_time": "2014-12-08T12:53:12", "url": "https://files.pythonhosted.org/packages/bd/f9/718800f2950ec7e0888b251ffadc0d9dd4348e5f70516e55b55d294106c3/djinn_auth-1.0.4.tar.gz" } ], "1.0.5": [ { "comment_text": "", "digests": { "md5": "becddb3d348cde20ee4c710f5da50c74", "sha256": "46d9a031ba8b486bfac7d3cce5a2af233a6daebe852e6b991c5c0ee8e9e4bb58" }, "downloads": -1, "filename": "djinn_auth-1.0.5.tar.gz", "has_sig": false, "md5_digest": "becddb3d348cde20ee4c710f5da50c74", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 24942, "upload_time": "2015-02-10T15:45:21", "url": "https://files.pythonhosted.org/packages/95/82/6e924db63e870a87955977481c1e265fd270a7764a4fb004cc6e5212506d/djinn_auth-1.0.5.tar.gz" } ], "1.0.6": [ { "comment_text": "", "digests": { "md5": "cee4377c5260f36bfc98da7308a9eab5", "sha256": "3c5cc5dee09c7ea29788a4ff771ef821135d6c4be075d6dbb06e8dd1c89c1b19" }, "downloads": -1, "filename": "djinn_auth-1.0.6.tar.gz", "has_sig": false, "md5_digest": "cee4377c5260f36bfc98da7308a9eab5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18029, "upload_time": "2015-09-29T08:22:08", "url": "https://files.pythonhosted.org/packages/c0/cc/92af1a8304e059923d3ed5c0c1ba512ddaf66cab202a9534345449bf53ec/djinn_auth-1.0.6.tar.gz" } ], "1.0.7": [ { "comment_text": "", "digests": { "md5": "230b085c9ddf278cdfed2a4984d33dd8", "sha256": "41efaff0d7bca16bef662145ef447cec153bcad7047054e9339d6539d97f47f5" }, "downloads": -1, "filename": "djinn_auth-1.0.7.tar.gz", "has_sig": false, "md5_digest": "230b085c9ddf278cdfed2a4984d33dd8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18101, "upload_time": "2016-07-05T19:14:50", "url": "https://files.pythonhosted.org/packages/3a/55/9e0fe8657d273bad5f26a6141d0ea4051da5e848bd9697fe1f9a40435024/djinn_auth-1.0.7.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "230b085c9ddf278cdfed2a4984d33dd8", "sha256": "41efaff0d7bca16bef662145ef447cec153bcad7047054e9339d6539d97f47f5" }, "downloads": -1, "filename": "djinn_auth-1.0.7.tar.gz", "has_sig": false, "md5_digest": "230b085c9ddf278cdfed2a4984d33dd8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18101, "upload_time": "2016-07-05T19:14:50", "url": "https://files.pythonhosted.org/packages/3a/55/9e0fe8657d273bad5f26a6141d0ea4051da5e848bd9697fe1f9a40435024/djinn_auth-1.0.7.tar.gz" } ] }