Skip to main content

Django integration

Project description

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, 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:

# 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"),
]
# 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. Source at github.com/advantch/kernia.

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

kernia_django-0.1.0.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kernia_django-0.1.0-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file kernia_django-0.1.0.tar.gz.

File metadata

  • Download URL: kernia_django-0.1.0.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for kernia_django-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4fa449e2721ed32ae3e3760ef78d3f74c236ba64dc7100b1d646f19e540e11af
MD5 edc66a28dfd9d6722a5bf6d89f6a3662
BLAKE2b-256 2727100ed82c8f6cc076704f887e85e989a33e9b680e46a9f852786d19f7782c

See more details on using hashes here.

File details

Details for the file kernia_django-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: kernia_django-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for kernia_django-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 de84a8165ce2af56fa3a8113c0f670c03dca60bec20b92a9bc720e306974896c
MD5 b5ef6ca77599fea854ca0e2e479308aa
BLAKE2b-256 99c54e13cf299a91538f1f5ace42f92a31e33425b2a55691b54d0e6ea5747ba6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page