Skip to content

[2.0] fix(mcp): mcp claims mapping parser - #36213

Merged
Vishnuujain merged 1 commit into
2.0from
backport/2.0/pr-36171
Oct 26, 2026
Merged

Vishnuujain merged 1 commit into
2.0from
backport/2.0/pr-36171

Conversation

@gh-bot-collate

@gh-bot-collate gh-bot-collate Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Automated backport of #36171 to 2.0.

Source PR #36171
Author @Vishnuujain
Merge commit e9d0281149a7cd22276d5783596d69549f9c9891
Method Conflicts resolved by Claude — worth a read of the diff.

Resolution notes

Backport notes: PR #36171 → 2.0

Summary

Backports the colon-safe JWT principal claims mapping parser fix from
McpCallbackServlet.getClaimsMapping() (uses SecurityUtil.buildPrincipalClaimsMapping
instead of a naive String.split(":"), which previously silently dropped any
claim pair whose source claim name itself contains a colon, e.g.
username:custom:login).

Conflicts and resolution

  • McpCallbackServlet.java — applied cleanly via cherry-pick, no conflict.
    SecurityUtil.buildPrincipalClaimsMapping already exists on 2.0.

  • McpCallbackServletTest.java — conflicted. The 2.0 test file is
    significantly smaller than the version on main, which already contained
    several unrelated tests (doGet_idpErrorCallback_*,
    bufferedResponseSendRedirect_records302Status, and their supporting
    fixtures samplePendingRequest(), makeServletWithCapturedHandler(),
    mockCallbackRequest()) added by other PRs never backported to 2.0. Those
    tests reference types/helpers not present on 2.0
    (OAuthRecords.McpPendingAuthRequest, Mockito.never(),
    ArgumentMatchers.any()/eq(), Assertions.assertEquals, a getStatusCode()
    helper) and are out of scope for this backport.

    Resolution: kept only what PR fix(mcp): mcp claims mapping parser #36171 actually added — the single test
    getClaimsMapping_keepsClaimNamesThatContainAColon() and its reflection
    helper invokeGetClaimsMapping() (the latter merged cleanly without
    conflict) — and pruned the unrelated main-only tests/fixtures from the
    conflict hunk. Trimmed imports to match: kept mockStatic,
    findEmailFromClaims, findUserNameFromClaims, MockedStatic,
    AuthenticationConfiguration, SecurityConfigurationManager, List,
    Map; dropped never, OAuthRecords.McpPendingAuthRequest, any, eq,
    assertEquals since nothing remaining in the 2.0 file needs them.

What to check by hand

  • Confirm no other PR intentionally backported those doGet_idpErrorCallback_*
    tests separately — if one is in flight, re-verify there's no duplicate test
    name collision.
  • Run mvn test -pl openmetadata-mcp -Dtest=McpCallbackServletTest once staged.

Opened from openmetadata-collate, which holds the credentials needed to open a PR here. It merges itself once this branch's required checks pass — no review needed. If a check fails it stays open and the author of #36171 is asked to look.

resolver run

RetriggerView in GreptileConfidence Score: 4/5

Do not merge until the shared parser fix is included and the new test code meets the repository requirements.

Findings

  1. P1 Colon claim names still fail ▶
  2. P2 Helper variable breaks naming rule ▶
  3. P2 New declarations omit required final ▶

Summary

Routes MCP claim mapping through SecurityUtil.buildPrincipalClaimsMapping and adds a regression test for claim names containing colons.

  • MCP sign-in reads configured identity claims through the shared parser.

Reviews (1) · Last reviewed commit: "fix(mcp): mcp claims mapping parser (#36..." · Reviewed by Greptile

@gh-bot-collate gh-bot-collate Bot added the safe to test Add this label to run secure Github workflows on PRs label Oct 26, 2026
@gh-bot-collate
gh-bot-collate Bot enabled auto-merge (squash) October 26, 2026 08:13
@gh-bot-collate gh-bot-collate Bot mentioned this pull request Oct 26, 2026
7 tasks done
}
}
return mapping;
return buildPrincipalClaimsMapping(authConfig.getJwtPrincipalClaimsMapping());

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.

P1 Colon claim names still fail

buildPrincipalClaimsMapping is not colon-safe on 2.0. It still uses split(":") and drops entries with more than two parts. Both mappings in the new test therefore disappear, so the username becomes jdoe instead of employee42 and the test fails. Backport the shared parser change to split only at the first colon.

@SuppressWarnings("unchecked")
private static Map<String, String> invokeGetClaimsMapping(McpCallbackServlet servlet)
throws Exception {
Method m = McpCallbackServlet.class.getDeclaredMethod("getClaimsMapping");

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 Helper variable breaks naming rule

The new reflection helper names its method variable m. The repository guide forbids single-letter variables outside short lambdas and loop indices. Rename it to claimsMappingMethod before merging to meet that requirement.

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!

Comment on lines +308 to +311
AuthenticationConfiguration authConfig =
new AuthenticationConfiguration()
.withJwtPrincipalClaimsMapping(List.of("username:custom:login", "email:custom:mail"));
Map<String, Object> claims =

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 New declarations omit required final

The new test and helper omit final from variables and parameters that never change. The repository guide requires final in these cases. Apply it to the new declarations, including authConfig, claims, and the helper parameter, 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!

@Vishnuujain
Vishnuujain disabled auto-merge October 26, 2026 09:27
@Vishnuujain
Vishnuujain merged commit e371349 into 2.0 Oct 26, 2026
94 of 110 checks passed
@Vishnuujain
Vishnuujain deleted the backport/2.0/pr-36171 branch October 26, 2026 09:27

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

1 participant