djangoplay-web / Integrations / DjangoPlay ↔ AuthX Integration Architecture
DocsDjangoPlay WebIntegrationsDjangoPlay ↔ AuthX Integration Architecture

DjangoPlay ↔ AuthX Integration Architecture

This document describes how DjangoPlay integrates with AuthX for identity, authentication, and SSO.

9 min readApplies to v1.2.2
On this page ▾
  1. 1. Integration Overview
  2. Architectural principle
  3. 2. Responsibility Boundary
  4. DjangoPlay owns
  5. AuthX owns
  6. 3. Identity Architecture
  7. 4. DjangoPlay Integration Components
  8. 5. AuthX Client
  9. 6. DjangoPlay → AuthX Communication
  10. 7. Service Authentication
  11. 8. Identity Creation Flow
  12. Design rule
  13. 9. Identity Update Flow
  14. 10. Identity Lookup
  15. 11. Local UserIdentity Mirror
  16. 12. Authentication and Authorization Boundary
  17. AuthX
  18. DjangoPlay
  19. 13. Secrets and Configuration
  20. 14. Environment Separation
  21. 15. Failure Boundary
  22. 16. Integration Design Principles
  23. 17. Integration Summary

DjangoPlay remains the application platform and domain owner, while AuthX acts as the centralized identity service.


1. Integration Overview

DjangoPlay and AuthX are separate applications with clearly defined responsibilities.

DjangoPlay owns application-level user data, domain relationships, authorization, and business workflows.

AuthX owns identity and authentication concerns such as credentials, authentication state, SSO identity linkage, and token handling.

Architectural principle

AuthX is the identity authority; DjangoPlay maintains a local application-level mirror of the identity.

The local mirror exists so that DjangoPlay can maintain application relationships, permissions, profiles, and domain-specific data without making AuthX the owner of the Django application's domain model.


2. Responsibility Boundary

The integration is intentionally divided into two responsibility domains.

DjangoPlay owns

  • User-facing application flows
  • Application-specific user and profile data
  • Local UserIdentity representation
  • Application relationships and foreign keys
  • Groups and application permissions
  • Policy-based authorization
  • Domain workflows
  • Integration with AuthX through AuthXClient

AuthX owns

  • Identity records
  • Authentication credentials
  • Password hashing
  • Authentication workflows
  • SSO identity linkage
  • Identity state
  • JWT/token operations
  • Authoritative identity information

This separation prevents authentication concerns from becoming distributed throughout the DjangoPlay application.


3. Identity Architecture

The identity relationship can be represented as:

The important distinction is:

text
AuthX
    ↓
Authoritative identity

DjangoPlay
    ↓
Local identity mirror + application data

4. DjangoPlay Integration Components

The DjangoPlay side of the integration is centered around the AuthX client and identity synchronization services.

The general structure is:

text
Authentication Flow
       │
       ▼
AuthX Integration Service
       │
       ▼
AuthXClient
       │
       ▼
AuthX HTTP API

The synchronization layer is responsible for keeping the local UserIdentity representation aligned with the authoritative AuthX identity.

Typical operations include:

  • Create identity
  • Update identity
  • Retrieve identity
  • Lookup identity by email
  • Synchronize identity information
  • Maintain the local identity mirror

5. AuthX Client

DjangoPlay communicates with AuthX through an HTTP client abstraction rather than making raw HTTP calls throughout the application.

Conceptually:

This provides a single integration boundary for:

  • Base URL configuration
  • Service authentication
  • HTTP communication
  • Request handling
  • AuthX API interaction

This also prevents AuthX-specific HTTP details from leaking into domain applications.


6. DjangoPlay → AuthX Communication

DjangoPlay communicates with AuthX over HTTP.

The internal AuthX API is protected using a service-to-service authentication header:

http
X-Service-Token: <AUTHX_SERVICE_TOKEN>

The high-level communication path is:

text
DjangoPlay
    │
    │ HTTPS / HTTP
    │ X-Service-Token
    ▼
AuthX Internal API
    │
    ▼
Identity Service
    │
    ▼
AuthX Database

In local development, AuthX may run on a local service endpoint such as:

text
http://localhost:8100

The actual endpoint is environment-specific and is supplied through DjangoPlay configuration.


7. Service Authentication

DjangoPlay authenticates itself to AuthX as a trusted internal service.

The service token is a shared secret between the two services.

It must be treated as infrastructure credential material and must not be exposed to browsers or client-side code.


8. Identity Creation Flow

When DjangoPlay needs to create a new identity, AuthX creates the authoritative identity first.

Design rule

The order is intentional:

text
Create authoritative AuthX identity
             ↓
Receive identity information
             ↓
Synchronize DjangoPlay mirror

DjangoPlay should not create an independent authentication identity that competes with AuthX.


9. Identity Update Flow

Updates follow the same authority model.

This keeps AuthX as the authoritative source while allowing DjangoPlay to maintain its local representation.


10. Identity Lookup

DjangoPlay can retrieve identity information from AuthX when required.

Typical operations include:

text
Get identity by ID
Get identity by email
Create identity
Update identity

Conceptually:


11. Local UserIdentity Mirror

DjangoPlay maintains a local identity representation because the Django application needs to associate identity with its own domain model.

The local representation can provide application access to information such as:

text
authx_id
username
email
sso_provider
sso_id
is_active
is_verified
is_staff
is_superuser

The exact fields are determined by the current DjangoPlay implementation.

The architectural distinction is:

Data Authority
Authentication identity AuthX
Password credentials AuthX
SSO identity linkage AuthX
Application profile data DjangoPlay
Application relationships DjangoPlay
Application permissions DjangoPlay
Domain-specific data DjangoPlay

The mirror is therefore not a second authentication authority.


12. Authentication and Authorization Boundary

Authentication and authorization are separate concerns.

AuthX

Answers:

Who is this user?

DjangoPlay

Answers:

What is this user allowed to do in this application?

This distinction is fundamental to the integration architecture.


13. Secrets and Configuration

DjangoPlay and AuthX maintain their own service configuration.

DjangoPlay contains the configuration required to communicate with AuthX, while AuthX maintains its own service-side credentials and database configuration.

Conceptually:

text
DjangoPlay configuration
    │
    ├── AUTHX_BASE_URL
    ├── AUTHX_SERVICE_TOKEN
    └── AUTHX_TIMEOUT


AuthX configuration
    │
    ├── AUTHX_SERVICE_TOKEN
    ├── AUTHX database configuration
    └── AuthX cryptographic configuration

AuthX-specific secrets should remain under AuthX's own configuration boundary.

Secrets must never be committed to source control or exposed to client-side applications.


14. Environment Separation

The integration supports environment-specific AuthX configuration.

The AuthX base URL and service credentials are supplied through the configuration for the active environment.

This prevents development configuration from being coupled to production infrastructure.


15. Failure Boundary

Because AuthX is a separate service, DjangoPlay treats communication with AuthX as an external service boundary.

Failures can occur at several boundaries:

  • Network connectivity
  • AuthX availability
  • Service authentication
  • Request validation
  • Identity operations
  • AuthX database operations

The integration layer provides a controlled boundary for handling these failures rather than allowing AuthX-specific exceptions and HTTP behavior to spread throughout the application.


16. Integration Design Principles

The DjangoPlay ↔ AuthX integration follows these principles:

Principle Description
Identity Authority AuthX owns authoritative identity information
Local Mirror DjangoPlay maintains a local identity representation
Service Boundary Communication occurs through AuthXClient
Service Authentication Internal calls use X-Service-Token
Separation of Concerns Authentication and application authorization remain separate
Application Ownership DjangoPlay owns application/domain data
Credential Isolation AuthX credentials remain within the AuthX boundary
Environment Isolation AuthX configuration varies by environment
Centralized Integration AuthX communication is not scattered across apps
Explicit Synchronization Identity changes are synchronized into DjangoPlay

17. Integration Summary

The overall relationship can be summarized as:

text
                    USER
                     │
                     ▼
              DJANGOPLAY
                     │
          Authentication Flow
                     │
                     ▼
                AuthXClient
                     │
             HTTP + Service Token
                     │
                     ▼
                  AUTHX
                     │
              Identity Service
                     │
                     ▼
             AuthX PostgreSQL

Alongside the authoritative AuthX identity, DjangoPlay maintains:

text
AuthX Identity
      │
      ▼
DjangoPlay UserIdentity
      │
      ├── Application relationships
      ├── Profiles
      ├── Permissions
      └── Domain data

The resulting architecture keeps identity centralized in AuthX while application ownership remains within DjangoPlay.

For detailed implementation documentation, refer to the DjangoPlay authentication architecture and the AuthX service documentation.