Skip to content

Identity: store-wide unique User.Name and Application.Name/ClientId block shared-store multi-tenancy (follow-up to #282) #284

Description

@sfmskywalker

Follow-up to #282 / #281 (role stores) and elsa-workflows/elsa-core#8615. Those fix roles only. On shared-store multi-tenant hosts, the identity user and application stores still have store-wide uniqueness problems.

Mongo

Collection Index Effect
User Name_1 unique (store-wide) Two tenants can't each have a user with the same name. That includes the default seeded admin user, so the second tenant's admin seeding fails.
Application Name_1 unique (store-wide) Two tenants can't each have an application with the same display name.
Application ClientId_1 unique (store-wide) This should probably stay global. The client is resolved from the incoming credential before the tenant is known, so a ClientId lookup can't apply a tenant filter. A compound (TenantId, ClientId) index would let two tenants reuse a client id, and resolution would become ambiguous or wrong. Keep it global unless the token/API-key pipeline is changed to resolve the tenant first.

Proposed: compound unique indexes (TenantId, Name) for User and Application.Name, using the same idempotent drop-old-and-create-new migration pattern as #281. Leave the decision on ClientId open, with a store-global default.

Dapper

Users / Applications have no unique index on Name or ClientId (only the Id primary key). Same-tenant duplicates are possible, and a pre-tenant ClientId lookup only sees the ambient or default tenant's row. Consider (TenantId, Name) unique indexes, plus a decision on ClientId, through the Dapper migration mechanism, safe on existing 3.9 data.

""/null normalisation (#242)

Unique indexes that include TenantId depend on a consistent representation of the default tenant. Most databases treat NULLs as distinct in unique indexes, and "" and null are different values. Land the #242 normalisation first or together with this, or these indexes won't protect default-tenant rows.

Milestone: 3.10. Analysis is from #281's PR body.

Activity

  1. sfmskywalker commented on Oct 5, 2026

    @sfmskywalker
    MemberAuthor

    Moved to elsa-workflows/elsa-core#8617. Under the lockstep ADR, the 3.10 Dapper/Mongo stores ship from core's src/extensions, so the fix belongs there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions