github / github/copilot-cli

MCP Oauth fails when the server metadata URL is redirected

Aperta
#4,769 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

area:authentication area:mcp
Lingua principale
Shell
Stelle
11.2k
Fork
1.9k
Merge medio
14h 16m
PR unite (30g)
6

Descrizione

Describe the bug

When the .well-known/openid-configuration is behind an http redirect, authentication fails with:

Authentication failed: MCPOAuthError: Incompatible authorization server: authorization server advertised an issuer that does not match the URL its metadata was discovered from (RFC 8414 §3.3); refusing to connect

I believe that copilot-cli checks the issuer against the original URL instead of the redirected URL. Note that RFC 8414 states that the issuer must match "the URL used to retrieve the metadata," which strictly speaking is the redirection target, not the source.

Affected version

GitHub Copilot CLI 1.0.83.

Steps to reproduce the behavior
  1. Run an MCP server on a different server from its OAuth authorization server, e.g. https://my.mcp.server vs https://my.oauth.server
  2. Configure the MCP server so that https://my.mcp.server/.well-known/openid-configuration returns an HTTP 301 redirect to https://my.oauth.server/.well-known/openid-configuration
  3. Configure the OAuth server so that https://my.oauth.server/.well-known/openid-configuration specifies https://my.oauth.server as the issuer
  4. In copilot-cli, type /mcp add FooBar, select type HTTP, remote server URL https://my.mcp.server, and the client ID when asked
Expected behavior

Copilot should ask to authenticate, then open the authentication URL in my browser (or display the authentication code and URL so that I can copy-paste them in my browser), then complete the authentication flow.

Additional context

This may be related to #4480 except that in #4480, the Atlassian MCP server gave the wrong issuer, whereas here the issuer is correct for the real URL and copilot-cli is checking against the wrong URL.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Riproduci il problema facendo in modo che il .well-known/openid-configuration del server MCP restituisca un reindirizzamento 301, quindi traccia la validazione dell’issuer usata dal flusso HTTP di /mcp add. Il lavoro è completato quando i metadati dell’URL reindirizzata vengono accettati se il loro issuer corrisponde a quell’URL finale e l’autenticazione procede fino al browser o al codice di autorizzazione visualizzato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
shell
Ambito
authentication, cli, security
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Attiva
Chiarezza
Abbastanza chiara
Idoneità per principianti
55/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.