Skip to content

fix(mcp): pick the sso user the same way as the web login - #36860

Merged
Vishnuujain merged 1 commit into
mainfrom
mcp-sso-email-user
Nov 3, 2026
Merged

Vishnuujain merged 1 commit into
mainfrom
mcp-sso-email-user

Conversation

@Vishnuujain

@Vishnuujain Vishnuujain commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes:

  • With emailClaim set, the MCP SSO callback worked out the user a second time with the legacy claim rules (the part of the email before the @), so the MCP login and the web login could resolve the same person to different users.
  • /mcp/callback now resolves the identity with the web login's own resolveOidcIdentity, and in the email-first flow takes the account that owns the email (UserUtil.resolveUserNameForEmail), as the SAML MCP bridge already does.

Type of change:

  • Bug fix

Tests:

Unit tests

  • McpCallbackServletTest: an email-first login hands the account that owns the email to the MCP flow; fails before this change (it passes the email's local part). The legacy-flow test now runs through the real resolver.

Backend integration tests

Local Java test run: FAILED

  • Commit: d1e09fda34a1 (base origin/main)
  • Finished: 2026-11-02 14:26 UTC · 20.0 min
  • Details: the classes each step ran, why these tests, the commands
Step Scope Classes Tests Failed Skipped Min Result
unit openmetadata-mcp (1 class), openmetadata-service (5 classes) 6 222 0 0 2.0 passed
integration mysql-elasticsearch · parallel 94 3375 1 277 4.6 FAILED
integration mysql-elasticsearch · isolated 14 105 0 2 4.6 passed
integration mysql-elasticsearch · rdf 4 61 0 0 5.0 passed
integration cache-tests · isolated 3 14 0 0 3.8 passed

Failed: RoleResourceIT#test_listRolesWithPoliciesField(TestNamespace)

Selected but produced no report: CredentialAuthBenchIT (mysql-elasticsearch · parallel), CredentialMemoryIT (mysql-elasticsearch · parallel), CredentialPatBurstIT (mysql-elasticsearch · parallel), CredentialSweepCostIT (mysql-elasticsearch · parallel)

  • Impacted, not run locally: 2 classes (listed in the details)

@gitar-bot

gitar-bot Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Code Review ✅ Approved

🔴 High risk · Changing MCP SSO account resolution to use the email-owning user could give a session another account’s privileges if identity matching is wrong.

Fixes the MCP SSO callback so it resolves the user with the same logic as the web login, taking the account that owns the email when email-first login is enabled. No issues found.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@Vishnuujain

Vishnuujain commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor Author

Local Java test run: FAILED — details

  • Commit: d1e09fda34a1 (base origin/main)
  • The summary is in the PR description.

Failed: RoleResourceIT#test_listRolesWithPoliciesField(TestNamespace)

Selected but produced no report: CredentialAuthBenchIT (mysql-elasticsearch · parallel), CredentialMemoryIT (mysql-elasticsearch · parallel), CredentialPatBurstIT (mysql-elasticsearch · parallel), CredentialSweepCostIT (mysql-elasticsearch · parallel)

Tests run locally

  • unit · openmetadata-mcp (1 class), openmetadata-service (5 classes): AuthCallbackServletTest (5 passed), AuthenticationCodeFlowHandlerTest (91 passed), ConcurrentFirstOidcLoginTest (5 passed), JwtFilterTest (100 passed), McpCallbackServletTest (12 passed), SsoRedirectBoundaryTest (9 passed)
  • integration · mysql-elasticsearch · parallel: 94 classes, 3098 tests executed (listed below)
  • integration · mysql-elasticsearch · isolated: ContextMemoryDerivationIT (5 passed), ContextMemoryExtractionIT (5 passed), ConversationSchemaMigrationIT (2 passed), CredentialDatabaseOutageIT (2 passed), CredentialRevocationTwoProcessIT (7 passed, 2 skipped), OpsRegenerateBotTokensIT (1 passed), RevokeWaitForPropagationIT (1 passed), SessionMultiNodeIT (11 passed), SsoOidcCallbackHardeningIT (6 passed), SsoOidcConfidentialLoginIT (14 passed), SsoOidcProviderProfilesIT (14 passed), SsoOidcPublicBearerIT (13 passed), SsoTokenRenewalIT (15 passed), UserMetricsResourceIT (7 passed)
  • integration · mysql-elasticsearch · rdf: AgentSparqlResourceIT (22 passed), RdfFusekiAuthorizationIT (13 passed), RdfMcpKnowledgeGraphIT (21 passed), RdfPolicyRevocationIT (5 passed)
  • integration · cache-tests · isolated: CredentialRedisDownIT (4 passed), CredentialRedisNoRoundTripIT (2 passed), SessionRedisMultiNodeIT (8 passed)

Per-class counts come from the test reports, which can credit a test to the wrong class when classes run concurrently, and keep only the last run of a nested class that several test classes inherit. The summary's step totals are Maven's own counts.

integration · mysql-elasticsearch · parallel: 95 classes

AIApplicationResourceIT (76 passed, 7 skipped), AIContextKnowledgeAuthorizationIT (27 passed), AIContextMcpIT (62 passed, 2 skipped), AIContextRestIT (8 passed), AIFrameworkControlResourceIT (3 passed), AIGovernancePolicyResourceIT (35 passed), AdminOnlyEndpointsIT (22 passed, 1 failed), AgentExecutionResourceIT (20 passed, 5 skipped), AppOperationPermissionsIT (10 passed), AssetsTabAuthorizationIT (36 passed, 5 skipped), BaseEntityIT$ListEntityHistoryByTimestampPaginationTest (80 passed, 11 skipped), BotImpersonationIT (34 passed, 7 skipped), BotResourceIT (7 passed), BulkOperationPermissionsIT (9 passed), ConceptContextIT (15 passed), ConfigResourceIT (13 passed), ContextFileIT (192 passed, 25 skipped), ContextMemoryAnchorIT (49 passed, 3 skipped), ContextMemoryConflictReviewIT (72 passed, 8 skipped), ContextMemoryCreateGrantIT (4 passed), ContextMemoryIT (50 passed, 5 skipped), ContextMemoryLifecycleIT (5 passed), ContextMemoryQueryEvidenceIT (8 passed), ContextMemoryRelatedEntitiesReconcileIT (2 passed), ContextMemorySearchMatrixIT (110 passed, 23 skipped), ContextMemorySourceEntityTiebreakIT (7 passed), ContextMemoryStatusMigrationIT (1 passed), ContextMemoryWriteAccessIT (42 passed, 3 skipped), ConversationResourceIT (1 passed), CredentialHotPathNoIoIT (2 passed), CredentialIndexMigrationIT (2 passed), CredentialMcpRevocationIT (2 passed), CredentialOutOfBandRevocationIT (45 passed, 4 skipped), CredentialRedisCommandStatsIT (2 passed), CredentialScaleHelpersTest (4 passed), CredentialSourceDaoIT (4 passed), CredentialTwoVerifierConvergenceIT (9 passed, 1 skipped), DataContractPermissionIT (4 passed), DatabaseSmokeIT (14 passed, 1 skipped), DomainIsolationIT (12 passed), DomainMoveApprovalAuthorizationIT (2 passed), DomainReassignmentAuthorizationIT (21 passed, 1 skipped), EmailFirstIdentityIT (21 passed), FeedAccessAuthzIT (42 passed), GlossaryTermRelationSettingsPermissionsIT (15 passed, 1 skipped), GlossaryTermResourceIT (42 passed, 5 skipped), IndependentOntologyAuthorizationIT (1 passed), IngestionPipelineAgentTypeIT (63 passed, 4 skipped), LLMModelResourceIT (76 passed, 11 skipped), LLMServiceResourceIT (33 passed, 5 skipped), LoginLockoutIT (1 passed), McpContextMemoryPrincipalIdentityIT (14 passed), McpContextMemoryVisibilityIT (12 passed), McpExecutionResourceIT (42 passed), McpGrantMigrationIT (1 passed), McpIntegrationIT (2 passed), McpOAuthIT (6 passed), McpPermissionIT (18 passed), McpRdfNotEnabledIT (13 passed, 2 skipped), McpSearchIT (16 passed), McpServerResourceIT (176 passed, 20 skipped), McpServiceResourceIT (51 passed, 7 skipped), McpToolsValidationIT (22 passed), McpUserContextIT (9 passed), MetricAssetsIT (1 passed), OAuth2TokenManagerIT (9 passed), OntologyAiResourceIT (3 passed), PermissionsResourceIT (142 passed, 16 skipped), PersonaAIContextIT (52 passed, 1 skipped), PipelineStatusAuthorizationIT (17 passed), PolicyResourceIT (33 passed, 6 skipped), PolicyRevocationConcurrencyIT (6 passed), PromptTemplateResourceIT (43 passed, 1 skipped), ProviderRoleSyncIT (55 passed, 11 skipped), QueryVisibilityPolicyIT (15 passed), RoleResourceIT (48 passed, 6 skipped), SamlSecurityConfigIT (9 passed), SecurityServiceResourceIT (17 passed, 1 skipped), SeedDataPresenceIT (1 passed), ServiceAttributePolicyIT (98 passed, 5 skipped), SlackOAuth2AtRestEncryptionIT (1 passed), SubResourceAuthorizationIT (25 passed, 1 skipped), TableResourceIT (140 passed, 3 skipped), TaskPermissionsIT (6 passed, 1 skipped), TestCaseCreateOrUpdateAuthorizationIT (30 passed, 1 skipped), TestCaseCsvDomainIsolationIT (6 passed, 1 skipped), TestCaseResultAuthorizationIT (2 passed), TestLoginSessionSweepIT (11 passed), UserDefaultTeamAssignmentIT (1 passed), UserImportPrivilegeEscalationIT (50 passed, 6 skipped), UserPreferencesIT (26 passed, 5 skipped), UserResourceIT (79 passed, 13 skipped), UserSecretsIT (20 passed, 1 skipped), UserTeamAssignmentPrivilegeIT (12 passed), WorkflowTriggerPermissionsIT (192 passed, 20 skipped)

Why these tests
  • area ai-mcp-context ← openmetadata-mcp/src/main/java/org/openmetadata/mcp/server/auth/handlers/McpCallbackServlet.java, openmetadata-mcp/src/test/java/org/openmetadata/mcp/server/auth/handlers/McpCallbackServletTest.java
  • area security ← openmetadata-service/src/main/java/org/openmetadata/service/security/AuthenticationCodeFlowHandler.java
  • changed test ← openmetadata-mcp/src/test/java/org/openmetadata/mcp/server/auth/handlers/McpCallbackServletTest.java
  • smoke ← code other than a test class changed
Impacted, not run locally (2)
  • GoogleSsoSignInUIIT → nightly: openmetadata-nightly k8s-java-it (ui-it + embedded JavaUIIT)
  • GoogleSsoBootstrapUIIT → nightly: openmetadata-nightly k8s-java-it (ui-it + embedded JavaUIIT)
Commands
mvn -B package -pl openmetadata-mcp,openmetadata-service -am -Dspring-boot.repackage.skip=true -Dtest=AuthCallbackServletTest,AuthenticationCodeFlowHandlerTest,ConcurrentFirstOidcLoginTest,JwtFilterTest,McpCallbackServletTest,SsoRedirectBoundaryTest -Dsurefire.failIfNoSpecifiedTests=false
mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=parallel '-Dit.test=<98 classes>' -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=global-state -Dit.test=ContextMemoryDerivationIT,ContextMemoryExtractionIT,ConversationSchemaMigrationIT,CredentialDatabaseOutageIT,CredentialRevocationTwoProcessIT,OpsRegenerateBotTokensIT,RevokeWaitForPropagationIT,SessionMultiNodeIT,SsoOidcCallbackHardeningIT,SsoOidcConfidentialLoginIT,SsoOidcProviderProfilesIT,SsoOidcPublicBearerIT,SsoTokenRenewalIT,UserMetricsResourceIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=rdf -Dit.test=AgentSparqlResourceIT,RdfFusekiAuthorizationIT,RdfMcpKnowledgeGraphIT,RdfPolicyRevocationIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pcache-tests -DintegrationTests.lane=global-state -Dit.test=CredentialRedisDownIT,CredentialRedisNoRoundTripIT,SessionRedisMultiNodeIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

✅ SSO Login Nightly — PASSED

View workflow run · Commit d1b8993

Provider Status Pass Fail Flaky Skip Duration
basic ✅ pass 28 0 0 0 6m 20s
ldap ✅ pass 7 0 0 0 0m 47s
keycloak-oidc-confidential ✅ pass 12 0 0 0 1m 21s
keycloak-oidc-public ✅ pass 11 0 0 0 1m 40s
msal-mock ✅ pass 7 0 0 0 0m 36s
auth0-mock ✅ pass 6 0 0 0 0m 45s
okta ⏩ skipped - - - - -
keycloak-azure-saml ✅ pass 23 0 0 0 6m 01s
keycloak-azure-saml-crosssite ⏩ skipped - - - - -

Totals: 94 passed · 0 failed · 0 flaky · 0 skipped · duration 17m 34s

@Vishnuujain
Vishnuujain marked this pull request as ready for review November 2, 2026 14:32
@Vishnuujain
Vishnuujain requested a review from a team as a code owner November 2, 2026 14:32
@Vishnuujain
Vishnuujain requested a review from TeddyCr November 2, 2026 14:32
@github-actions

github-actions Bot commented Nov 2, 2026

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.

@Vishnuujain Vishnuujain self-assigned this Nov 2, 2026
@Vishnuujain
Vishnuujain enabled auto-merge November 3, 2026 08:30
@Vishnuujain
Vishnuujain added this pull request to the merge queue Nov 3, 2026
@Vishnuujain
Vishnuujain merged commit 67bad95 into main Nov 3, 2026
196 of 197 checks passed
@Vishnuujain
Vishnuujain deleted the mcp-sso-email-user branch November 3, 2026 19:44
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

🤖 Backport to 2.1 is under way. It is built from openmetadata-collate, which holds the credentials needed to open a PR here, and it will comment again with the result — nothing is needed from you unless it reports otherwise.

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

🤖 Backport to 2.0 is under way. It is built from openmetadata-collate, which holds the credentials needed to open a PR here, and it will comment again with the result — nothing is needed from you unless it reports otherwise.

@gh-bot-collate

gh-bot-collate Bot commented Nov 3, 2026

Copy link
Copy Markdown

🤖 Backport to 2.1 opened as #36995 (clean cherry-pick). It merges itself once the checks pass.

Vishnuujain added a commit that referenced this pull request Nov 3, 2026
@gh-bot-collate

gh-bot-collate Bot commented Nov 3, 2026

Copy link
Copy Markdown

🤖 Not backported to 2.0. Claude looked at the conflict and declined to resolve it:

Backport aborted: PR #36860 to 2.0

Why this cannot be sensibly adapted

PR #36860 ("pick the sso user the same way as the web login") makes
McpCallbackServlet call a new AuthenticationCodeFlowHandler.resolveOidcIdentity()
method so the MCP OAuth callback resolves the SSO user via the exact same
"email-first" identity resolution the web login uses, instead of duplicating
claims-mapping logic locally.

That "web login" behavior does not exist on 2.0. On main,
AuthenticationCodeFlowHandler resolves the OIDC user through:

  • OidcIdentityResolver (resolveOidcIdentity), which produces a
    ResolvedOidcIdentity with an emailFirstFlow() flag and an
    AuthenticationConfiguration.getEmailClaim() setting
  • EmailFirstUserProvisioner / getOrCreateEmailFirstOidcUser, which looks
    up the existing local user that owns the asserted email rather than
    deriving a username from claims
  • UserUtil.resolveUserNameForEmail, UserProfileClaims,
    UserUtil.assignTeamsFromClaim

None of these classes/methods/config fields exist anywhere in the 2.0
history (OidcIdentityResolver.java, EmailFirstUserProvisioner, the
emailClaim config field, and UserUtil.resolveUserNameForEmail have no
commits on this branch). They are part of a separate, larger "email-first"
user-provisioning feature that was never backported to 2.0.

On 2.0, AuthenticationCodeFlowHandler.handleCallback() (the web login)
still resolves the user with the same plain
SecurityUtil.findUserNameFromClaims / SecurityUtil.findEmailFromClaims
calls that McpCallbackServlet already uses locally (via its own
getClaimsMapping() / getClaimsOrder() / getPrincipalDomain() helpers).
In other words, the discrepancy PR #36860 fixes on main — the MCP callback
diverging from the web login's identity resolution — does not exist on
2.0: both paths already use the same SecurityUtil helpers and the same
claims-mapping/claims-order/principal-domain inputs.

Forcing a resolution here would mean either:

  • Introducing OidcIdentityResolver, EmailFirstUserProvisioner,
    UserUtil.resolveUserNameForEmail, and the emailClaim config field from
    scratch on 2.0 — i.e. backporting an unrelated, much larger feature, which
    violates "port this change and nothing else", or
  • Referencing those APIs without actually adding them, which would not
    compile.

Neither is a legitimate backport of this specific fix, so I'm stopping here
instead of forcing a resolution.

State left behind

The cherry-pick is still in progress (not aborted, not continued, nothing
staged/committed by me beyond what git cherry-pick -x itself already
applied/staged). The following still have unresolved conflict markers:

  • openmetadata-mcp/src/test/java/org/openmetadata/mcp/server/auth/handlers/McpCallbackServletTest.java
  • openmetadata-service/src/main/java/org/openmetadata/service/security/AuthenticationCodeFlowHandler.java

openmetadata-mcp/src/main/java/org/openmetadata/mcp/server/auth/handlers/McpCallbackServlet.java
applied cleanly but now references OidcIdentityResolver and UserUtil
APIs that don't exist on 2.0 — it will not compile as-is and should be
reverted along with the rest of the cherry-pick.

Recommendation

Abandon this backport (git cherry-pick --abort). If MCP SSO login
inconsistencies are also a problem on 2.0, that would need a separate,
2.0-native fix scoped to the SecurityUtil-based resolution that actually
exists there — not a port of this PR.

resolver run

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 To release Will cherry-pick this PR into the release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants