Releases: meinsoft/django-shield
Releases · meinsoft/django-shield
Release list
v0.2.1 - Chained Guards & Debug Mode
What's New
Features
- guard.all() - All rules must pass
- guard.any() - At least one rule must pass
- Debug mode - Console logging for permission checks
- Documentation - https://meinsoft.github.io/django-shield
Usage
@guard.all(
'user.is_authenticated',
'is_author or is_admin'
)
def edit_post(request, pk):
...
@guard.any(
'user.is_superuser',
'is_author'
)
def view_post(request, pk):
...
# settings.py
DJANGO_SHIELD = {
'DEBUG': True
}Quality
- 217 tests passing
Installation
pip install git+https://github.com/meinsoft/django-shield.gitv0.2.0 - Expression Syntax
🎉 Expression Syntax Release
New Features
- Class-based View support - @ guard now works on CBV classes
- Expression syntax - Write permissions as strings
- All operators - and, or, not, ==, !=, >, <, >=, <=, in
- Attribute access - obj.field, user.field, obj.author == user
- null support - obj.deleted_at == null
Examples
@guard('is_admin or is_author')
@guard('obj.status == "draft"')
@guard('obj.author == user')
@guard('obj.status in ["draft", "pending"]')
@guard('user.is_staff and not obj.is_locked')
@guard('is_author')
class PostUpdateView(UpdateView):
model = PostQuality
- 192 tests passing
- 96% code coverage
Installation
pip install git+https://github.com/meinsoft/django-shield.gitv0.1.0 - Foundation
🎉 First Release
Django Shield v0.1.0 - Foundation release.
Features
@ruledecorator for defining permission rules@guarddecorator for protecting function-based views- Object-level permissions
- Auto-inject fetched objects to views
- Custom lookup fields (slug, uuid, etc.)
Quality
- 48 tests passing
- 100% code coverage
- Python 3.10, 3.11, 3.12
- Django 4.2, 5.0, 5.1
Installation
pip install git+https://github.com/meinsoft/django-shield.git