IAM-style roles and permissions for Django Rest Framework
Project description
DRF-IAM (Django REST Framework - Identity and Access Management)
A powerful Django application that provides Role-Based Access Control (RBAC) for Django REST Framework applications. Easily manage permissions and roles across your API endpoints.
Features
- 🔒 Role-Based Access Control (RBAC)
- 🎯 Custom policy names for viewsets
- 🔄 Seamless integration with Django's User model
- ⚡ Easy to set up and configure
- 📚 Comprehensive documentation
Installation
pip install drf-iam
Quick Start
- Add
drf_iamto yourINSTALLED_APPSinsettings.py:
INSTALLED_APPS = [
...
'drf_iam',
]
- Add the Role relationship to your User model:
from django.contrib.auth.models import AbstractUser
from drf_iam.models import Role
class User(AbstractUser):
role = models.ForeignKey(Role, on_delete=models.SET_NULL, null=True)
- Run migrations:
python manage.py makemigrations
python manage.py migrate
- Use in your viewsets:
from rest_framework import viewsets
from drf_iam.permissions import IAMPermission
class UserViewSet(viewsets.ModelViewSet):
permission_classes = [IAMPermission]
iam_policy_name = "users" # Optional: Custom policy name for this viewset
Documentation
For detailed documentation, visit https://drf-iam.readthedocs.io/
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file drf_iam-0.2.11.tar.gz.
File metadata
- Download URL: drf_iam-0.2.11.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20d88f0de1726040b7ef39a61f47a84681f7dadf0eb2013c9e6a2f57fb1a2b3a
|
|
| MD5 |
b6b157bb1165e29c3db162efe50fbb31
|
|
| BLAKE2b-256 |
74f7e2d3dca6d49dff2678e6f16ebb931849a23a9a6367d506a0047538dce092
|
File details
Details for the file drf_iam-0.2.11-py3-none-any.whl.
File metadata
- Download URL: drf_iam-0.2.11-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9cb4b703a4f2743b507d34502a70516b1aa03e8d13e4ed6bf10ef4038ff20431
|
|
| MD5 |
22de5ebafc02f43eb645e2d43918f50e
|
|
| BLAKE2b-256 |
96bc80a21823893e6ea4091d5e27b79b684817c8ce8e47a880d458e8b99b308f
|