Skip to main content
Yanked

This release has been yanked by its maintainers, and will be ignored by installers, except when explicitly specified.
Reason given by maintainers: Early build, no longer supported. Use 0.1.2 or later.

devora-django

Recording, masking and capture policy are configured in the Devora dashboard and authorized server-side for each session. This backend SDK takes no capture settings, and devora_sdk() ignores keyword arguments it does not recognize, so check option names carefully. See capture settings.

Django adapter for the Devora Python backend SDK.

Requirements

  • Python >=3.10,<4.0
  • Django >=5.2.17,<7.0, excluding 6.0.0 through 6.0.7 (on Django 6.0, use 6.0.8 or newer)
  • In production, a replay store shared by every worker (the example below uses Redis 6.2 or newer, for SET ... PXAT)

Install

pip install devora-python devora-django redis

Quick Start

# devora_integration.py
import os

import redis
from devora_sdk import DEVORA_ENDPOINTS, devora_sdk

# Replay protection shared by every worker and instance (required in production).
redis_client = redis.Redis.from_url(os.environ["REDIS_URL"])


class RedisReplayStore:
    def consume(self, namespace: str, request_id: str, expires_at: int) -> bool:
        # Atomic insert-if-absent kept until expires_at; an exception makes the SDK fail closed (503).
        key = f"devora:replay:{namespace}:{request_id}"
        return bool(redis_client.set(key, b"1", nx=True, pxat=expires_at))


sdk = devora_sdk(
    api_key=os.environ["DEVORA_API_KEY"],  # pk_server_live_...
    secret_key=os.environ["DEVORA_SECRET_KEY"],  # sk_server_live_...
    org_id=os.environ["DEVORA_ORG_ID"],
    replay_store=RedisReplayStore(),
)


@sdk.register(DEVORA_ENDPOINTS.USER_SEARCH)
def search_users(req):
    return {"users": search_customer_users(req.query.get("term", ""))}
# urls.py
from django.urls import include, path
from devora_sdk_django import django_urlpatterns
from .devora_integration import sdk

urlpatterns = [
    path("devora/", include(django_urlpatterns(sdk))),
]

Register every handler before building the URL patterns; routes registered later are not mounted. If any handler is an async def function, use async_django_urlpatterns(sdk) instead (it runs sync handlers in a worker thread too); django_urlpatterns answers an async handler with 400 HANDLER_ERROR.

The environment comes from environment=, else DEVORA_ENV, else NODE_ENV. Anything other than development or test (including unset) is production, and production refuses to start without a replay_store. Any store whose consume is an atomic insert-if-absent shared by every worker works; see the replay-store contract. consume must be a regular (not async def) method.

Local development only: to run without Redis, omit replay_store and set DEVORA_ENV=development (or pass environment="development"). The SDK then keeps request ids in memory, which protects a single process only. Never use this in production.

For protected application routes, install the guard middleware and return the context dict your IMPERSONATE handler stored, read back from your authenticated request state.

# devora_guard.py
from devora_sdk_django import create_impersonation_guard
from .devora_integration import sdk


def get_impersonation_context(request):
    # YOU IMPLEMENT: return the dict your IMPERSONATE handler stored, read from
    # your verified session (never from headers or JSON the browser can set), or None.
    return getattr(request.user, "devora", None)


DevoraGuardMiddleware = create_impersonation_guard(
    sdk=sdk,
    get_impersonation_context=get_impersonation_context,
)

Add "yourapp.devora_guard.DevoraGuardMiddleware" to settings.MIDDLEWARE, after your own authentication middleware, so request.user is set when the guard runs.

expires_at must be a Unix timestamp in milliseconds. If your JWT stores Unix seconds, multiply by 1000 when building the impersonation context. actor, subject, auth_method, authorization_source, and recording_allowed are all required — the guard rejects the context as invalid without them, even though the dataclass marks them optional for construction convenience.

Cross-Origin-Opener-Policy

Django's SecurityMiddleware sends Cross-Origin-Opener-Policy: same-origin by default. That cuts the page opened by a Devora impersonation link off from the dashboard tab that opened it, so the link cannot be redeemed. Set SECURE_CROSS_ORIGIN_OPENER_POLICY = None, or send unsafe-none on the route your Devora links land on.

Request body limits

SDK views read at most max_body_size + 1 bytes before parsing (1 MiB by default) and reject oversized declared lengths without reading. The browser-session view uses a 4 KiB limit. Async SDK views perform this bounded read off the event loop. Set DATA_UPLOAD_MAX_MEMORY_SIZE = 1024 * 1024 and keep earlier middleware from buffering larger SDK bodies. WSGI/ASGI servers and reverse proxies also need request-size and read-timeout limits: Django's ASGI handler can spool a request before a view runs, and the SDK cannot bound that prior allocation.

Options, error codes and the browser-session bridge are documented in the Python reference.

Metadata

Release files for devora-django 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for devora-django 0.1.1
File Size Uploaded
devora_django-0.1.1.tar.gz 9.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for devora-django 0.1.1
File Interpreter ABI Platform
devora_django-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 20.5 kB

Release files / devora_django-0.1.1.tar.gz

Download URL devora_django-0.1.1.tar.gz
Size 9.8 kB
Tags Source
SHA-256 checksum
How to use checksums
9f1eaefb22cbd0f67688e13075fd288a7835c2c29820bc95fdb99ed5ea9876df
BLAKE2b-256 checksum
How to use checksums
98aec86a5cfb2da57cf3cbcce620be2e7f5f1fa1e69754e9183ed772e03f2361
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 30, 2026.

Transparency log

Release files / devora_django-0.1.1-py3-none-any.whl

Download URL devora_django-0.1.1-py3-none-any.whl
Size 10.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2dc7473b71287707970cd88b8173aae58f30c0bea34dc00bffe21fcc4437c710
BLAKE2b-256 checksum
How to use checksums
fcfb6dab827dca53e868452a3654661ba01e6c7724ae058cfa340d22a3dc5144
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 30, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page