Skip to content

fix: bind impersonation restrictions to the routed resource method (backport 2.0 #36231) - #36233

Merged
manerow merged 2 commits into
2.0from
fix/impersonation-route-binding-2.0
Oct 26, 2026
Merged

manerow merged 2 commits into
2.0from
fix/impersonation-route-binding-2.0

Conversation

@manerow

@manerow manerow commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Backport of PR #36231 to 2.0. Clean cherry-pick: the added and removed lines are the same as on main, only one import next to the change differs.

Changes

  • New @IdentityEndpoint annotation (a JAX-RS @NameBinding). ImpersonationRestrictionFilter runs only for annotated methods, and the path list is removed.
  • The credential and session methods of UserResource and the write methods of BotResource are annotated.
  • UserResource.authorizeAdminForPrivilegedFields refuses 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.md records the rule.

Only requests that send X-Impersonate-User are affected. The UI never sends it.

Tests

Run on this branch:

  • ImpersonationRestrictionFilterTest: 3/3.
  • BotImpersonationIT: 25/25.

@manerow
manerow requested a review from a team as a code owner October 26, 2026 10:17
@manerow
manerow requested review from sonika-shah and removed request for a team October 26, 2026 10:17
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

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 skip-pr-checks label.

@github-actions github-actions Bot added backend safe to test Add this label to run secure Github workflows on PRs labels Oct 26, 2026
null),
"An impersonated request must not create a bot");
assertTrue(
denied.getMessage().contains("identity endpoint"),

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.

P2 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);

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.

P2 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!

@manerow
manerow merged commit 22d82b9 into 2.0 Oct 26, 2026
56 of 60 checks passed
@manerow
manerow deleted the fix/impersonation-route-binding-2.0 branch October 26, 2026 11:27
@sonarqubecloud

Copy link
Copy Markdown

@open-metadata open-metadata deleted a comment from gitar-bot Bot Oct 29, 2026
@open-metadata open-metadata deleted a comment from gitar-bot Bot Oct 29, 2026
@open-metadata open-metadata deleted a comment from greptile-apps Bot Oct 29, 2026

This branch was successfully deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants