aws / aws/amazon-q-developer-cli
bug: OAuth ignores authorization_servers from Protected Resource Metadata
- Lingua principale
- Rust
- Stelle
- 2k
- Fork
- 439
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
### Summary
Q CLI's MCP OAuth implementation ignores the `authorization_servers` field from the Protected Resource Metadata (PRM) and derives OAuth endpoints from the MCP server's origin instead. This breaks authentication for MCP servers using external authorization servers.
### Expected Behavior (per MCP OAuth spec)
1. Q CLI fetches PRM → gets `authorization_servers: ["https://external-idp.example.com"]`
2. Q CLI uses external IDP's `/authorize` endpoint ✅
### Actual Behavior
1. Q CLI fetches PRM → gets `authorization_servers: ["https://external-idp.example.com"]`
2. **Q CLI IGNORES `authorization_servers`** ❌
3. Q CLI derives `/authorize` from MCP server's ORIGIN (same host)
### Reproduction
1. Configure MCP server returning PRM with external authorization_servers
2. Add to Q CLI config
3. Observe OAuth URL uses MCP server origin, not external IDP
### Technical Analysis
In `crates/chat-cli/src/mcp_client/oauth_util.rs`, rmcp constructs OAuth endpoints relative to MCP server origin. The `authorization_servers` field from PRM is never used.
`OAuthConfig` only supports `redirect_uri` - no `authUrl`/`tokenUrl` override.
### Impact
- Breaks MCP servers using external authorization servers
- Affects enterprise deployments with custom IDPs
- May relate to #3431 (Figma OAuth)
### Proposed Fix
1. Parse `authorization_servers` from PRM
2. Use first entry as base URL for OAuth endpoints
3. Add `authUrl`/`tokenUrl` to `OAuthConfig`
### Reference
- MCP OAuth spec: https://modelcontextprotocol.io/specification/2025-03-26/basic/authentication
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Parti da crates/chat-cli/src/mcp_client/oauth_util.rs e segui il modo in cui rmcp costruisce gli endpoint OAuth dopo aver recuperato Protected Resource Metadata. Esamina OAuthConfig e la gestione di authorization_servers, quindi riproduci il caso con un PRM che indichi un authorization server esterno. Il lavoro è completato quando gli endpoint OAuth di autorizzazione e token usano quel server invece dell'origine del server MCP.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- rust
- Ambito
- authentication, cli
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100