Skip to content
Skills Library
Programming · Planning

multitenant

/multitenant

Architecture multitenant avec approche tiered (Shared/Dedicated Schema/DB), RBAC/ABAC, field-level encryption. Use when working with multitenant applications, tenant isolation, data segregation.

Licence
MIT
Last repository change
27.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
2
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 27.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Architecture multitenant avec approche tiered (Shared/Dedicated Schema/DB), RBAC/ABAC, field-level encryption. Use when working with multitenant applications, tenant isolation, data segregation.

Original author description

Architecture multitenant avec approche tiered (Shared/Dedicated Schema/DB), RBAC/ABAC, field-level encryption. Use when working with multitenant applications, tenant isolation, data segregation.

How it works

  1. Trois tiers d'isolation
  2. Cinq invariants non-négociables
  3. Pattern minimal — Shared schema + RLS
  4. Anti-patterns critiques
  5. RBAC / ABAC
  6. Pour aller plus loin
Original SKILL.md headings · 57 lines, 413 words
SKILL.md preview
---
name: multitenant
description: Architecture multitenant avec approche tiered (Shared/Dedicated Schema/DB), RBAC/ABAC, field-level encryption. Use when working with multitenant applications, tenant isolation, data segregation.
context: fork
  files: ["**/TenantFilter.php", "**/TenantScope.php", "**/middleware/Tenant*"]
---

# Multitenant — Quick Reference

Servir plusieurs clients (tenants) sur la même base de code avec **isolation stricte** et un coût d'infra contrôlé.

## Trois tiers d'isolation

| Tier | Isolation | Coût | Cas d'usage |
|------|-----------|------|-------------|
| **Tier 1 — Shared schema** | colonne `tenant_id` partout, filtres SQL automatiques | Faible | Startups, free / petits clients |
| **Tier 2 — Dedicated schema** | un schéma PostgreSQL par tenant | Moyen | SMB, clients exigeants |
| **Tier 3 — Dedicated DB** | une base entière par tenant | Élevé | Enterprise, compliance stricte (HDS, FedRAMP) |

**Règle de migration** : commencer Tier 1, migrer un client en Tier 2/3 quand il représente > 20 % du revenu OU exige un SLA spécifique.

## Cinq invariants non-négociables

1. **`tenant_id` propagé à chaque requête** (AsyncLocalStorage / SecurityContext / middleware).
2. **PostgreSQL Row-Level Security (RLS) activé sur TOUTES les tables.** Filet de sécurité contre un oubli applicatif.
3. **Tests d'isolation obligatoires.** Tenant A ne doit jamais lire/écrire les données de B — y compris via tri, requête nuée, agrégat.
4. **Audit trail isolé par tenant.** Pas de log multi-tenant cross-référencé sans permission explicite.
5. **Field-level encryption** sur PII / secrets sensibles (Halite PHP, Eloquent Casts, libsodium).

## Pattern minimal — Shared schema + RLS

```sql
ALTER TABLE invoices ADD COLUMN tenant_id UUID NOT NULL;
ALTER TABLE invoices ENABLE ROW LEVEL SECURITY;
CREATE POLICY tenant_isolation ON invoices
  USING (tenant_id = current_setting('app.tenant_id')::uuid);
```

```php
// Symfony — middleware qui set la variable session pour RLS
$conn->executeStatement(
    'SET LOCAL app.tenant_id = :tid',
    ['tid' => $tenantId]
);
```

## Anti-patterns critiques

- ❌ Oublier le filtre `tenant_id` dans une requête raw → fuite cross-tenant.
- ❌ Cache Redis sans préfixe tenant → données de A retournées à B.
- ❌ Job worker async qui perd le `tenant_id` → impossible de retrouver le contexte.
- ❌ Signed URLs / tokens sans `tenant_id` dans le payload → utilisable cross-tenant.
- ❌ Field encryption avec une clé unique partagée → compromission = exposition totale (préférer keys per tenant).

## RBAC / ABAC

- **RBAC** : rôles globaux (`admin`, `member`, `viewer`) suffisent pour 80 % des cas.
- **ABAC** : passer à des policies (Casbin, Cerbos, OPA) quand les règles dépendent d'attributs (région, montant, statut).

## Pour aller plus loin

> Patterns détaillés par tier, migration tier 1 → tier 2 sans downtime, tests d'isolation (Pest + tenant fixtures), RBAC/ABAC, exemples Laravel + Symfony, checklists par phase : voir `@.claude/skills/multitenant/REFERENCE.md`.
Files in this package (2)
  • REFERENCE.md 10 KB
  • SKILL.md 3 KB

Versions

RepositoryScoreLicence
This page · TheBeardedBearSAS/claude-craft100MIT
finom/vovk100MIT

Database snapshot: 13.11.2026 · package version 13456c9bb35e (SHA-256 digest of the entire package)

Downloads in the last 30 days: 1 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100orleans-multitenant
    Multitenancy for Microsoft Orleans 10 with the Orleans.Multitenant NuGet package — per-tenant grain storage and tenant separation of grain calls and streams. Use when an Orleans app needs multitenancy, tenant isolation or per-tenant storage (e.g. multi-tenant SaaS), even if the…
  • 100multitenancy
    Multi-tenant architecture patterns. Database-per-tenant, schema-per-tenant, shared-schema with tenant ID, row-level security, tenant resolution, and data isolation. USE WHEN: user mentions "multi-tenant", "multitenancy", "SaaS architecture", "tenant isolation", "row-level…
  • 90backend-multi-tenancy
    Use this skill when the user says 'multi-tenancy', 'SaaS', 'tenant isolation', 'row-level security', 'DB per tenant', 'schema per tenant', 'tenant provisioning', 'tenant migration', 'multi-tenant database', 'tenant context'. This skill implements tenant isolation strategies:…
  • 100access-control
    Design RBAC/ABAC models, Principle of Least Privilege, Identity Management. Use when: access control.
  • 100enforcer
    Guidance for Casbin.NET authorization library (Enforcer). USE FOR: access control list (ACL) enforcement, role-based access control (RBAC), attribute-based access control (ABAC), policy management, multi-tenant authorization, API endpoint protection. DO NOT USE FOR:…
  • 91convex-authz
    Add production-ready authorization (RBAC, ABAC, ReBAC) to Convex apps with O(1) permission checks. Use when implementing roles, permissions, access control, multi-tenancy, or relationship-based authorization in a Convex project. Inspired by Google Zanzibar / SpiceDB.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.