Skip to content

fix(mcp): ask before SSO authorizes a client (backport 2.0 #36172) - #37674

Merged
pmbrull merged 1 commit into
2.0from
codex/backport-mcp-sso-consent-2.0
Nov 12, 2026
Merged

pmbrull merged 1 commit into
2.0from
codex/backport-mcp-sso-consent-2.0

Conversation

@pmbrull

@pmbrull pmbrull commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Describe your changes:

Backports #36172 to 2.0, resolving the failed automated backport manually.

MCP SSO sign-in now asks the user to approve the registered client before issuing an authorization code. The page identifies the client, the signed-in account, and the redirect host. Deny returns access_denied without issuing a code.

Type of change:

  • Bug fix

High-level design:

  • Adapt the OAuth SQL to CollectionDAO, where the 2.0 branch keeps its DAOs.
  • Keep the signed-in account and a hash of the consent token on the pending request. Conditional SQL makes consent single-use, rejects expired requests, and prevents a second sign-in from replacing the first account.
  • Add the fields in 2.0.8, after the published 2.0.7 release. PostgreSQL uses ADD COLUMN IF NOT EXISTS; MySQL uses a guarded Java migration step that tolerates reruns.
  • Preserve canonical account names. User deletion and password changes also remove pending consents through the existing grant-revocation transaction.
  • Decision record: ADR:2026-10-23-mcp-sso-asks-consent-after-the-idp-round-trip.

This backport adds client consent. It does not disable dynamic registration or remove existing clients and tokens.

Tests:

Use cases covered

  • SSO authentication displays consent and issues no code before approval.
  • Approval issues a code for the authenticated account; denial issues none.
  • Missing or incorrect consent tokens, repeated sign-ins, expired requests, and clients removed before approval are rejected.
  • The rendered form posts through the servlet under BASE_PATH.
  • Consent is stored and claimed once on MySQL and PostgreSQL. Migration reruns succeed.
  • Deleting an account removes its pending consent and grants while preserving other accounts' grants.

Unit and database tests

46 focused cases passed; none skipped. Saved reports were reused because publication did not change the tested behavior or environment.

Test class Passed
UserSSOConsentTest 6
UserSSOOAuthProviderTest 3
McpPendingAuthRequestRepositoryTest 1
OAuthHttpStatelessServerTransportProviderTest 30
McpPendingConsentSqlTest 2
McpGrantRevocationSqlTest 2
WorkflowRedeployEntryPointTest 2

The SQL tests ran against disposable MySQL 8.3 and PostgreSQL 15 databases.

Successful final reactor command:

mvn -B -pl openmetadata-mcp -am verify \
  -Dtest=UserSSOConsentTest,UserSSOOAuthProviderTest,OAuthHttpStatelessServerTransportProviderTest,McpPendingAuthRequestRepositoryTest \
  -Dsurefire.failIfNoSpecifiedTests=false -DonlyBackend

The six service cases passed in the preceding combined verify run, with McpPendingConsentSqlTest,McpGrantRevocationSqlTest,WorkflowRedeployEntryPointTest added to the same test selection. That run then stopped at MCP test compilation because the port duplicated an existing helper; the duplicate was removed before the successful final run. An initial test-phase attempt stopped before tests because the shaded search dependencies require the package phase; verify builds them correctly.

Merge-readiness follow-up (2026-11-12): all 595 MCP tests passed, with no failures, errors, or skips, on the unchanged PR head 67991f80157269ef7890f2b8bb3d7fdf0d8f1c83. This includes the existing callback, login, registration, token, and revocation regressions as well as the consent tests.

mvn -B -pl openmetadata-mcp -am verify \
  '-Dtest=%regex[org/openmetadata/mcp/.*Test.class]' \
  -Dsurefire.failIfNoSpecifiedTests=false -DonlyBackend

Service unit CI also passed: 9,416 cases, zero failures/errors, one skip. The two consent SQL cases, two grant-revocation SQL cases, and two migration entry-point cases all passed without skips.

Also passed:

  • mvn -B -pl openmetadata-mcp,openmetadata-service spotless:apply
  • Commit-time Google Java formatter
  • git diff --check
  • Patch application check against base 0ebc9e054166ca8b3d17a04acac1c62e14a63ad6

Self-review: reviewed 67991f80157269ef7890f2b8bb3d7fdf0d8f1c83 against REVIEW.md, including the SSO callback, servlet routing, consent SQL, migrations, and user-deletion/password-change consumers. An independent review of all 18 files found no material security or correctness issues and no material code blocker.

Line coverage was not measured. This release branch has no affected-test planner or decision-record validation target; focused checks were selected from the changed behavior and its consumers.

Backend integration tests

The full PostgreSQL integration runs failed with cases already failing before this backport. The MySQL integration lane was still running at the last check. A real OIDC/SAML round trip remains pending; the tests above cover servlet dispatch and real database behavior but do not replace an end-to-end identity-provider check.

CI baseline comparison (2026-11-12)

Compared against the earlier runs for #37650, head 3d1a824fea46d089092ca7727f3de971563e119b, which was merged as this PR's base 0ebc9e054166ca8b3d17a04acac1c62e14a63ad6. A direct tree diff confirms their backend, migrations, integration tests, and backend CI workflows are identical; their only difference is playwright/utils/searchSettingUtils.ts.

Suite Earlier baseline This PR
PostgreSQL + Elasticsearch/Redis 7 failures, 2 errors The same 7 failures and 2 errors
PostgreSQL + OpenSearch 5 failures, 1 error 5 failures, 2 errors; the extra glossary-status timeout also occurs in the earlier PostgreSQL/Elasticsearch baseline

Every failing test case in these two PR runs was already failing before the backport: connection cleanup, ODCS email-format import/export, disabled-policy enforcement, API endpoint field tags in search, glossary CSV relationships, quoted-term rename, and glossary status in search. No new failing test case was found.

The external Collate compatibility check also failed on the earlier baseline, with the same published build command as this PR: mvn -B clean install -DskipTests -pl '!collate-ui,!collate-dist'. Its underlying Maven error is not published on GitHub, so the exact compatibility root cause remains unverified.

The PR metadata check separately requires a linked GitHub issue. The original #36172 is a PR and has no linked issue; the tracking issue is still to be supplied.

Playwright and manual testing

No Playwright run or live SSO browser check was performed. The changed consent page is server-rendered HTML; no React bundle changes are included.

UI screen recording / screenshots:

Pending. The PR is ready for review; a consent-screen capture and a live SSO check have not been performed.

Checklist:

  • Linked the original PR as a backport.
  • Added and listed focused regression tests.
  • Included the consent decision record and the 2.0.8 migration.
  • Recorded verification failures, their resolutions, and broader coverage still pending.
  • Capture the consent screen and validate a real SSO round trip.

Require approval before SSO issues an MCP authorization code. Store
single-use consent in the database and add its columns in 2.0.8.

Adapt #36172 to CollectionDAO and retain user grant revocation.
@gitar-bot

gitar-bot Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Code Review ✅ Approved 🔴 High risk

Adding consent-gated MCP SSO code issuance changes authorization; a misbound approval could grant a client access to a user's account.

Adds a user consent step to MCP SSO sign-in so the registered client, signed-in account, and redirect host are shown and must be approved before an authorization code is issued, with denial returning access_denied. 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

@pmbrull
pmbrull marked this pull request as ready for review November 12, 2026 11:57
@pmbrull
pmbrull requested a review from a team as a code owner November 12, 2026 11:57
@pmbrull
pmbrull requested review from manerow and removed request for a team November 12, 2026 11:57
@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.

@pmbrull
pmbrull merged commit 11d25d7 into 2.0 Nov 12, 2026
109 of 116 checks passed
@pmbrull
pmbrull deleted the codex/backport-mcp-sso-consent-2.0 branch November 12, 2026 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants