Skip to content

Releases: meinsoft/django-shield

v0.2.1 - Chained Guards & Debug Mode

Choose a tag to compare

@meinsoft meinsoft released this 21 Jan 05:44

What's New

Features

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.git

v0.2.0 - Expression Syntax

Choose a tag to compare

@meinsoft meinsoft released this 21 Jan 02:59

🎉 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 = Post

Quality

  • 192 tests passing
  • 96% code coverage

Installation

pip install git+https://github.com/meinsoft/django-shield.git

v0.1.0 - Foundation

Choose a tag to compare

@meinsoft meinsoft released this 20 Jan 02:03
5e3834b

🎉 First Release

Django Shield v0.1.0 - Foundation release.

Features

  • @rule decorator for defining permission rules
  • @guard decorator 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