Guides & Recipes — MultiTenancy
Recommended recipes for trusted internal gateways and deterministic unit tests.
Recipe 1: Trusted Gateway Header Resolution
Section titled “Recipe 1: Trusted Gateway Header Resolution”Never trust raw X-Tenant-ID headers from public clients without authenticating the caller. When operating behind an internal API gateway, use AddInternalHeaderTenantResolution(expectedSharedSecret, headerName: "X-Tenant-ID", secretHeaderName: "X-Gateway-Secret") so requests lacking the shared gateway secret are rejected.
Recipe 2: Testing Multi-Tenant Services with EricksonLopez.MultiTenancy.Testing
Section titled “Recipe 2: Testing Multi-Tenant Services with EricksonLopez.MultiTenancy.Testing”Use FakeTenantStore, TenantContextBuilder, TestTenantContext, and FakeDbConnection to verify tenant-scoped queries and RLS transaction setup without spinning up external database servers.