Repository navigation
Description
Summary
UltimateAuth exposes configurable identifier uniqueness scopes, but the current EF Core persistence model enforces tenant-wide uniqueness unconditionally.
This creates a mismatch between the configured application-level behavior and the database-level constraints.
This issue tracks the design and implementation alignment as part of the planned v0.5.0 multi-tenant expansion.
Current Behavior
The identifier uniqueness configuration supports:
Tenant: Unique within the tenant.WithinUser: Unique within the owning user.None: No application-level uniqueness requirement.
However, EF Core currently defines the following unique index:
e.HasIndex(x => new
{
x.Tenant,
x.Type,
x.NormalizedValue
}).IsUnique();Consequently, identifiers with the same normalized value cannot coexist within a tenant, regardless of the configured uniqueness scope.
For WithinUser and None, the application layer may approve an operation that EF Core subsequently rejects.
Expected Behavior
- Configured uniqueness scopes have clearly documented and consistent semantics.
- Application services, availability checks, and persistence stores enforce compatible rules.
- InMemory and EF Core implementations provide equivalent observable behavior.
- Concurrent operations cannot violate the configured uniqueness guarantees.
- Soft-deleted identifiers follow an explicit and consistent reservation policy.
- Tenant isolation remains guaranteed independently of uniqueness configuration.
Design Considerations
Evaluate:
- Whether all existing uniqueness scopes should remain publicly supported.
- How uniqueness should be enforced at the database level for each scope.
- Whether database schema or index strategies need to vary by configuration.
- How concurrent identifier creation and modification should be handled.
- How soft-delete, hard-delete, and future restore operations interact with uniqueness.
- Whether existing deployments require a migration or compatibility strategy.
- How the design integrates with the expanded multi-tenant architecture.
Do not remove the existing unique index without establishing an equivalent enforcement strategy for tenant-wide uniqueness.
Acceptance Criteria
- Uniqueness scope semantics are finalized and documented.
- Supported scopes behave consistently across application and persistence layers.
- EF Core constraints are compatible with the supported configuration.
- InMemory behavior matches the persistence contract.
- Concurrency and duplicate-insertion scenarios are covered by tests.
- Soft-delete reservation behavior remains consistent.
- Tenant isolation is preserved.
- Migration and backward-compatibility implications are evaluated.
Activity