Metadata-Version: 2.4
Name: kernia-django
Version: 0.1.0
Summary: Django integration
Project-URL: Homepage, https://kernia.dev
Project-URL: Documentation, https://kernia.dev/docs
Project-URL: Source, https://github.com/advantch/kernia
Project-URL: Issues, https://github.com/advantch/kernia/issues
Project-URL: Changelog, https://github.com/advantch/kernia/releases
Author: Advantch
License-Expression: MIT
License-File: LICENSE
Keywords: asgi,authentication,authorization,django,fastapi,oauth,passkeys,security,sessions,sso,starlette
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Internet :: WWW/HTTP :: Session
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.11
Requires-Dist: anyio>=4
Requires-Dist: django>=4.2
Requires-Dist: kernia>=0.1.0
Description-Content-Type: text/markdown

# kernia-django

Django integration for Kernia. Mounts the auth router, populates `request.kernia_session` and `request.kernia_user`, and provides a view decorator for protected views.

Part of [Kernia](https://kernia.dev), a framework-agnostic authentication library for Python.

## Installation

    pip install kernia-django

## Usage

Add the app to `INSTALLED_APPS` and the middleware, then splice the auth routes into `urls.py`:

```python
# urls.py
from django.urls import path
from kernia_django import setup
from myproject.auth import auth   # your init(KerniaOptions(...)) instance

urlpatterns = [
    *setup(auth, url_prefix="/api/auth"),
]
```

```python
# views.py
from kernia_django import require_session

@require_session
def me(request):
    return JsonResponse({"user_id": request.kernia_user["id"]})
```

Django is sync-by-default; the bridge uses `asgiref.sync.async_to_sync` to call the async core.

## Documentation

Full documentation at [kernia.dev/docs](https://kernia.dev/docs). Source at [github.com/advantch/kernia](https://github.com/advantch/kernia).

## License

MIT
