FINERACT-2720: Scope entity-to-entity mapping results to user office hierarchy - #6197
Open
aya-abdallah-FOO wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When the All option is selected in the Office dropdown on the Entity-to-Entity Mapping screen (System → Entity to Entity Mapping), the API returns mappings across all offices
in the system, including branches the authenticated user has no access to. This violates office-level access restrictions.
Root cause:
retrieveEntityToEntityMappingstreatsfromId = 0(the "All" sentinel) as a pass-through, so the SQL returns every row regardless of the caller's officehierarchy.
Fix
When
fromId == 0and the relation'sfrom_entity_typeis1(office), a recursive CTE (WITH RECURSIVE office_descendants) scopes results to only the authenticated user'soffice and its descendants. Non-office relation types fall through to the existing query unchanged.
Testing
:fineract-provider:compileJavaand:fineract-provider:compileTestJavapass cleanFINERACT-2720