Skip to content

chore: Refactor ACL validation of single events [DHIS2-20158]#23752

Merged
muilpp merged 5 commits into
masterfrom
DHIS2-20158-single-events
May 11, 2026
Merged

chore: Refactor ACL validation of single events [DHIS2-20158]#23752
muilpp merged 5 commits into
masterfrom
DHIS2-20158-single-events

Conversation

@muilpp

@muilpp muilpp commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

Refactors SecuritySingleEventValidator to delegate all access checks to TrackerAccessManager, splits uncomplete event handling into a dedicated CompletedSingleEventValidator, mirroring the existing CompletedTrackerEventValidator.

The old canCreate(SingleEvent) only checked program and category option write access, it did not perform any org unit unit check. That particular check was previously handled in SecuritySingleEventValidator, but not in TrackerAccessManager. This is now handled in the new validateSingleEventAccess method.

It also migrates the SingleEvent access manager methods from List<String> to List<ErrorMessage> to align with other entity types.

Next and last is relationships.

@muilpp
muilpp marked this pull request as ready for review April 27, 2026 14:41
@muilpp
muilpp requested a review from a team as a code owner April 27, 2026 14:41
org.hisp.dhis.tracker.model.SingleEvent databaseSingleEvent =
bundle.getPreheat().getSingleEvent(singleEvent.getUID());
CategoryOptionCombo aoc =
bundle.getPreheat().getCategoryOptionCombo(singleEvent.getAttributeOptionCombo());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We cannot assume (and we shouldn't) that a payload for delete has no attributeOptionCombo defined.
I think this logic of replacing the attributeOptionCombo only applies to update strategy.
This is working in most cases but I found it confusing. canDelete in TrackerAccessManager doesn't need to check attributeOptionCombo write access and indeed it doesn't happen but only because it was null in the payload.

It is actually an issue if the client send a payload for delete and it includes the attributeOptionCombo . In this case attributeOptionCombo is going to be validated and is not passing any other validation, so it could be not accesssible for the user.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should double check this also on tracker event validator

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Right, I’ll ignore the payload AOC for deletions, but we still need to validate access to it. A user’s access may change between the time the event was created and when they try to delete it.

Tracker events and enrollments I'll do in a different PR.

@sonarqubecloud

sonarqubecloud Bot commented May 6, 2026

Copy link
Copy Markdown

@enricocolasante enricocolasante left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We will need to re-check tracker event logic for AOC and maybe even enrollments

@muilpp

muilpp commented May 7, 2026

Copy link
Copy Markdown
Contributor Author

We will need to re-check tracker event logic for AOC and maybe even enrollments

this is done here

@muilpp
muilpp requested a review from a team May 11, 2026 06:42
@muilpp
muilpp merged commit d24bbc8 into master May 11, 2026
18 checks passed
@muilpp
muilpp deleted the DHIS2-20158-single-events branch May 11, 2026 08:31
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.

3 participants