Skip to content

Represent MCP authentication with an enum - #29924

Merged
aibrahim-oai merged 4 commits into
mainfrom
codex/model-mcp-auth-strategy
Jun 25, 2026
Merged

Represent MCP authentication with an enum#29924
aibrahim-oai merged 4 commits into
mainfrom
codex/model-mcp-auth-strategy

Conversation

@aibrahim-oai

@aibrahim-oai aibrahim-oai commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Why

MCP authentication has distinct OAuth and ChatGPT-session flows. Representing that choice as use_chatgpt_auth makes one flow implicit and allows the configuration model to express the distinction only through a boolean.

ChatGPT credential forwarding also needs a first-party trust boundary. A configurable chatgpt_base_url controls routing, but must not grant an MCP server permission to receive session credentials.

This change builds on #29733, where the boolean was introduced.

What changed

  • Replace use_chatgpt_auth with an auth field backed by the exhaustive McpServerAuth enum.
  • Support auth = "oauth" and auth = "chatgpt", with OAuth remaining the default.
  • Trust only the origin derived from the existing hardcoded CHATGPT_CODEX_BASE_URL when granting ChatGPT auth to an MCP server.
  • Keep configured bearer tokens and authorization headers ahead of the selected authentication flow.
  • Update config writers, schema output, fixtures, and integration-test setup to use the enum.

Verification

Integration coverage exercises the complete streamable HTTP startup path in two independent configurations:

  • A directly constructed MCP configuration verifies that matching an overridden chatgpt_base_url does not grant ChatGPT auth.
  • A persisted config.toml containing an attacker-controlled chatgpt_base_url and auth = "chatgpt" verifies the same boundary through normal config parsing.

Both tests complete MCP initialization and tool listing and assert that the full captured request sequence contains no authorization headers. Separate integration coverage verifies that configured authorization takes precedence over ChatGPT auth.

@aibrahim-oai

Copy link
Copy Markdown
Contributor Author

This change is part of the following stack:

Change managed by git-spice.

@aibrahim-oai aibrahim-oai changed the title Model MCP authentication as an enum Represent MCP authentication with an enum Jun 24, 2026
Base automatically changed from codex/configurable-chatgpt-mcp-auth to main June 25, 2026 02:21
@aibrahim-oai
aibrahim-oai force-pushed the codex/model-mcp-auth-strategy branch from b0f2ef8 to c667582 Compare June 25, 2026 02:25
@aibrahim-oai
aibrahim-oai marked this pull request as ready for review June 25, 2026 02:51
@aibrahim-oai
aibrahim-oai requested a review from a team as a code owner June 25, 2026 02:51
@aibrahim-oai
aibrahim-oai merged commit f8937b7 into main Jun 25, 2026
30 checks passed
@aibrahim-oai
aibrahim-oai deleted the codex/model-mcp-auth-strategy branch June 25, 2026 02:51
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant