Skip to content

mcp/oauthlogin rejects OAuth callbacks from any provider that does not implement RFC 9207 #764

Closed

Description

@jhrozek

Summary

mcp/oauthlogin requires an iss parameter on every OAuth callback. iss comes from
RFC 9207, which is an optional extension, so mecatl can only complete an OAuth
login against an authorization server that happens to implement it. Against any other
the callback is discarded, no authorization code is ever read, and the flow waits out
its callback timeout.

mcp/oauthlogin/callback.go (validQuery):

for _, required := range []string{"state", "iss"} {
    if len(query[required]) != 1 {
        return false
    }
}

Who this affects

The MCP OAuth login path, which is the flow that authenticates mecated to a remote
MCP server requiring OAuth:

  • cmd/mecated/mcplogin.go
  • internal/adapter/mcp/oauth_login.go
  • internal/app/mcplogin.go

Which providers break

Checked by fetching each discovery document for
authorization_response_iss_parameter_supported:

Provider Advertises RFC 9207
Google yes
Keycloak 26.7 yes
Microsoft Entra ID no
GitLab no
Apple no
Salesforce no
Dex no

Dex is the confirmed case: its callback arrives with code and state and no iss,
and login cannot complete. Keycloak's advertises true, and login works.

Absence of the metadata field means the server does not advertise support, which is
not absolute proof it never emits the parameter — but it is the signal RFC 9207 keys
the requirement on, and in practice a server without the metadata field has not
implemented the parameter.

Not checked: Okta, Auth0, Ping, Cognito. Their discovery documents are per-tenant, so
there is no public URL to fetch; do not read their absence from the table either way.

Worth checking separately: vMCP's own embedded authorization server. MCP servers often
run a minimal embedded AS rather than delegating to a full IdP, and a minimal
implementation is exactly the kind that skips an optional 2022 extension. If it does
not emit iss, mecatl cannot OAuth against our own vMCP.

Why it is hard to diagnose

The failure is silent. The browser shows "Authorization could not be completed"; the
process learns nothing, because the rejection reason never leaves the HTTP response,
and the run ends on a generic ErrAuthorizationFailed after the callback timeout.
Locating it currently means reading the validation code.

Proposed fix

RFC 9207 section 2.4: validate iss when it is present, and require it only when the
authorization server's discovery document advertises
authorization_response_iss_parameter_supported. That keeps mix-up protection for a
server that promised an iss — it cannot be stripped — while working with servers that
never offered one.

The listener holds no discovery document, so the required-if-advertised half cannot
live in mcp/oauthlogin. On this path the natural home is
internal/adapter/mcp/oauth_login.go, which already receives the discovery result and
passes result.Iss through to the SDK.

A version of this fix exists on spike/mecak8s-vmcp-b1-login, where the second half
lives in internal/adapter/clientauth (that path does its own discovery). It is not a
cherry-pick: the layer that owns the check differs.

Activity

  1. self-assigned this
    on Aug 26, 2026
  2. added a commit that references this issue on Aug 26, 2026
    e105c2c
  3. jhrozek commented on Aug 27, 2026

    @jhrozek
    ContributorAuthor

    Correction to the proposed fix in the description, after reading the SDK.

    The MCP Go SDK already implements RFC 9207 section 2.4 independently, in
    auth/authorization_code.go (validateIssuerResponse, called from the
    authorization-code handler), keyed on its own discovery metadata:

    if issParameterSupported {
        if iss == "" {
            return fmt.Errorf("authorization server advertises RFC 9207 iss parameter support but none was received ...")
        }
        if iss != expectedIssuer { ... }
    } else {
        if iss != "" {
            return fmt.Errorf("authorization server does not advertise RFC 9207 iss parameter support but iss was received ...")
        }
    }

    So the description is wrong on two counts:

    1. The required-if-advertised half does NOT need to be written in
      internal/adapter/mcp. It already exists downstream, and duplicating it there
      would be redundant.
    2. The fix is therefore just the listener relaxation in
      mcp/oauthlogin/callback.go: validate iss when present, stop requiring it.
      Mix-up protection for this consumer is preserved by the SDK, which is stricter
      than a bare relaxation -- it also rejects an iss that arrives when the server
      did not advertise support.

    spike/mecak8s-vmcp-b1-login carries that relaxation along with a
    required-if-advertised check in internal/adapter/clientauth (needed there because
    the mecatui path does its own discovery and does not go through the SDK). Merging
    that branch closes this issue; extracting just the callback.go change would close
    it sooner and is a three-file diff.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions