Skip to content

Fix/multitenancy resolution issues#40

Merged
mheidari988 merged 6 commits intomainfrom
fix/multitenancy-resolution-issues
Jan 8, 2026
Merged

Fix/multitenancy resolution issues#40
mheidari988 merged 6 commits intomainfrom
fix/multitenancy-resolution-issues

Conversation

@mheidari988
Copy link
Contributor

Summary

  • Harden multitenancy resolution: preserve fallback metadata in consensus, gate optional requests on AllowAnonymous, aggregate duplicate claims for ambiguity, and clarify auto middleware ordering for header/host vs route/claim usage.

Testing

  • dotnet test
  • Other (add details):

Checklist

  • Includes docs/changelog updates if user-facing
  • Adds/updates tests
  • Keeps public API surface minimal and backward compatible (or documents breaking change)
  • PR scoped to a single concern/module where possible

Notes

  • Breaking changes? No.
  • Related issues/links: n/a

Ignore default fallback candidates during consensus unless they are the only source, and share correlation scopes between middleware and MediatR to prevent duplicate scopes.

Switch resolution strategy to scoped and add regression tests for consensus fallback and HTTP scope handling.
Bind tenant filters to the concrete DbContext for safer model caching and throw when tenant-scoped entities lack the tenant property in shared database mode.

BREAKING CHANGE: shared database setups without a TenantId property and UseShadowTenantId=false now throw during model building; add the property, enable UseShadowTenantId, or mark entities as global.
Return Default as the source when only fallback candidates are present so the resolver applies configured fallback tenant details.
Add regression coverage for fallback-only consensus.
Treat optional requirements as required when AllowAnonymous is false, while keeping RequireTenantByDefault for unannotated requests.
Update tests and clarify the option intent.
Aggregate same-type claims so the core resolver can detect ambiguous tenant candidates.
Add regression coverage for multiple claim values.
Note that auto wiring is intended for host/header resolution and manual ordering is required for route/claim and exception handling.
@mheidari988 mheidari988 self-assigned this Jan 8, 2026
@mheidari988 mheidari988 merged commit 2aebd5b into main Jan 8, 2026
3 checks passed
@mheidari988 mheidari988 deleted the fix/multitenancy-resolution-issues branch January 8, 2026 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant