Repository navigation
Fixes #35840: only admins can change a user's domains (backport 2.0 #35845) - #35846
Conversation
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
| // =================================================================== | ||
|
|
||
| @Test | ||
| void test_patchUser_ownDomains_forbiddenForNonAdmin(TestNamespace ns) { |
There was a problem hiding this comment.
New parameters miss required
final
The seven new tests leave ns non-final, although CLAUDE.md requires final on parameters that do not change. Add final to these new TestNamespace parameters to satisfy the repository requirement before merging.
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| HttpMethod.PATCH, | ||
| "/v1/users/" + patched.getId(), | ||
| addDomainsOp(testDomain().getEntityReference())); | ||
| admin.getHttpClient().executeForString(HttpMethod.PUT, "/v1/users", userBodyWithDomain(put)); |
There was a problem hiding this comment.
The new tests repeat "/v1/users" and "domains" as literals. CLAUDE.md requires a named constant when a string appears more than once. Reuse or define constants for these values to satisfy the repository requirement before merging.
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| } | ||
|
|
||
| @Test | ||
| void test_putUser_keepsOwnDomainButCannotClaimTeamDomain(TestNamespace ns) { |
There was a problem hiding this comment.
test_putUser_keepsOwnDomainButCannotClaimTeamDomain combines team creation, user creation, two requests, and stored-state checks in one long method. CLAUDE.md requires small, focused methods and says to aim for 15 lines or fewer. Extract the setup and request checks into named helpers before merging. The new self-signup test has the same problem.
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Code Review ✅ Approved🔴 High risk · Making domain assignments admin-only changes authorization and could deny legitimate users domain access, while blocking self-granted access to protected assets. Restricts user domain changes to admins in VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
|



Backport of PR #35845 to
2.0, for 2.0.6. The commit is a clean cherry-pick: the change is the same as onmain(identicalgit patch-id --stable), only its line numbers differ.Problem
Any user could add a domain to their own profile, with
PATCH /v1/users/{id}orPUT /v1/users, andhasDomain()then treated them as a member of that domain. With a rule such as "allowEditAllwhenhasDomain()" they could edit that domain's assets and move them into their own domain, which gets around the fix for #33420 (PR #35798 on this branch). ThroughPUTthis also worked for users with the built-inDomainOnlyAccessRole, and a non-admin allowed to edit other users could give them any domain the same way.What this PR changes
Domains join the admin-only checks
UserResourcealready applies to roles,isAdmin,isBotand closed teams:/domainsneeds an admin.What users will notice
Only admins can change a user's domains, as on
main. Every other self-edit keeps working, and the user profile page already shows the domain control to admins only.How it was tested
UserResourceITpass on this branch, on Postgres and MySQL. On untouched2.0the four that change behavior fail, on both databases.main(PR Fixes #35840: only admins can change a user's domains #35845); the code they exercise is the same here.Fixes #35840
The repository's Java style requirements still need to be satisfied before merging.
Findings
Summary
Adds admin-only checks for assigning domains to users.
Reviews (2) · Last reviewed commit: "Test that a team's domain cannot be clai..." · Reviewed by Greptile