How stackadnan/django-tenant-apikeys works
django-tenant-apikeys is a Django library for issuing and enforcing tenant-scoped API keys. A project creates a key through the model or Django admin; a client presents it through the DRF or Ninja adapter, which delegates verification and shared policy checks to the core and attaches the tenant. Scope checks and optional per-key rate limits further gate access. Keys can later be rotated or revoked, with lifecycle signals available to projects. The graph reflects README capabilities and shown source references; unsampled implementation details are not assumed.
Main entry points: models.py Key model · authentication.py DRF authentication · ninja.py Ninja authentication · core.py Shared auth core
Components 15
Key management
- Key model
django_tenant_apikeys/models.py - Django database
- Admin interface
django_tenant_apikeys/admin.py - Lifecycle commands
django_tenant_apikeys/management/commands
Request authentication
- DRF authentication
django_tenant_apikeys/authentication.py - Ninja authentication
django_tenant_apikeys/ninja.py - Shared auth core
django_tenant_apikeys/core.py - Client IP resolution
django_tenant_apikeys/ip.py
Access policies
- Scope permissions
django_tenant_apikeys/permissions.py - Rate-limit engine
django_tenant_apikeys/ratelimit.py - DRF throttle
django_tenant_apikeys/throttling.py - Django cache
Operations and events
- Lifecycle signals
django_tenant_apikeys/signals.py
Other components
- Project developer
- API client
Connections 24
- Project developer → Key model: creates keys
README.md - Key model → Django database: persists keys
README.md - Project developer → Admin interface: manages keys
README.md - Admin interface → Key model: creates and revokes
django_tenant_apikeys/admin.py - Project developer → Lifecycle commands: runs commands
README.md - Lifecycle commands → Key model: rotates or revokes
django_tenant_apikeys/management/commands/tenant_api_key_rotate.py - API client → DRF authentication: sends API key
README.md - API client → Ninja authentication: sends API key
README.md - DRF authentication → Client IP resolution: resolves client IP
django_tenant_apikeys/authentication.py - DRF authentication → Shared auth core: authenticates key
django_tenant_apikeys/authentication.py - Ninja authentication → Client IP resolution: resolves client IP
django_tenant_apikeys/ninja.py - Ninja authentication → Shared auth core: authenticates key
django_tenant_apikeys/ninja.py - Shared auth core → Key model: looks up and verifies
django_tenant_apikeys/core.py - DRF authentication → Key model: resolves key model
django_tenant_apikeys/authentication.py - Ninja authentication → Key model: resolves key model
django_tenant_apikeys/ninja.py - DRF authentication → Scope permissions: provides authenticated key
README.md - Ninja authentication → Scope permissions: checks required scopes
django_tenant_apikeys/ninja.py - DRF authentication → DRF throttle: enables throttling
README.md - Ninja authentication → Rate-limit engine: checks key limit
django_tenant_apikeys/ninja.py - DRF throttle → Rate-limit engine: checks key limit
django_tenant_apikeys/throttling.py - Rate-limit engine → Django cache: counts requests
django_tenant_apikeys/ratelimit.py - Key model → Lifecycle signals: emits lifecycle events
django_tenant_apikeys/models.py - Shared auth core → Lifecycle signals: emits rejection events
django_tenant_apikeys/signals.py - Rate-limit engine → Lifecycle signals: emits limit events
django_tenant_apikeys/ratelimit.py