{ "info": { "author": "Robert C Jensen", "author_email": "rob@computerlab.io", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Topic :: Internet :: WWW/HTTP", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "django-rest-framework-roles\n===========================\n\nSimplifies `Role Based Access Control`_ in `django-rest-framework`_.\n\nWhy would I use this?\n---------------------\n\nYou have more than one type of user in your data model and you have\nbusiness logic that diverges depending on the type of user. You do not\nwant to organize your API by role because that is not very RESTful. You\ndo not want to manually type out a lot of conditional branching around\nuser roles.\n\nModeling Requirements\n---------------------\n\n- You must have one **Group** for each role\n- A **User** cannot belong to more than one of the **Groups**\n corresponding to each role\n\nInstallation\n------------\n\n.. code:: bash\n\n $ pip install django-rest-framework-roles\n\nConfiguration\n-------------\n\n- ``VIEWSET_METHOD_REGISTRY`` A tuple of DRF methods to override.\n Defaults to:\n\n.. code:: python\n\n (\n \"get_queryset\",\n \"get_serializer_class\",\n \"perform_create\",\n \"perform_update\",\n \"perform_destroy\",\n )\n\n- ``ROLE_GROUPS`` A tuple of Group names that correspond 1-to-1 with\n user roles. Defaults to:\n\n.. code:: python\n\n [group.name.lower() for group in Group.objects.all()]\n\nIt's recommended to define ``ROLE_GROUPS`` in ``settings`` to avoid\na database lookup on every request.\n\nUsage\n-----\n\nAdd the mixin to any ViewSet:\n\n.. code:: python\n\n from drf_roles.mixins import RoleViewSetMixin\n\n class MyViewSet(RoleViewSetMixin, ModelViewSet):\n # ...\n\nFor each of the methods specified in ``VIEWSET_METHOD_REGISTRY`` a\nrole-scoped method will be generated on your ViewSet.\n\nParameterizing\n~~~~~~~~~~~~~~\n\nFor example, let\u2019s say you have three groups named *Takers*, *Leavers* &\n*Gods*. Let\u2019s also say you included ``\"get_queryset\"`` in the\n``VIEWSET_METHOD_REGISTRY``.\n\nWhen a *Taker* user hits an endpont on the ViewSet, the call to\n``get_queryset`` will be rerouted to a call to\n``get_queryset_for_takers``.\n\nWhen a *Leaver* user hits an endpont on the ViewSet, the call to\n``get_queryset`` will be rerouted to a call to\n``get_queryset_for_leavers``.\n\nWhen a *God* user hits an endpont on the ViewSet, the call to\n``get_queryset`` will be rerouted to a call to\n``get_queryset_for_gods``.\n\nYou can implement each of these methods on your ViewSet to return a\ndifferent queryset for each type of user.\n\nNot Parameterizing\n~~~~~~~~~~~~~~~~~~\n\nYou can also *not* implement one or more of these methods, in which case\nthe default call will be executed. For example, with our same set of\ngroups and with ``\"get_serializer_class\"`` included in the role\nregistry, let\u2019s say you did not implement\n``get_serializer_class_for_takers``. When a *Taker* user hits an\nendpoint on the ViewSet, the default implementation of\n``get_serializer_class`` will be executed and return\n``serializer_class``.\n\nIn this case, you would want to be sure that you have a\n``serializer_class`` defined on your ViewSet! Otherwise Django REST\nFramework will complain. It is a good idea to always define a default\n``queryset`` and ``serializer_class`` with least privilege (e.g:\nModel.objects.none()).\n\nRoadmap\n-------\n\n- Some projects require even further parameterization. For example, you may need\n to use a different `serializer_class` depending on the user's *role* **and**\n the *request method*.\n- There may be a more pleasant way to express the parameterization in code. For\n example, it may be more pleasing to use nested classes instead of renaming the\n methods.\n\nFurther Reading\n---------------\n\n- `Role-Based Access Control with Django Rest Framework`_\n- `Computer Lab`_\n\n.. _Role Based Access Control: https://en.wikipedia.org/wiki/Role-based_access_control\n.. _django-rest-framework: http://www.django-rest-framework.org/\n.. _Role-Based Access Control with Django Rest Framework: http://computerlab.io/2016/08/17/django-rest-framework-roles/\n.. _Computer Lab: http://computerlab.io\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://computerlab.io/", "keywords": "", "license": "BSD License", "maintainer": "", "maintainer_email": "", "name": "django-rest-framework-roles", "package_url": "https://pypi.org/project/django-rest-framework-roles/", "platform": "", "project_url": "https://pypi.org/project/django-rest-framework-roles/", "project_urls": { "Homepage": "http://computerlab.io/" }, "release_url": "https://pypi.org/project/django-rest-framework-roles/0.6/", "requires_dist": null, "requires_python": "", "summary": "Parameterizes Django REST Framework methods over user-defined roles", "version": "0.6" }, "last_serial": 5116628, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "a2008c359119a8b8afb5f176b566129b", "sha256": "4b614ff35be3c138a2adcb8b656db2a3c1dee8e0a39d0ecf039ff952a15c88a8" }, "downloads": -1, "filename": "django-rest-framework-roles-0.1.tar.gz", "has_sig": false, "md5_digest": "a2008c359119a8b8afb5f176b566129b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4500, "upload_time": "2016-08-17T01:15:28", "url": "https://files.pythonhosted.org/packages/f5/6e/8d1198d066ca653a12e45ab10f75887d58380809f444e1d3e47ac1b63abd/django-rest-framework-roles-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "477e7bc86e19f839baa3b9e5dd1d864f", "sha256": "19545242754343e844e7b64a53edbf86deb0635ec533dc0af0db6fdf38070f3b" }, "downloads": -1, "filename": "django-rest-framework-roles-0.2.tar.gz", "has_sig": false, "md5_digest": "477e7bc86e19f839baa3b9e5dd1d864f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4495, "upload_time": "2016-08-17T01:20:29", "url": "https://files.pythonhosted.org/packages/24/78/a42982d6e8d18f4b7ecaf3bac34105d2f2f79007219b8100fbdece61d6ea/django-rest-framework-roles-0.2.tar.gz" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "b79a38d545a9dfb18cd5c34485a01703", "sha256": "b15694c8ac397db600395972f4194472755ceb22349e95e0491ddd6749875bc3" }, "downloads": -1, "filename": "django-rest-framework-roles-0.3.tar.gz", "has_sig": false, "md5_digest": "b79a38d545a9dfb18cd5c34485a01703", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4490, "upload_time": "2016-08-17T01:23:03", "url": "https://files.pythonhosted.org/packages/f8/02/f7cda8810c0fe64a82c8c55bc00027b1cb7e6ce9ff4bdcbf2ee9c6f47109/django-rest-framework-roles-0.3.tar.gz" } ], "0.4": [ { "comment_text": "", "digests": { "md5": "a21e661c38365c09592f4473fe739bb0", "sha256": "0df0e28040b88dcb25693d96d67e99756a15bf2257212fcdfc9f5680f46e09cd" }, "downloads": -1, "filename": "django-rest-framework-roles-0.4.tar.gz", "has_sig": false, "md5_digest": "a21e661c38365c09592f4473fe739bb0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4496, "upload_time": "2016-08-17T17:08:09", "url": "https://files.pythonhosted.org/packages/f1/86/41e9ec746f76acabccfd8f5f921cf1e608b5dccdef5c353e68f69bdf614e/django-rest-framework-roles-0.4.tar.gz" } ], "0.5": [ { "comment_text": "", "digests": { "md5": "cb3c03ae4ccce3c7685c8c68c6f9f7f6", "sha256": "76a0b912684dbf4b9cf1cc5087c9ec02ff90059c4597d8693af86fe119c2ed13" }, "downloads": -1, "filename": "django-rest-framework-roles-0.5.tar.gz", "has_sig": false, "md5_digest": "cb3c03ae4ccce3c7685c8c68c6f9f7f6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4633, "upload_time": "2016-08-24T02:03:57", "url": "https://files.pythonhosted.org/packages/2d/01/756697f5986fb7039b841edd74aa024fe71d4706e89155ccba8bfcd31f9a/django-rest-framework-roles-0.5.tar.gz" } ], "0.6": [ { "comment_text": "", "digests": { "md5": "180ec5dc9d16b597855b8087ebf565cd", "sha256": "097c0f82545b1c38e05e179dea613cf7f08e5159932a4abdcd65302f17bfcbdc" }, "downloads": -1, "filename": "django_rest_framework_roles-0.6-py3-none-any.whl", "has_sig": false, "md5_digest": "180ec5dc9d16b597855b8087ebf565cd", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5100, "upload_time": "2019-04-09T03:32:29", "url": "https://files.pythonhosted.org/packages/0d/e2/bffa37c90110c6336dcc77e6de3d54df41ce840dc85a571d825e2e51b8dc/django_rest_framework_roles-0.6-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "41ba2a4283f2dab9a7dae5ad8c518067", "sha256": "243f4aff1dacb52c1011e21310d9bc25008cdd764e9e9fb1a947c8c2467e0001" }, "downloads": -1, "filename": "django-rest-framework-roles-0.6.tar.gz", "has_sig": false, "md5_digest": "41ba2a4283f2dab9a7dae5ad8c518067", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4665, "upload_time": "2019-04-09T03:32:31", "url": "https://files.pythonhosted.org/packages/9f/4e/6283bf34fc2e975ea30831c84f5898fb5362efafca1f83d2e64fcd685808/django-rest-framework-roles-0.6.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "180ec5dc9d16b597855b8087ebf565cd", "sha256": "097c0f82545b1c38e05e179dea613cf7f08e5159932a4abdcd65302f17bfcbdc" }, "downloads": -1, "filename": "django_rest_framework_roles-0.6-py3-none-any.whl", "has_sig": false, "md5_digest": "180ec5dc9d16b597855b8087ebf565cd", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5100, "upload_time": "2019-04-09T03:32:29", "url": "https://files.pythonhosted.org/packages/0d/e2/bffa37c90110c6336dcc77e6de3d54df41ce840dc85a571d825e2e51b8dc/django_rest_framework_roles-0.6-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "41ba2a4283f2dab9a7dae5ad8c518067", "sha256": "243f4aff1dacb52c1011e21310d9bc25008cdd764e9e9fb1a947c8c2467e0001" }, "downloads": -1, "filename": "django-rest-framework-roles-0.6.tar.gz", "has_sig": false, "md5_digest": "41ba2a4283f2dab9a7dae5ad8c518067", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4665, "upload_time": "2019-04-09T03:32:31", "url": "https://files.pythonhosted.org/packages/9f/4e/6283bf34fc2e975ea30831c84f5898fb5362efafca1f83d2e64fcd685808/django-rest-framework-roles-0.6.tar.gz" } ] }