Skip to content

Validate parent organization unit tenant on create and move#25357

Merged
EngincanV merged 5 commits intorel-10.3from
maliming/validate-organization-unit-parent-tenant
May 4, 2026
Merged

Validate parent organization unit tenant on create and move#25357
EngincanV merged 5 commits intorel-10.3from
maliming/validate-organization-unit-parent-tenant

Conversation

@maliming
Copy link
Copy Markdown
Member

@maliming maliming commented May 2, 2026

OrganizationUnitManager.CreateAsync and MoveAsync accepted any parentId without checking that the parent belongs to the same tenant as the OU being created or moved. From a tenant context, calling the API with a parentId from another tenant succeeded and stored a cross-tenant ParentId reference in the database (Code was calculated as a top-level code because the multi-tenant filter hid the parent during lookup, but the FK column itself crossed tenant boundaries).

The manager now validates the parent's TenantId before create and move and throws Volo.Abp.Identity:010010 (OrganizationUnitParentTenantMismatch) when they don't match.

Copilot AI review requested due to automatic review settings May 2, 2026 07:52
@maliming maliming added this to the 10.3-patch milestone May 2, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens the Identity module's organization-unit domain logic by validating that a parent organization unit belongs to the same tenant during create and move operations, preventing cross-tenant ParentId references from being persisted.

Changes:

  • Adds parent-tenant validation to OrganizationUnitManager.CreateAsync and MoveAsync.
  • Introduces a new Identity error code for parent-tenant mismatches.
  • Adds domain tests and localization entries for the new validation error.

Reviewed changes

Copilot reviewed 30 out of 30 changed files in this pull request and generated 26 comments.

Show a summary per file
File Description
modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/OrganizationUnitManager_Tests.cs Adds tests for rejecting cross-tenant parents during create and move.
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/OrganizationUnitManager.cs Enforces parent tenant validation before assigning codes and persisting moves.
modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/zh-Hant.json Adds the new localized error string in Traditional Chinese.
modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/zh-Hans.json Adds the new localized error string in Simplified Chinese.
modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/vi.json Adds the new error string entry for Vietnamese localization.
modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/tr.json Adds the new error string entry for Turkish localization.
modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/sv.json Adds the new error string entry for Swedish localization.
modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/sl.json Adds the new error string entry for Slovenian localization.
modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/sk.json Adds the new error string entry for Slovak localization.
modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/ru.json Adds the new error string entry for Russian localization.
modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/ro-RO.json Adds the new error string entry for Romanian localization.
modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/pt-BR.json Adds the new error string entry for Brazilian Portuguese localization.
modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/pl-PL.json Adds the new error string entry for Polish localization.
modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/nl.json Adds the new error string entry for Dutch localization.
modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/it.json Adds the new error string entry for Italian localization.
modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/is.json Adds the new error string entry for Icelandic localization.
modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/hu.json Adds the new error string entry for Hungarian localization.
modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/hr.json Adds the new error string entry for Croatian localization.
modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/hi.json Adds the new error string entry for Hindi localization.
modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/fr.json Adds the new error string entry for French localization.
modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/fi.json Adds the new error string entry for Finnish localization.
modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/fa.json Adds the new error string entry for Persian localization.
modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/es.json Adds the new error string entry for Spanish localization.
modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/en.json Adds the base English error message for the new error code.
modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/en-GB.json Adds the UK English error message override for the new error code.
modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/el.json Adds the new error string entry for Greek localization.
modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/de.json Adds the new error string entry for German localization.
modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/cs.json Adds the new error string entry for Czech localization.
modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/ar.json Adds the new error string entry for Arabic localization.
modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityErrorCodes.cs Defines the new OrganizationUnitParentTenantMismatch error code constant.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 30 out of 30 changed files in this pull request and generated 1 comment.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 30 out of 30 changed files in this pull request and generated 6 comments.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 30 out of 30 changed files in this pull request and generated 4 comments.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 2, 2026

Codecov Report

❌ Patch coverage is 22.00000% with 39 lines in your changes missing coverage. Please review.
✅ Project coverage is 49.77%. Comparing base (b809229) to head (9456694).
⚠️ Report is 18 commits behind head on rel-10.3.

Files with missing lines Patch % Lines
...Volo/Abp/Identity/OrganizationUnitManager_Tests.cs 0.00% 38 Missing ⚠️
...omain/Volo/Abp/Identity/OrganizationUnitManager.cs 91.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           rel-10.3   #25357      +/-   ##
============================================
+ Coverage     49.30%   49.77%   +0.47%     
============================================
  Files          3667     3609      -58     
  Lines        123121   120708    -2413     
  Branches       9404     9218     -186     
============================================
- Hits          60707    60085     -622     
+ Misses        60590    58826    -1764     
+ Partials       1824     1797      -27     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@maliming maliming requested a review from EngincanV May 4, 2026 05:54
@EngincanV EngincanV merged commit d6c5fc7 into rel-10.3 May 4, 2026
3 of 4 checks passed
@EngincanV EngincanV deleted the maliming/validate-organization-unit-parent-tenant branch May 4, 2026 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants