Multi-Tenancy
Überblick
Abschnitt betitelt „Überblick“Greentic wurde von Grund auf für Multi-Tenant-Deployments entwickelt. Jeder Aspekt der Plattform unterstützt Tenant-Isolation, sodass ein einzelnes Deployment mehrere Organisationen sicher bedienen kann.
Tenant-Hierarchie
Abschnitt betitelt „Tenant-Hierarchie“Workspace└── Tenant (organization) └── Environment (prod, staging, dev) └── Team (department, group) └── Channel (messaging provider instance) └── Session (user conversation)TenantCtx
Abschnitt betitelt „TenantCtx“Die TenantCtx-Struktur fließt durch alle Operationen:
pub struct TenantCtx { pub tenant_id: String, pub env_id: String, pub team_id: Option<String>,}Jeder API-Aufruf, jede Flow-Ausführung und jeder Datenzugriff ist auf einen TenantCtx begrenzt.
Konfiguration
Abschnitt betitelt „Konfiguration“Tenant-Definition
Abschnitt betitelt „Tenant-Definition“tenant: id: acme name: "ACME Corporation" settings: timezone: "America/New_York" language: "en-US"
environments: - id: prod name: "Production" - id: staging name: "Staging"Team-Definition
Abschnitt betitelt „Team-Definition“team: id: support name: "Customer Support" tenant_id: acme
channels: slack: provider: messaging-slack config: workspace_id: "T123456" channel_id: "C789012"
telegram: provider: messaging-telegram config: chat_id: "-1001234567890"Bundle-Konfiguration
Abschnitt betitelt „Bundle-Konfiguration“tenants: acme: name: "ACME Corporation" teams: support: name: "Customer Support" channels: slack: provider: messaging-slack telegram: provider: messaging-telegram
sales: name: "Sales Team" channels: teams: provider: messaging-teams
bigcorp: name: "BigCorp Inc." teams: helpdesk: channels: webchat: provider: messaging-webchatDatenisolation
Abschnitt betitelt „Datenisolation“Session-Speicherung
Abschnitt betitelt „Session-Speicherung“Sessions werden nach Tenant-Kontext isoliert:
sessions/├── acme/│ ├── prod/│ │ ├── support/│ │ │ ├── session_001.cbor│ │ │ └── session_002.cbor│ │ └── sales/│ │ └── session_003.cbor│ └── staging/│ └── support/│ └── session_004.cbor└── bigcorp/ └── prod/ └── helpdesk/ └── session_005.cborZustandsisolation
Abschnitt betitelt „Zustandsisolation“Der Arbeitszustand (state) wird pro Session abgegrenzt:
// State key formatlet key = format!( "state:{}:{}:{}:{}", tenant_ctx.tenant_id, tenant_ctx.env_id, tenant_ctx.team_id.unwrap_or("default"), session_id);NATS-Subject-Isolation
Abschnitt betitelt „NATS-Subject-Isolation“Das Nachrichtenrouting verwendet tenant-spezifische Subjects:
greentic.messaging.ingress.{env}.{tenant}.{team}.{channel} │ │ │ │ │ │ │ └─ Channel ID (slack, telegram) │ │ └──────── Team ID │ └─────────────── Tenant ID └────────────────────── Environment (prod, staging)Secret-Isolation
Abschnitt betitelt „Secret-Isolation“Secrets werden tenant-spezifisch gespeichert und abgerufen:
// Secret retrieval includes tenant contextlet secret = secrets_client .get_secret(&tenant_ctx, "api_key") .await?;Secret-Namensräume
Abschnitt betitelt „Secret-Namensräume“secrets/├── global/ # Platform-wide secrets│ └── signing_key├── acme/ # Tenant: ACME│ ├── slack_bot_token│ ├── openai_api_key│ └── teams/│ └── support/│ └── webhook_secret└── bigcorp/ # Tenant: BigCorp └── telegram_bot_tokenFlow-Isolation
Abschnitt betitelt „Flow-Isolation“Jeder Tenant kann unterschiedliche Flows und Konfigurationen haben:
name: acme_support_flowversion: "1.0"
# ACME-specific support flownodes: - id: greet type: reply config: message: "Welcome to ACME Support! How can I help?"name: bigcorp_helpdesk_flowversion: "1.0"
# BigCorp-specific helpdesk flownodes: - id: greet type: reply config: message: "BigCorp Helpdesk here. What's your issue?"Zugriffskontrolle
Abschnitt betitelt „Zugriffskontrolle“Komponenten-Zugriff
Abschnitt betitelt „Komponenten-Zugriff“Komponenten erhalten TenantCtx und müssen Grenzen respektieren:
impl Guest for MyComponent { fn process(input: Input, ctx: &TenantCtx) -> Output { // Verify tenant has access to requested resource if !has_permission(ctx, &input.resource_id) { return Output::error("Access denied"); }
// Process with tenant scope process_for_tenant(ctx, input) }}API-Zugriff
Abschnitt betitelt „API-Zugriff“Die REST-API erzwingt Tenant-Grenzen:
GET /api/v1/sessionsAuthorization: Bearer <token>X-Tenant-ID: acmeX-Team-ID: supportDeployment-Modelle
Abschnitt betitelt „Deployment-Modelle“Single-Tenant
Abschnitt betitelt „Single-Tenant“Eine Greentic-Instanz pro Tenant:
┌─────────────────┐│ Greentic (ACME) │└─────────────────┘
┌─────────────────┐│ Greentic (BigCorp)│└─────────────────┘Gemeinsam genutzte Multi-Tenant-Umgebung
Abschnitt betitelt „Gemeinsam genutzte Multi-Tenant-Umgebung“Mehrere Tenants auf gemeinsamer Infrastruktur:
┌───────────────────────────────────┐│ Greentic Instance ││ ┌─────────┐ ┌─────────────────┐││ │ ACME │ │ BigCorp │││ │ (prod) │ │ (prod) │││ └─────────┘ └─────────────────┘││ ┌─────────┐ ┌─────────────────┐││ │ ACME │ │ BigCorp │││ │(staging)│ │ (staging) │││ └─────────┘ └─────────────────┘│└───────────────────────────────────┘Mischung aus dedizierten und gemeinsam genutzten Ressourcen:
┌───────────────────────────────────┐│ Shared Greentic Instance ││ ┌─────────┐ ┌─────────────────┐││ │ Small │ │ Medium │││ │ Tenants │ │ Tenants │││ └─────────┘ └─────────────────┘│└───────────────────────────────────┘
┌───────────────────────────────────┐│ Dedicated: Enterprise Tenant ││ (Custom SLA, dedicated resources)│└───────────────────────────────────┘Best Practices
Abschnitt betitelt „Best Practices“- TenantCtx immer weitergeben - Tenant-IDs niemals hartkodieren
- An den Grenzen validieren - Tenant-Zugriff auf API- und Komponentenebene prüfen
- Tenant-spezifisches Logging verwenden - Tenant-ID in alle Logeinträge aufnehmen
- Secrets trennen - Secrets niemals zwischen Tenants teilen
- Isolation testen - Prüfen, dass ein Tenant nicht auf die Daten eines anderen zugreifen kann
- Pro Tenant überwachen - Nutzung und Fehler pro Tenant verfolgen