ข้ามไปยังเนื้อหา

Multi-tenancy

เนื้อหานี้ยังไม่ได้แปลเป็นภาษาไทย แสดงเป็นภาษาอังกฤษแทน

CephalonEngine treats multi-tenancy as a first-class capability — not a sidecar. The Cephalon.MultiTenancy family covers everything from resolution to durable governance.

PackageMaturityWhat it brings
Cephalon.MultiTenancyM2Tenancy primitives — ITenantContext, ITenantResolver, resolution policy, ambient context middleware.
Cephalon.MultiTenancy.GovernanceM2Durable tenant-membership, tenant-invitation, declared domain ownership, approval/remediation action decision, in-process workflow, opt-in durable membership/invitation/domain/action-store.

The governance flow can deliver invitations and remediation messages through pluggable providers:

PackageMaturity
Cephalon.MultiTenancy.Governance.SmtpDeliveryM2
Cephalon.MultiTenancy.Governance.SendGridDeliveryM2
Cephalon.MultiTenancy.Governance.SendGridDelivery.AspNetCoreM2
Cephalon.MultiTenancy.Governance.AmazonSesDeliveryM2
Cephalon.MultiTenancy.Governance.AmazonSesDelivery.AspNetCoreM2
Cephalon.MultiTenancy.Governance.MailgunDeliveryM2
Cephalon.MultiTenancy.Governance.MailgunDelivery.AspNetCoreM2
Cephalon.MultiTenancy.Governance.MicrosoftGraphDeliveryM2
Cephalon.MultiTenancy.Governance.MicrosoftGraphDelivery.AzureIdentityM2
Cephalon.MultiTenancy.Governance.HttpDeliveryM2
builder.Services
.AddCephalonAspNetCore()
.AddMultiTenancy(options =>
{
options.Resolvers.UseSubdomain();
options.Resolvers.UseHeader("X-Tenant");
options.Resolvers.UseClaim("tenant_id");
})
.AddTenantGovernance(options =>
{
options.UseEntityFramework<TenantGovernanceDbContext>();
options.EmailDelivery.UseSendGrid();
})
.AddModulesFromAssemblies(/* ... */);

A common pattern is to inject the tenant context into the DbContextOptions so EF Core can apply row-level filters automatically:

services.AddCephalonEntityFramework<AppDbContext>((sp, options) =>
{
var tenant = sp.GetRequiredService<ITenantContext>();
options.UseNpgsql(conn);
options.AddInterceptor(new TenantRlsInterceptor(tenant));
});