Skip to content

Conversation

@g2vinay
Copy link
Contributor

@g2vinay g2vinay commented Jan 29, 2026

Add context-aware CORS policy for HTTP transport mode

  • Development mode (unauthenticated): Restricts to localhost origins only to prevent CSRF attacks

    • Allows localhost/127.0.0.1/[::1] with any port (supports MCP Inspector, custom ports)
    • Protects against cross-site request forgery when --dangerously-disable-http-incoming-auth is used
    • Prevents malicious websites from accessing developer's Azure credentials via localhost endpoints
  • Production mode (authenticated): Allows all origins safely

    • JWT Bearer authentication validates all requests regardless of origin
    • Required for MCP clients (GitHub Copilot in VS Code/Codespaces) from various origins
    • CORS is a browser mechanism; authenticated API doesn't need origin restrictions

Replaces permissive 'AllowAll' policy with context-aware 'McpCorsPolicy'
Implements ConfigureCors() method shared by both authenticated and unauthenticated HTTP hosts

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

Labels

None yet

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

1 participant