elsa-workflows / elsa-workflows/elsa-core

Elsa 3 Multitenancy — Option to Disable Tenant Validation (Allow Unregistered Tenants)

Open
#6,987 0 comments 0 reactions 0 assignees View on GitHub
triaged
Dominant language
C#
Stars
7.9k
Forks
1.5k
Avg merge
15h 22m
Merged PRs (30d)
114

Description

Currently, Elsa 3’s multitenancy system enforces that every resolved tenant must exist in the configured tenant provider (either ConfigurationTenantsProvider or StoreTenantsProvider).

In some scenarios—especially for dynamic or SaaS-style multi-tenant systems—we may want to accept arbitrary tenant IDs (for example, passed through headers or routes) without requiring that they be pre-registered in the tenant store.

However, unlike Elsa 2, there is no ValidateResolvedTenant option or equivalent mechanism in Elsa 3’s MultitenancyOptions to bypass this validation.

**Use Case:**

We are building a multi-tenant SaaS system where:

The tenant ID is sent from the client via a header (X-Tenant-Id).

Tenants are created and managed dynamically in another service.

Elsa should still load workflows and execute them in the tenant context, even if the tenant record is not yet persisted in Elsa’s tenant store.

In Elsa 2, we could disable this validation using:

options.ValidateResolvedTenant = false;

But in Elsa 3, this option no longer exists.

**Expected Behavior:**

Elsa should allow resolving and using a tenant context even when the tenant does not exist in the configured ITenantsProvider.

For example, the following configuration should not throw an exception when the tenant is not found:

elsa.UseTenants(tenants =>
{
tenants.ConfigureMultitenancy(options =>
{
options.TenantResolverPipelineBuilder.Append();
// ✅ Expected: Allow arbitrary tenants without validation
// options.ValidateResolvedTenant = false; (missing in Elsa 3)
});

});

**Actual Behavior:**

Elsa currently fails when a tenant ID is resolved but not found in the store, throwing an exception similar to:

Unable to resolve tenant from provider 'StoreTenantsProvider'.

Proposed Solution:

Add a configuration flag in MultitenancyOptions, for example:

public bool ValidateResolvedTenant { get; set; } = true;

If false, Elsa should skip tenant existence validation and continue executing workflows under the resolved tenant ID.

Environment:

Elsa version: 3.3.0

.NET version: .NET 9

Database: PostgreSQL

Multitenancy setup: StoreTenantsProvider with HeaderTenantResolver****

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.