Skip to main content

ACLVL Permissions

ACLVL Permissions is a Django package that provides an easy-to-use system for managing roles and access levels within your Django applications. It simplifies role-based access control (RBAC) by linking roles to access levels and associating them with views.


Features

  • Define roles and access levels for flexible and scalable RBAC.
  • Automatically create or retrieve AccessLevel objects from views with declared permissions.
  • Management commands to list views and synchronize access levels.
  • Django admin integration for managing roles and access levels.

Installation

  1. Install the package using pip:
pip install aclvl_permissions
  1. Add the app to your INSTALLED_APPS in settings.py:
INSTALLED_APPS = [
    # Other apps
    'aclvl_permissions',
]
  1. Run migrations to set up the database models:
python manage.py makemigrations aclvl_permissions
python manage.py migrate

Models

Role

The 'Role' model defines user roles within the system. Each role can be associated with multiple 'AccessLevel' objects.

ACLVL Permissions Models

The ACLVL Permissions package provides two primary models: Role and AccessLevel. These models form the backbone of the role-based access control (RBAC) system by defining roles and permissions within your application.


Models Overview

1. Role

The Role model represents a user role within the system. Roles are linked to AccessLevel objects to define what permissions a role has.

Fields

Field Type Description
name CharField Name of the role (e.g., "Admin", "Editor").
role_key CharField Unique identifier key for the role.
access_level ManyToManyField Relationship to the AccessLevel model.

2. AccessLevel

The 'AccessLevel' model represents an individual permission within the system. Access levels are linked to roles to grant specific permissions.

Fields

Field Type Description
name CharField Name of the role (e.g., "Admin", "Editor").
access_key CharField Unique identifier key for the access level.

Commands Overview

1. list_views

The list_views command lists all declared views in your Django project, displays their view_key and required_access_levels, and ensures that all AccessLevel objects for the specified required_access_levels are created in the database.

Features:

  • Lists all views with a view_key and required_access_levels.
  • Automatically creates or retrieves AccessLevel objects based on declared permissions.

Command Usage:

python manage.py aclvl_set_view_keys

Usage

In your Django project, you can use the custom permission as follows:

from aclvl_permissions.permissions import AccessLevelPermission

class MyView(APIView):
    permission_classes = [AccessLevelPermission]
    required_access_levels = ['view_all_model', 'view_owner_model', 'create_all_model']
    view_key = 'model'

License

This project is licensed under the MIT License - see the LICENSE file for details.

Metadata

Release files for aclvl-permissions 0.3.0

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

Source distribution (sdist)

Source distribution for aclvl-permissions 0.3.0
File Size Uploaded Provenance
aclvl_permissions-0.3.0.tar.gz 6.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for aclvl-permissions 0.3.0
File Interpreter ABI Platform
aclvl_permissions-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 13.5 kB

Release files / aclvl_permissions-0.3.0.tar.gz

Download URL aclvl_permissions-0.3.0.tar.gz
Size 6.5 kB
Tags Source
SHA-256 checksum
How to use checksums
ccb7f338427b7d045cad003d6b06bf14b9327c2cd692daa746a6c655837b8b22
BLAKE2b-256 checksum
How to use checksums
b178d0340afe93ce429183f076477e82deaaf9e0c446a49206a47e62c8b0ff30
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.8.10

Release files / aclvl_permissions-0.3.0-py3-none-any.whl

Download URL aclvl_permissions-0.3.0-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e63230ac24c70454ec89389c8587e325a46cb415a678b023f5a058f4b4e2c797
BLAKE2b-256 checksum
How to use checksums
67a29a963a970c52fb9b672d83ecdf88ba72cc0588aac7b0db5d38efe7a08eb1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.8.10

Security for aclvl-permissions 0.3.0

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