Role and permission management for Django projects.
Project description
django-minosse
Role-based access control for Django, without the extra database tables.
django-minosse lets you define roles as Python classes, sync them to Django's built-in
Group model, and protect views with decorators or mixins — all on top of the
django.contrib.auth machinery you already have.
Requirements
- Python 3.12+
- Django 5.0+
Installation
pip install django-minosse
or with uv:
uv add django-minosse
No changes to INSTALLED_APPS are needed. django-minosse relies on
django.contrib.auth and django.contrib.contenttypes, which are already present in
every Django project. Run python manage.py migrate at least once so the auth tables
exist before calling sync() or get_group().
Quick start
1. Define roles
# myapp/roles.py
from minosse.roles import AbstractRole, RoleRegistry
registry = RoleRegistry()
@registry.register
class EditorRole(AbstractRole):
group_name = "Editors"
available_permissions = {
"can_publish": True,
"can_edit": True,
"can_delete": False,
}
@registry.register
class ViewerRole(AbstractRole):
group_name = "Viewers"
available_permissions = {
"can_view_reports": True,
}
2. Sync roles to the database
from myapp.roles import registry
registry.sync() # call from a management command or AppConfig.ready()
3. Protect views
Function-based views:
from django.contrib.auth.decorators import login_required
from minosse.decorator import role_required, permission_required
from .roles import EditorRole
@login_required
@role_required(EditorRole)
def editor_dashboard(request):
...
@login_required
@permission_required("can_publish")
def publish_article(request, pk):
...
Class-based views:
from django.views.generic import TemplateView
from minosse.mixin import RoleRequiredMixin, PermissionRequiredMixin
from .roles import EditorRole
class EditorDashboardView(RoleRequiredMixin, TemplateView):
required_role_class = EditorRole
template_name = "editor/dashboard.html"
class PublishView(PermissionRequiredMixin, TemplateView):
required_permission_codename = "can_publish"
template_name = "editor/publish.html"
4. Manage role membership
# Assign / remove
EditorRole.add_user_to_role(user)
EditorRole.remove_user_from_role(user)
# Check
if EditorRole.user_has_role(user):
...
Features
- Define roles as Python classes with declarative permission sets
- Sync roles and permissions to Django's
Group/Permissionmodels - Protect function-based views with
@role_requiredand@permission_required - Protect class-based views with
RoleRequiredMixinandPermissionRequiredMixin - Register roles centrally via
RoleRegistryfor bulk sync
Documentation
Full documentation is available in the docs/ directory and can be served locally:
make docs-serve
License
MIT
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
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 django_minosse-1.0.2.tar.gz.
File metadata
- Download URL: django_minosse-1.0.2.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b84b1d9445083b0ea2a0f4a5837fafd8f269e65db0baec231fbb8ca0ac18417b
|
|
| MD5 |
dfa7036c0cb7621c399416e17fcc7872
|
|
| BLAKE2b-256 |
6aeb7212e5fdd64526c4d2a9f69f97029485bb54a2dd17c5e6f1a5be6436441c
|
Provenance
The following attestation bundles were made for django_minosse-1.0.2.tar.gz:
Publisher:
publish.yml on fundor333/django-minosse
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_minosse-1.0.2.tar.gz -
Subject digest:
b84b1d9445083b0ea2a0f4a5837fafd8f269e65db0baec231fbb8ca0ac18417b - Sigstore transparency entry: 1864393513
- Sigstore integration time:
-
Permalink:
fundor333/django-minosse@2627e4799fb56e04118470b07108ad1d3323f940 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/fundor333
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2627e4799fb56e04118470b07108ad1d3323f940 -
Trigger Event:
push
-
Statement type:
File details
Details for the file django_minosse-1.0.2-py3-none-any.whl.
File metadata
- Download URL: django_minosse-1.0.2-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a1376b3d552f2c6e6575802ac47cf2da69420e5c1e50ca88f0bbd0ecfc595790
|
|
| MD5 |
d829b5c27731357a6cc95d759fd5568b
|
|
| BLAKE2b-256 |
f660440137067c6e12c3c86b2899ebd55c2824c1e32bc167fb94e0e399c996f1
|
Provenance
The following attestation bundles were made for django_minosse-1.0.2-py3-none-any.whl:
Publisher:
publish.yml on fundor333/django-minosse
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_minosse-1.0.2-py3-none-any.whl -
Subject digest:
a1376b3d552f2c6e6575802ac47cf2da69420e5c1e50ca88f0bbd0ecfc595790 - Sigstore transparency entry: 1864393636
- Sigstore integration time:
-
Permalink:
fundor333/django-minosse@2627e4799fb56e04118470b07108ad1d3323f940 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/fundor333
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2627e4799fb56e04118470b07108ad1d3323f940 -
Trigger Event:
push
-
Statement type: