Skip to content

fix(mcp): ask before sso sign-in authorizes a client - #36172

Merged
Vishnuujain merged 7 commits into
mainfrom
fix/mcp-sso-consent
Oct 26, 2026
Merged

Vishnuujain merged 7 commits into
mainfrom
fix/mcp-sso-consent

Conversation

@Vishnuujain

@Vishnuujain Vishnuujain commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes:

Part of a larger set of MCP and auth fixes.

  • MCP SSO sign-in (OIDC confidential client and SAML) now ends on a page that names the client, the signed-in user and the redirect host. The authorization code is issued only after the user approves; Deny returns access_denied. Basic and LDAP already asked on /mcp/login.
  • The pending approval is stored on the mcp_pending_auth_requests row (2.0.7 adds consent_token_hash and consent_user_name: Postgres in schemaChanges.sql, MySQL in the guarded Java step, also run from 2.1.0), so any server can answer the POST. Only the first sign-in for a request is recorded and the approval can be used once.
  • Decision record: ADR:2026-10-23-mcp-sso-asks-consent-after-the-idp-round-trip.

Type of change:

  • Bug fix

High-level design:

Consent is asked after the IdP round trip, not before it, because SAML resolves the pending request from RelayState alone and the OIDC round-trip state lives in the database. The approval lives on the pending request row rather than the HttpSession (per node) or a token signed with a server key (defaults ship in conf/). Details in the decision record.

Tests:

Unit tests

  • UserSSOOAuthProviderTest: consent page instead of a code, approve, deny, wrong or missing token, second sign-in for the same request, client removed before approval.
  • McpPendingConsentSqlTest: runs the consent SQL on MySQL 8.3 and Postgres 15 (Testcontainers) against the table built from the shipped migrations, including 2.0.7 (on MySQL the guarded Java step, run twice). Store once, claim once, wrong token, expiry, no re-arm after a decision. It fails if the store guard is removed.
  • McpPendingAuthRequestRepositoryTest: the row gets the token hash, the claim uses the same hash, a missing token claims nothing.
  • OAuthHttpStatelessServerTransportProviderTest: renders the consent page, then posts that form's own action and fields through doPost under a base path. Approve issues the code for the signed-in user, Deny returns access_denied, and a client removed meanwhile gets a 400. They fail if the route is removed or the form's field names drift from the server's.
  • All openmetadata-mcp unit tests (811) and the migration workflow tests pass locally.

Backend integration tests

Not run locally (the selection is 210 classes); the merge queue runs them.

Manual testing performed

  1. Ran the real /mcp/authorize, /callback and /mcp/consent servlets against a stub OIDC provider: with a live IdP session the browser stops on the consent page and no code reaches the client; Approve issues a code for the signed-in user; Deny returns access_denied.
  2. Ran the consent store and claim statements on MySQL 8.3 and Postgres: first sign-in wins, a second user cannot overwrite it, the claim works once, expired requests are refused.

Checklist:

  • I have read the CONTRIBUTING document.
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.
  • Self-review: I reviewed the final diff against REVIEW.md (the pr-checklist skill runs it) and fixed every 🔴 finding, or answered it on the line below.
    Reviewed f3ed188. One 🔴: the consent SQL, repository and route had no real test. Fixed in 8e663e5 with the two tests above; that commit adds only tests and one decision-record sentence. The /mcp/consent route is covered by the transport tests above and was also exercised end to end locally. 🟡 left for a follow-up: /mcp/login (Basic/LDAP) does not show the redirect host, and handleSSOErrorCallback keeps its own copies of the client check and cleanup.
  • Decision check: added ADR:2026-10-23-mcp-sso-asks-consent-after-the-idp-round-trip.
  • I have added a test that covers the exact scenario we are fixing.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no new blocking issue was found.

Summary

MCP SSO sign-in now asks the user to approve the client before issuing an authorization code.

  • SSO users approve an MCP client before it gets an authorization code.
  • MCP consent stays tied to one live sign-in across server nodes.

No new actionable issues were found. The earlier test-length finding is excluded by the current review guide.

Diagram

sequenceDiagram
    participant Browser
    participant Server
    participant IdP
    participant DB
    participant Client
    Browser->>Server: Start MCP authorization
    Server->>IdP: Sign in
    IdP->>Server: Return authenticated user
    Server->>DB: Store first pending approval
    Server-->>Browser: Show client, user, and redirect host
    Browser->>Server: POST decision and page token
    Server->>DB: Claim token once
    alt Approve
        Server-->>Client: Authorization code and original state
    else Deny
        Server-->>Client: access_denied and original state
    end
Loading

Reviews (6) · Last reviewed commit: "resolved conflict" · Reviewed by Greptile

@Vishnuujain
Vishnuujain requested a review from a team as a code owner October 25, 2026 02:44
@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 the safe to test Add this label to run secure Github workflows on PRs label Oct 25, 2026
@Vishnuujain Vishnuujain self-assigned this Oct 25, 2026
@Vishnuujain Vishnuujain added the To release Will cherry-pick this PR into the release branch label Oct 26, 2026
@Vishnuujain
Vishnuujain added this pull request to the merge queue Oct 26, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Oct 26, 2026
@github-actions github-actions Bot added the merge conflict Conflicts with the latest main; removed from the merge queue label Oct 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — merge_conflict (2026-10-26T16:11:01Z)

The entry left the queue before it was built, so no checks ran against it.

Conflicts with the latest main — rebase, then re-queue.

@github-actions github-actions Bot removed the merge conflict Conflicts with the latest main; removed from the merge queue label Oct 26, 2026
@Vishnuujain
Vishnuujain enabled auto-merge October 26, 2026 20:06
@gitar-bot

gitar-bot Bot commented Oct 26, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

🔴 High risk · Moving MCP SSO code issuance behind consent changes authorization decisions; a mishandled approval could grant unintended client access.

Adds a consent step to MCP SSO sign-in so the user approves the client before an authorization code is issued, with Deny returning access_denied. Pending approval is stored on the mcp_pending_auth_requests row, with schema changes for 2.0.7. No open 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 added this pull request to the merge queue Oct 26, 2026
Merged via the queue into main with commit c226e1f Oct 26, 2026
82 of 84 checks passed
@Vishnuujain
Vishnuujain deleted the fix/mcp-sso-consent branch October 26, 2026 21:11
@github-actions

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

Copy link
Copy Markdown

🤖 Backport to 2.0 failed. The conflict could not be resolved, so this change is not on that branch. Resolver run.

pmbrull added a commit that referenced this pull request Nov 12, 2026
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.
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.

3 participants