This repository has been archived on 2026-04-03. You can view files and clone it, but cannot push or open issues or pull requests.
nyx/src/tenant.ts
Nico d6337c1ece Tenant-specific OIDC: separate Zitadel projects per tenant
Each tenant config now includes oidcClientId. Auth composable reads
client ID from tenant config instead of hardcoded fallback. Dev tenant
uses restricted Zitadel project (role-check enabled, developer grant).
Added NODE_ENV=production to env files to fix --mode dev builds.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-01 17:37:16 +02:00

38 lines
1.0 KiB
TypeScript

/**
* tenant.ts — Build-time tenant configuration
*
* VITE_TENANT selects which tenant config to load.
* Direct dynamic import ensures only the active tenant is bundled.
*/
export interface TenantFeatures {
graph: boolean;
trace: boolean;
viewer: boolean;
devTools: boolean;
}
export interface TenantConfig {
id: string;
name: string;
domain: string;
defaultTheme: string;
oidcClientId: string;
features: TenantFeatures;
}
// Vite replaces import.meta.env.VITE_TENANT at build time,
// making the import path a string literal → only one tenant bundled.
const modules: Record<string, { default: TenantConfig }> = import.meta.glob('../tenants/*/config.ts', { eager: true });
const tenantId = import.meta.env.VITE_TENANT || 'loop42';
const key = `../tenants/${tenantId}/config.ts`;
const mod = modules[key];
if (!mod) {
throw new Error(`Unknown tenant: ${tenantId}. Available: ${Object.keys(modules).join(', ')}`);
}
const config: TenantConfig = mod.default;
export default config;