Skip to content

1.15.0 — Django Async Support (ASGI)

Choose a tag to compare

@Cheater121 Cheater121 released this 04 Apr 16:10
· 12 commits to main since this release
0946233

Adds native async integration for Django 4.1+ ASGI applications:

  • New async components in rbacx.adapters.django:

    • AsyncRbacxDjangoMiddleware — injects Guard as request.rbacx_guard without blocking the event loop
    • async_require_access(...) — async view decorator using Guard.evaluate_async
    • AsyncTraceIdMiddleware — async request trace ID injection for logging context
  • Middleware is ASGI-aware and sets _is_coroutine so Django properly awaits it

  • Enables fully non-blocking authorization in async Django views

Usage:

# settings.py
MIDDLEWARE = [
    "rbacx.adapters.django.trace.AsyncTraceIdMiddleware",
    "rbacx.adapters.django.middleware.AsyncRbacxDjangoMiddleware",
]

# views.py
from rbacx.adapters.django.decorators import async_require_access

@async_require_access(build_env, add_headers=True)
async def my_view(request):
    ...
  • Existing sync components (RbacxDjangoMiddleware, require_access, TraceIdMiddleware) are unchanged

No breaking changes

Upgrade

pip install -U rbacx