Architecture Decisions (ADRs)
ADR-004: Token Authentication & Host-Derived Tenancy
Architectural pairing of server-derived HTTP Host multi-tenancy with DRF TokenAuthentication.
ADR-004: Token Authentication & Host-Derived Tenancy
- Status:
ACCEPTED - Deciders: Lead Architect
- Date: September 2026
Context
Allowing clients to declare or switch their tenant identity via custom request headers (X-Tenant-ID) or URL parameters introduces tenant spoofing vulnerabilities.
Decision
Bind tenant identity strictly to the incoming HTTP Host Header:
- Matched in
TenantResolutionMiddlewareagainst activeTenantDomainrecords. - Authenticate requests using Django REST Framework's standard
TokenAuthentication. - Verify that the authenticated staff user has an active
StaffMembershipbinding them to the resolvedrequest.tenant.
Consequences
- Positive: Impossible for an authenticated staff user to accidentally or maliciously query data from another ISP tenant.
- Negative: Local development requires
localhostfallback or editing/etc/hostsfor testing custom domains.