hyperlane-plugin-tenant 23.3.1

A zero-allocation multi-tenant resolution and isolation plugin for the Hyperlane framework supporting X-Tenant-Id header, Host subdomain, and path-prefix extraction, XxHash3_64 tenant registry, pluggable TenantResolver, and prebuilt 400/403/404 wire responses.
Documentation
use super::*;

/// Lifecycle status of a registered tenant.
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
pub enum TenantStatus {
    /// Tenant is active and allowed to serve traffic.
    #[default]
    Active,
    /// Tenant is suspended and receives `403 Forbidden`.
    Suspended,
}

/// Strategy used to extract a raw tenant identifier from an incoming request.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum TenantSource {
    /// Extracted from the configured HTTP request header (default `x-tenant-id`).
    Header,
    /// Extracted from the leading subdomain label before `base_domain`.
    Subdomain,
    /// Extracted from a leading path prefix segment (`/<prefix>/<tenant>/...`).
    PathPrefix,
    /// Supplied by the configured fallback default tenant.
    Default,
}

/// Resolution outcome produced by [`TenantPlugin::resolve`].
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum TenantResolution {
    /// Path is exempt from tenant enforcement.
    Exempt,
    /// Successfully resolved to an active [`TenantContext`].
    Resolved(TenantContext),
    /// Request carried no valid tenant identifier (`400 Bad Request`).
    Missing,
    /// Extracted tenant ID was not found in the registry (`404 Not Found`).
    Unknown,
    /// Extracted tenant ID is suspended (`403 Forbidden`).
    Suspended,
}