Skip to content

Serialize MCP OAuth login and logout#30295

Open
stevenlee-oai wants to merge 7 commits into
dev/stevenlee/mcp-oauth-independent-3-transport-recoveryfrom
dev/stevenlee/mcp-oauth-independent-4-login-logout-locking
Open

Serialize MCP OAuth login and logout#30295
stevenlee-oai wants to merge 7 commits into
dev/stevenlee/mcp-oauth-independent-3-transport-recoveryfrom
dev/stevenlee/mcp-oauth-independent-4-login-logout-locking

Conversation

@stevenlee-oai

@stevenlee-oai stevenlee-oai commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Codex Thread 019edd6d-6f14-74e2-853c-345d1803d4a6

Stack

Review and merge in order. Every layer is independently correct and documents its safe stopping point.

  1. openai/codex#30292 — aggregate File/Secrets store locking
  2. openai/codex#30293 — resolve and lifecycle-pin the exact OAuth store
  3. openai/codex#30416 — serialized authoritative refresh transaction
  4. openai/codex#30294 — Codex-owned transport refresh and one-shot 401 recovery
  5. openai/codex#30295 — login/logout transaction serialization
  6. openai/codex#30296 — diagnostic-only Auto store drift reporting

This PR is layer 5.

Why

Refresh serialization is incomplete if OAuth login can overwrite a freshly rotated token or logout can be followed by an in-flight refresh resurrecting credentials. All credential lifecycle mutations for one MCP identity must share the same transaction lock.

What this PR does

  • Acquires the per-credential transaction lock in the real OAuth callback save path.
  • Acquires the same lock in CLI logout before deleting credentials.
  • Tests the actual callback and CLI paths rather than only private helpers.
  • Covers both ordering guarantees: completed login becomes authoritative, and logout waits for an earlier refresh before deleting its result.

Explicit decisions

  • Login, refresh, and logout serialize on compute_store_key(server_name, url).
  • Operations use a bounded lock wait and surface failure rather than bypassing serialization.
  • This layer adds no backend migration or durable token-store selector.

Safe stopping point

This completes the correctness stack: aggregate stores, exact-store pinning, refresh, every transport path, login, and logout now use the intended authority and serialization boundaries. Layer 6 is diagnostics only.

Validation

  • just test -p codex-rmcp-client (114 passed; expected environment skips)
  • just test -p codex-cli
  • Real callback-save and logout-vs-refresh contention coverage

@stevenlee-oai stevenlee-oai force-pushed the dev/stevenlee/mcp-oauth-independent-4-login-logout-locking branch from 04aa181 to 96b3707 Compare June 26, 2026 21:30
@stevenlee-oai stevenlee-oai force-pushed the dev/stevenlee/mcp-oauth-independent-3-transport-recovery branch 2 times, most recently from 0135226 to fc3ba8b Compare June 26, 2026 21:48
@stevenlee-oai stevenlee-oai force-pushed the dev/stevenlee/mcp-oauth-independent-4-login-logout-locking branch from 96b3707 to 71071e9 Compare June 26, 2026 21:48
@stevenlee-oai stevenlee-oai force-pushed the dev/stevenlee/mcp-oauth-independent-4-login-logout-locking branch from 71071e9 to 857c0dd Compare June 26, 2026 22:25
@stevenlee-oai stevenlee-oai force-pushed the dev/stevenlee/mcp-oauth-independent-3-transport-recovery branch from fc3ba8b to 5eaa4d4 Compare June 26, 2026 22:25
…y' into dev/stevenlee/mcp-oauth-independent-4-login-logout-locking

# Conflicts:
#	codex-rs/rmcp-client/src/oauth.rs
#	codex-rs/rmcp-client/src/oauth/tests/persistor_tests.rs
…y' into dev/stevenlee/mcp-oauth-independent-4-login-logout-locking
…y' into dev/stevenlee/mcp-oauth-independent-4-login-logout-locking
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant