Skip to content

[Backport 4.2.x] Users API / Align the checks on what a user administrator may change (#9449) - #9450

Open
juanluisrp wants to merge 10 commits into
geonetwork:4.2.xfrom
GeoCat:fix/user-update-identifier-4.2.x
Open

[Backport 4.2.x] Users API / Align the checks on what a user administrator may change (#9449)#9450
juanluisrp wants to merge 10 commits into
geonetwork:4.2.xfrom
GeoCat:fix/user-update-identifier-4.2.x

Conversation

@juanluisrp

@juanluisrp juanluisrp commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Backport of #9449 to 4.2.x.

updateUser mutated the record named by the path variable but read
userDto.getId() from the request body in places. Reject a body whose
identifier differs from the path, and use the path variable for the group
lookup.

(cherry picked from commit 08ef65c)
createUser and updateUser applied the group lists from the request body
without checking that the caller administers those groups. Check each
requested group in both endpoints, and split the update path into
administrator, self update and useradmin cases.

(cherry picked from commit 72dae43)
The check read the identifier and the enabled flag from the request body, and
ran only when the submitted profile was Administrator, so it missed demotions.
Base it on the stored record instead. Drop the call in createUser, where it
could never fire.

(cherry picked from commit aa04623)
getNonExistingUser and deleteNonExistingUser hardcode 222 as an identifier
that no user holds. The generator is not reset between tests in a class, so
the assumption breaks as soon as enough users are created. Use
Integer.MAX_VALUE instead.

(cherry picked from commit a907797)
…quest

updateUser validated the submitted values, and ran the last administrator
check, before working out whether the caller may act on the record at all.
A useradmin therefore got different answers for a record they administer, a
record they do not, and an identifier nobody holds.

Move the check on the groups in common ahead of that validation, and refuse
records whose stored profile is Administrator: a useradmin administers the
members of their groups, not the administrators that happen to share one.
getUsers already leaves administrators out of the list it returns them.

Keep the group lookups from that check for the group merge further down
rather than repeating them.

(cherry picked from commit 7388863)
deleteUser let a useradmin remove any user sharing one of their groups,
including an administrator. Refuse those records here too, reusing the
message of the group check so the answer does not depend on the profile of
the record.

(cherry picked from commit 82dd511)
The user form let a useradmin save or delete a record whose profile is
Administrator. Such a record is not reachable from the list they get, but
nothing in the form itself said so. Add isUserEditable and use it to disable
the save button and hide the delete button in that case.

(cherry picked from commit 9553d41)
The four processGroups calls appeared three times and the check on the groups
the caller administers twice. Move both into helpers. Drop the parameters
checkIfAtLeastOneAdminIsEnabled can read from the record or the field, and
compare the group assignments of updateOwnAccountKeepsGroupAssignments as
sets, findGroupIds having no defined order.

(cherry picked from commit 0d179c3)
deleteUser compared every group the caller belongs to with the groups of the
record, so a useradmin could remove a user sharing a group they are only an
editor of. updateUser looks at the groups where the caller holds the
UserAdmin profile; use the same set here.

(cherry picked from commit fc891c2)
The profile description repeated "their own groups" without defining it, which
reads as any group the user belongs to. Say that it means the groups where they
have the User Administrator role, and list what they can do there.

(cherry picked from commit 6f7ea57)
@juanluisrp juanluisrp added this to the 4.2.18 milestone Jul 27, 2026
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