Repository navigation
fix: bind impersonation restrictions to the routed resource method (backport 2.0 #36231) - #36233
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 |
| null), | ||
| "An impersonated request must not create a bot"); | ||
| assertTrue( | ||
| denied.getMessage().contains("identity endpoint"), |
There was a problem hiding this comment.
Assertions repeat raw message strings
The added assertions pass raw strings to .contains(), including repeated uses of "identity endpoint". The Java guide requires named constants for strings used in .contains() and for repeated strings. Extract constants for these denial messages. This repository requirement must be satisfied 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!
| .filter(candidate -> candidate.getName().equals(methodName)) | ||
| .findFirst() | ||
| .orElseThrow(); | ||
| ResourceInfo resourceInfo = mock(ResourceInfo.class); |
There was a problem hiding this comment.
Unchanged locals omit required
final
The new filterBoundTo helper initializes its local variables once but omits final. The Java guide requires final on locals and parameters that do not change. Apply it here, to filter and field, and to the other new declarations where the same rule applies. This repository requirement must be satisfied 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!
|



Backport of PR #36231 to
2.0. Clean cherry-pick: the added and removed lines are the same as onmain, only one import next to the change differs.Changes
@IdentityEndpointannotation (a JAX-RS@NameBinding).ImpersonationRestrictionFilterruns only for annotated methods, and the path list is removed.UserResourceand the write methods ofBotResourceare annotated.UserResource.authorizeAdminForPrivilegedFieldsrefuses impersonated callers for privileged fields (admin, bot, roles, domains, closed teams) on POST, PUT and PATCH.docs/decisions/2026-10-26-impersonated-requests-never-reach-credentials-or-grant-privileges.mdrecords the rule.Only requests that send
X-Impersonate-Userare affected. The UI never sends it.Tests
Run on this branch:
ImpersonationRestrictionFilterTest: 3/3.BotImpersonationIT: 25/25.