Skip to content

fix(mcp): show access denied for accounts not allowed - #38259

Merged
Vishnuujain merged 4 commits into
mainfrom
mcp-unknown-user-page
Nov 20, 2026
Merged

Vishnuujain merged 4 commits into
mainfrom
mcp-unknown-user-page

Conversation

@Vishnuujain

@Vishnuujain Vishnuujain commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes:

Fixes #38255

  • During MCP sign-in, a person the SSO provider vouched for but who may not sign in (no account with self-signup off, a registration domain that is not allowed) saw "Authentication Failed. An internal error occurred" with a 500.
  • The login step now tells the MCP callback why it failed, and the callback shows an Access Denied page with a 403 for that case. The login step's own status is unchanged, as ADR:2026-11-12-a-failed-sso-sign-in-returns-to-the-sign-in-page says.
  • The page text for this path is "Your account is not allowed to sign in to OpenMetadata.", since the login step reports these cases as one refusal. The existing "not registered" page is unchanged.
  • Found by a new MCP sign-in test for open-metadata/openmetadata-collate#4896, which follows in its own PR.

Type of change:

  • Bug fix

High-level design:

N/A, small change.

Tests:

Use cases covered

  • With self-signup off, a person without an account who signs in to an MCP client sees Access Denied (403), not an internal error.
  • Other failed MCP sign-ins still end on the existing error page.

Unit tests

  • I added unit tests for the new/changed logic.
  • Files added/updated: McpCallbackServletTest (doGet_accountNotAllowed_showsAccessDeniedNotAnInternalError), AuthenticationCodeFlowHandlerTest (handleCallback_failedMcpSignIn_tellsItsCallbackWhy).
  • Coverage was not measured.

Backend integration tests

  • Not applicable (no backend API changes).

Local Java test run: PASSED

  • Commit: eff62bbe3467 (base origin/main)
  • Finished: 2026-11-20 03:59 UTC · 1.1 min
  • Scope: focused; merge readiness is not established. Broader steps deferred: 5 (run --scope full).
Step Scope Classes Tests Failed Skipped Min Result
unit openmetadata-mcp (2 classes), openmetadata-service (1 class) 3 139 0 0 1.1 passed
  • Impacted, not run locally: 2 classes (listed in the details)

Manual testing performed

  1. Built this change and restarted a local server.
  2. Switched the server to a mock OIDC provider (confidential client) with self-signup off, through PUT /api/v1/system/security/config.
  3. Registered an MCP client and opened /mcp/authorize as a person who has no account.
  4. The callback answered 403 with "Access Denied. Your account is not allowed to sign in to OpenMetadata.", no consent page and no code. Before the change the same flow ended on the 500 "Authentication Failed" page.
  5. With the basic provider, the MCP sign-in through the password form, a tool call, refresh and revoke still work.

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR is linked to a GitHub issue via Fixes #<issue-number> above.
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.
  • Self-review: I reviewed the final diff against REVIEW.md and fixed every 🔴 finding, or answered it on the line below.
    • Reviewed at eff62bbe346. No 🔴.
  • Decision check: ADR:2026-11-12-a-failed-sso-sign-in-returns-to-the-sign-in-page gets a v2 amendment with the rule for the MCP callback.
  • 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 actionable issues were found.

Summary

Refused MCP sign-ins now show Access Denied with HTTP 403 instead of an internal-error page.

  • MCP sign-ins show an Access Denied page when an account is not allowed.

No actionable issues found. Tests were not run during this review.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[MCP SSO callback] --> B[Run sign-in handler]
  B --> C{Account not allowed?}
  C -->|Yes| D[403 Access Denied]
  C -->|Other failure| E[Existing error page]
  C -->|Sign-in succeeds| F[Existing token checks and consent]
Loading

Reviews (7) · Last reviewed commit: "Merge branch 'main' into mcp-unknown-use..." · Reviewed by Greptile

@Vishnuujain
Vishnuujain requested a review from a team as a code owner November 20, 2026 04:26
@Vishnuujain
Vishnuujain requested a review from harshach November 20, 2026 04:26
@Vishnuujain

Copy link
Copy Markdown
Contributor Author

Local Java test run: PASSED — details

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

Tests run locally

  • unit · openmetadata-mcp (2 classes), openmetadata-service (1 class): AuthenticationCodeFlowHandlerTest (96 passed), McpCallbackServletTest (13 passed), UserSSOOAuthProviderTest (30 passed)

Broader coverage not executed by this focused run

  • mvn -B package -pl openmetadata-mcp,openmetadata-service -am -Dspring-boot.repackage.skip=true -Dtest=AuthCallbackServletTest,AuthenticationCodeFlowHandlerTest,BasicAuthLoginServletTest,JwtFilterTest,McpCallbackServletTest,MintedTokensAreRecognizedTest,OAuthHttpStatelessServerTransportProviderTest,SsoRedirectBoundaryTest,UserSSOOAuthProviderTest -Dsurefire.failIfNoSpecifiedTests=false
  • mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=parallel '-Dit.test=<121 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,ContextMemoryExtractionRequestIT,ConversationSchemaMigrationIT,CredentialDatabaseOutageIT,CredentialRevocationTwoProcessIT,OpsRegenerateBotTokensIT,RevokeWaitForPropagationIT,SessionMultiNodeIT,SsoOidcCallbackHardeningIT,SsoOidcConfidentialLoginIT,SsoOidcProviderProfilesIT,SsoOidcPublicBearerIT,SsoSamlLoginIT,SsoSecurityConfigApplyIT,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
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=AuthenticationCodeFlowHandlerTest,McpCallbackServletTest,UserSSOOAuthProviderTest -Dsurefire.failIfNoSpecifiedTests=false

@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

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

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.

@gitar-bot

gitar-bot Bot commented Nov 20, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 🟡 Medium risk 1 closed / 1 findings

MCP callbacks now map refused SSO accounts to 403 Access Denied instead of 500, changing client-visible sign-in failure handling without granting access.

Refused MCP sign-ins for accounts not allowed to sign in now show an Access Denied page with a 403 instead of an internal error, with the login step's own status unchanged. The previously unrecorded ADR rule for this MCP 403 behavior was addressed. No open issues found.

✅ 1 closed
✅ Quality: MCP 403 rule for refused accounts isn't recorded in any ADR

📄 openmetadata-service/src/main/java/org/openmetadata/service/security/AuthenticationCodeFlowHandler.java:165 📄 openmetadata-service/src/main/java/org/openmetadata/service/security/AuthenticationCodeFlowHandler.java:711-713 📄 openmetadata-mcp/src/main/java/org/openmetadata/mcp/server/auth/handlers/McpCallbackServlet.java:308-313
This PR sets up a contract between openmetadata-service and openmetadata-mcp. endFailedSignIn puts the SignInFailure on the request as the attribute signInFailure. McpCallbackServlet then compares that attribute with ACCOUNT_NOT_ALLOWED and returns a 403 Access Denied page instead of the 500 error page. The cited ADR:2026-11-12-a-failed-sso-sign-in-returns-to-the-sign-in-page only says "A sign-in started by an MCP client keeps the error status its callback reads". It says nothing about the MCP callback reading the reason, or about which reasons get a 403 and which keep the error page. The description states that rule in prose ("the MCP callback now shows an Access Denied page with a 403 for that case… Other failed MCP sign-ins still end on the existing error page"), but this repo squash-merges, so the description won't survive in history.

The record (or a revision of the existing one) would say: "For a sign-in started by an MCP client, the login step keeps its error status and hands the SignInFailure to the MCP callback in the request attribute signInFailure. The callback answers account_not_allowed with a 403 Access Denied page, and every other reason ends on the existing error page." Without this, a future change to how endFailedSignIn sets the attribute, or to the SignInFailure constants, could quietly send refused accounts back to the 500 page.

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 merged commit 0b8b4e8 into main Nov 20, 2026
58 of 60 checks passed
@Vishnuujain
Vishnuujain deleted the mcp-unknown-user-page branch November 20, 2026 18:13
Vishnuujain added a commit that referenced this pull request Nov 24, 2026
* fix(mcp): show access denied for accounts not allowed

* neutral denied wording and failure reason tests

* record mcp access denied rule in adr

(cherry picked from commit 0b8b4e8)
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.

MCP sign-in shows "internal error" when the account is not allowed

3 participants