Skip to main content

A method for adding object-level or row-level permissions

Project description

This is an implementation of Object Permissions, a.k.a. row level permissions. Object Permissions allow you to assign a permission to an instance of any Model in your django project. This app provides a authentication backend that works with Django >= 1.2.

This specific implementation includes the ability to assign permissions to Users and UserGroups. Later versions may include the ability to create PermissionGroups and ObjectPermissionGroups.

Installation

There are several ways to install Object Permissions.

Object Permissions ships a standard distutils setup.py. A classic invocation to install from setup.py might be:

$ python setup.py install

You may need to add sudo in order to install to the system Python.

$ sudo python setup.py install

We also have Object Permissions on PyPI, so it can be installed using pip. (easy_install also works, but we do not recommend easy_install. Just use pip.)

$ pip install django-object-permissions

If you are installing Object Permissions directly into a Django app, and want to distribute Object Permissions with your app, simply copy the object_permissions folder into your Django project.

Configuring Your Django Project

  1. Add “object_permissions” to INSTALLED_APPS

  2. Run ./manage.py syncdb

  3. Add object_permissions.urls to urls if you wish to add views for editing user_groups

Using Object Permissions

First, register some permissions onto a Model in your models.py. This can only be done once per model; see registration.py for more information.

>>> from object_permissions import register
>>> register(['permission'], Model)

Now, that permission can be granted, revoked, or checked for any instance of that Model.

>>> user.grant('permission', object)
>>> user.revoke('permission', object)
>>> user.has_perm('permission', object)
>>> group.grant('permission', object)
>>> group.revoke('permission', object)

Authors

Object Permissions was originally implemented by Peter Krenesky at the Oregon State University Open Source Lab (OSUOSL). This release is maintained by Corbin Simpson.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-object-permissions-1.0.tar.gz (63.5 kB view details)

Uploaded Source

File details

Details for the file django-object-permissions-1.0.tar.gz.

File metadata

File hashes

Hashes for django-object-permissions-1.0.tar.gz
Algorithm Hash digest
SHA256 d48bca4f44b8a5750737f940cf8b9b1e4911444e5eaebfd05bd74da4147eb913
MD5 2a92c8eb199d84a19b8a32c6d9ce49f9
BLAKE2b-256 c9a3ecd151b5480c9de32977f2b17652b6f35b515fe1c0ff5d24dcb91091e679

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page