django-permafrost


Namedjango-permafrost JSON
Version 0.2.14 PyPI version JSON
download
home_pagehttps://github.com/renderbox/django-permafrost/
SummaryAdds Client Definable Permissions to Django
upload_time2021-04-12 17:15:19
maintainer
docs_urlNone
authorGrant Viklund
requires_python>=3.6
licenseMIT license
keywords django app
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            

.. image:: https://github.com/renderbox/django-permafrost/workflows/Permafrost%20Develop/badge.svg
   :target: https://github.com/renderbox/django-permafrost/workflows/Permafrost%20Develop/badge.svg
   :alt: Permafrost Develop



.. image:: https://github.com/renderbox/django-permafrost/workflows/Permafrost%20CI/badge.svg
   :target: https://github.com/renderbox/django-permafrost/workflows/Permafrost%20CI/badge.svg
   :alt: Permafrost CI



.. image:: https://readthedocs.org/projects/django-permafrost/badge/?version=latest
   :target: https://django-permafrost.readthedocs.io/en/latest/?badge=latest
   :alt: Documentation Status


Django Permafrost
=================

Django Permafrost is an extension to Django's Permissions framework.  It's goal is to allow developers to expose some permissions to Client Users on the site so they can create and manage custom User Roles.

It adds:


* A View Mixin that supports user permissions based on different HTTP method types (GET, POST, PUT, etc) for extra granular control.
* A View Mixin that captures into Django's logging setup any failed permission checks.
* An App that supports Client User definable roles and permissions.  This uses the underlying Django Permission system and controls which permissions are exposed to the users.

  * Developers can have both require permissions for the permission classes or optional permission that can be set by the Client.

For example, you have a SAAS platform where you have Administrators Clients.  They manage the other users on their master account in the system (like Employees, etc) and want to be able to define different permissions for various users.  They might have one Employee they want to be able to manage email lists but not let them invite users but both are considered in the staff category.

Installation
------------

To install, just use pip

.. code-block:: shell

   > pip install django-permafrost

To add it to your project, add it to the list of install apps in you ``settings.py``...

.. code-block:: python


   INSTALLED_APPS = [
       ...
       'permafrost',
       ...
   ]

... and migrate


.. code-block:: shell

   > ./manage.py migrate

Setup
-----

The Goal of Django Permafrost is to allow Clients to create their own Permafrost Roles, under developer defined Categories with developer defined required and optional permissions.

An example of a developer defined categories looks like this:

.. code-block:: python

   Sample Category Permission Format:

   PERMAFROST_CATEGORIES = {
       'user': {
           'label': _("User"),
           'access_level': 1,
           'optional': [
               {'label':_('Can Add Users to Role'), 'permission': ('add_user_to_role', 'permafrost', 'permafrostrole')},
           ],
           'required': [
               {'label':_('Can add Role'), 'permission': ('add_permafrostrole', 'permafrost', 'permafrostrole')},
           ],
       },
   }

This would be added to your Django ``settings.py`` file (or, at least, included into).  

In the above, we define the User category, give it the localizable label of "User" and provide two permissions in the "Natural Key" format (since PKs can be unreliable with permissions), the first is optional and the second is required.

There is also an access_level setting to help make sorting access levels more easily.

Recommendations
---------------

It is recommended that you update your code to use PermafrotRole's built-in functions to add users and permissions.  They add an extra level of checking to make sure the permissions passed in are allowed by the PERMAFROST_CATEGORIES configuration.

For example, permissions on a Group:

.. code-block:: python

   group.permissions.set([permission_list])
   group.permissions.add(permission, permission, ...)
   group.permissions.remove(permission, permission, ...)
   group.permissions.clear()

Can be replaced with:

.. code-block:: python

   PermafrostRole.permissions_set([permission_list])
   PermafrostRole.permissions_add(permission, permission, ...)
   PermafrostRole.permissions_remove(permission, permission, ...)
   PermafrostRole.permissions_clear()

Convenience tools
-----------------

There is a tool to help the developer list out the permissions available in the format permafrost expects.

.. code-block:: shell

   > ./manage permlist

using the command will produce a list like this

.. code-block:: shell

   > ./manage.py permlist

   Permlist formatted for your PermafrostRoles configuration
   {'label':_('Can add email address'), 'permission': ('add_emailaddress', 'account', 'emailaddress')},
   {'label':_('Can change email address'), 'permission': ('change_emailaddress', 'account', 'emailaddress')},
   {'label':_('Can delete email address'), 'permission': ('delete_emailaddress', 'account', 'emailaddress')},
   ...

Each line can be copied into the PERMAFROST_CATEGORIES config in the correct format.



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/renderbox/django-permafrost/",
    "name": "django-permafrost",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "django,app",
    "author": "Grant Viklund",
    "author_email": "renderbox@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/84/a6/a1f61cd8616e8b005d1545098fa375a7422ec87f308aee9e38a7fae858ac/django-permafrost-0.2.14.tar.gz",
    "platform": "",
    "description": "\n\n.. image:: https://github.com/renderbox/django-permafrost/workflows/Permafrost%20Develop/badge.svg\n   :target: https://github.com/renderbox/django-permafrost/workflows/Permafrost%20Develop/badge.svg\n   :alt: Permafrost Develop\n\n\n\n.. image:: https://github.com/renderbox/django-permafrost/workflows/Permafrost%20CI/badge.svg\n   :target: https://github.com/renderbox/django-permafrost/workflows/Permafrost%20CI/badge.svg\n   :alt: Permafrost CI\n\n\n\n.. image:: https://readthedocs.org/projects/django-permafrost/badge/?version=latest\n   :target: https://django-permafrost.readthedocs.io/en/latest/?badge=latest\n   :alt: Documentation Status\n\n\nDjango Permafrost\n=================\n\nDjango Permafrost is an extension to Django's Permissions framework.  It's goal is to allow developers to expose some permissions to Client Users on the site so they can create and manage custom User Roles.\n\nIt adds:\n\n\n* A View Mixin that supports user permissions based on different HTTP method types (GET, POST, PUT, etc) for extra granular control.\n* A View Mixin that captures into Django's logging setup any failed permission checks.\n* An App that supports Client User definable roles and permissions.  This uses the underlying Django Permission system and controls which permissions are exposed to the users.\n\n  * Developers can have both require permissions for the permission classes or optional permission that can be set by the Client.\n\nFor example, you have a SAAS platform where you have Administrators Clients.  They manage the other users on their master account in the system (like Employees, etc) and want to be able to define different permissions for various users.  They might have one Employee they want to be able to manage email lists but not let them invite users but both are considered in the staff category.\n\nInstallation\n------------\n\nTo install, just use pip\n\n.. code-block:: shell\n\n   > pip install django-permafrost\n\nTo add it to your project, add it to the list of install apps in you ``settings.py``...\n\n.. code-block:: python\n\n\n   INSTALLED_APPS = [\n       ...\n       'permafrost',\n       ...\n   ]\n\n... and migrate\n\n\n.. code-block:: shell\n\n   > ./manage.py migrate\n\nSetup\n-----\n\nThe Goal of Django Permafrost is to allow Clients to create their own Permafrost Roles, under developer defined Categories with developer defined required and optional permissions.\n\nAn example of a developer defined categories looks like this:\n\n.. code-block:: python\n\n   Sample Category Permission Format:\n\n   PERMAFROST_CATEGORIES = {\n       'user': {\n           'label': _(\"User\"),\n           'access_level': 1,\n           'optional': [\n               {'label':_('Can Add Users to Role'), 'permission': ('add_user_to_role', 'permafrost', 'permafrostrole')},\n           ],\n           'required': [\n               {'label':_('Can add Role'), 'permission': ('add_permafrostrole', 'permafrost', 'permafrostrole')},\n           ],\n       },\n   }\n\nThis would be added to your Django ``settings.py`` file (or, at least, included into).  \n\nIn the above, we define the User category, give it the localizable label of \"User\" and provide two permissions in the \"Natural Key\" format (since PKs can be unreliable with permissions), the first is optional and the second is required.\n\nThere is also an access_level setting to help make sorting access levels more easily.\n\nRecommendations\n---------------\n\nIt is recommended that you update your code to use PermafrotRole's built-in functions to add users and permissions.  They add an extra level of checking to make sure the permissions passed in are allowed by the PERMAFROST_CATEGORIES configuration.\n\nFor example, permissions on a Group:\n\n.. code-block:: python\n\n   group.permissions.set([permission_list])\n   group.permissions.add(permission, permission, ...)\n   group.permissions.remove(permission, permission, ...)\n   group.permissions.clear()\n\nCan be replaced with:\n\n.. code-block:: python\n\n   PermafrostRole.permissions_set([permission_list])\n   PermafrostRole.permissions_add(permission, permission, ...)\n   PermafrostRole.permissions_remove(permission, permission, ...)\n   PermafrostRole.permissions_clear()\n\nConvenience tools\n-----------------\n\nThere is a tool to help the developer list out the permissions available in the format permafrost expects.\n\n.. code-block:: shell\n\n   > ./manage permlist\n\nusing the command will produce a list like this\n\n.. code-block:: shell\n\n   > ./manage.py permlist\n\n   Permlist formatted for your PermafrostRoles configuration\n   {'label':_('Can add email address'), 'permission': ('add_emailaddress', 'account', 'emailaddress')},\n   {'label':_('Can change email address'), 'permission': ('change_emailaddress', 'account', 'emailaddress')},\n   {'label':_('Can delete email address'), 'permission': ('delete_emailaddress', 'account', 'emailaddress')},\n   ...\n\nEach line can be copied into the PERMAFROST_CATEGORIES config in the correct format.\n\n\n",
    "bugtrack_url": null,
    "license": "MIT license",
    "summary": "Adds Client Definable Permissions to Django",
    "version": "0.2.14",
    "split_keywords": [
        "django",
        "app"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "e895f87ec0b70fb0a0a4565a0fd98822",
                "sha256": "ef74ddfc9555167aeddf03b4e621b1c6131e31763e07d4a27786311bb445bab6"
            },
            "downloads": -1,
            "filename": "django_permafrost-0.2.14-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e895f87ec0b70fb0a0a4565a0fd98822",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 41690,
            "upload_time": "2021-04-12T17:15:18",
            "upload_time_iso_8601": "2021-04-12T17:15:18.301304Z",
            "url": "https://files.pythonhosted.org/packages/0c/e9/a07243de7695a4c0a073dd869cbadab79552388629e0f5c9106e0da78e64/django_permafrost-0.2.14-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "0c30a0fa0a50c47cdd67cc91bcfbf081",
                "sha256": "6b3bf613ea9a5a86216e81a28310ee16172f27b62ba93304e29ef866e29b5b58"
            },
            "downloads": -1,
            "filename": "django-permafrost-0.2.14.tar.gz",
            "has_sig": false,
            "md5_digest": "0c30a0fa0a50c47cdd67cc91bcfbf081",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 26841,
            "upload_time": "2021-04-12T17:15:19",
            "upload_time_iso_8601": "2021-04-12T17:15:19.494941Z",
            "url": "https://files.pythonhosted.org/packages/84/a6/a1f61cd8616e8b005d1545098fa375a7422ec87f308aee9e38a7fae858ac/django-permafrost-0.2.14.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2021-04-12 17:15:19",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": null,
    "github_project": "renderbox",
    "error": "Could not fetch GitHub repository",
    "lcname": "django-permafrost"
}
        
Elapsed time: 0.32637s