Skip to main content

django-field-object-permissions

django-field-object-permissions is an object permission system based on field values of the object. (eg: object.owner == user)

Install

To install just run:

pip install django-field-object-permissions

Configuration

  1. Put fieldobjectpermissions to your INSTALLED_APPS of the settings module:

    INSTALLED_APPS = (
       ...
       'fieldobjectpermissions',
    )

2. Replace the default authentication backend (fieldobjectpermissions is based on it):

AUTHENTICATION_BACKENDS = (
    # django.contrib.auth.backends.ModelBackend,  # Default
    fieldobjectpermissions.backends.FieldObjectPermissionsBackend,
)
  1. These new values are optional, defaults are shown below:

    FIELD_OBJECT_PERMISSIONS = {
        'OWNER_FIELDS': ('owner',),
        'GROUP_FIELDS': ('group',),
        'OWNER_ACTIONS': ('change', 'delete'),
        'GROUP_ACTIONS': ('change', 'delete'),
    }

4. Run python manage.py migrate as there are post-migration triggers to create the extra permissions required.

Usage

You can now assign permissions like owner_change_foo to allow only the user who matches the value of the owner field to change an object (or the superuser, of course).

Or the permission group_delete_foo to all allow any user who is a member of a group listed in the group field of an object to delete it (or the superuser, you know this).

These permissions are created in a post-migrate signal handler, and will only be created for models with have the required field(s).

By specifying multiple fields for OWNER_FIELDS or GROUP_FIELDS only one of the listed fields needs to exist for permission creation. And only one needs to match for permission to be granted by the auth backend.

Metadata

Release files for django-field-object-permissions 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-field-object-permissions 0.1.1
File Size Uploaded Provenance Actions
django-field-object-permissions-0.1.1.tar.gz 4.9 kB Without provenance Details for django-field-object-permissions-0.1.1.tar.gz

Release files / django-field-object-permissions-0.1.1.tar.gz

Download URL django-field-object-permissions-0.1.1.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
e28300dc7031428466f497f0ef122d81514f95d55632a6734b1d02ab02224b57
BLAKE2b-256 checksum
How to use checksums
cb00b79542b0641708e55cf837f70f6b461d1879fc95887afa58ad97f674dcb8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for django-field-object-permissions 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page