Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Multi-Tenant Role Validation and Index Modification for Unique Role Names per Tenant #783

Merged
merged 3 commits into from
Oct 16, 2024

Conversation

neozhu
Copy link
Owner

@neozhu neozhu commented Oct 15, 2024

Branch Name

feature/multi-tenant-role-validation

Pull Request Description

This pull request introduces the following changes:

  1. Custom Multi-Tenant Role Validator:

    • Added MultiTenantRoleValidator to enforce unique role names per tenant.
    • This ensures that role names cannot be duplicated within the same tenant, providing proper isolation in multi-tenant environments.
  2. Replace Default Role Validator:

    • Registered MultiTenantRoleValidator in the service collection to replace the default RoleValidator<ApplicationRole>.
    • Removed the default role validator to ensure only the custom validation logic is applied.
  3. Index Modification:

    • Modified the database index for the ApplicationRole entity to enforce a unique constraint on the combination of Name and TenantId.
    • This change ensures that the database enforces role uniqueness within each tenant, avoiding conflicts and duplications at the data layer.

These changes address the issue of role name collisions in multi-tenant scenarios and provide a consistent solution both at the application and database levels to maintain role uniqueness within each tenant.

@neozhu neozhu linked an issue Oct 15, 2024 that may be closed by this pull request
@neozhu neozhu merged commit 336f321 into main Oct 16, 2024
4 checks passed
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.

Same role name with diferent tenants
1 participant