Skip to content

feat(transport): keep client_secret_expires_at from client registration - #1478

Open
marcus-beauregard wants to merge 1 commit into
modelcontextprotocol:mainfrom
marcus-beauregard:fix/client-secret-expiry
Open

marcus-beauregard wants to merge 1 commit into
modelcontextprotocol:mainfrom
marcus-beauregard:fix/client-secret-expiry

Conversation

@marcus-beauregard

Copy link
Copy Markdown

Summary

AuthorizationManager::register_client deserialized the whole RFC 7591 registration response but returned only an OAuthClientConfig, which had no expiry on it — so a client that stores its registration could not tell when the issued client_secret lapses. OAuthClientConfig now carries client_secret_expires_at.

Fixes #1416.

Root cause

ClientRegistrationResponse ends with #[serde(flatten)] additional_fields, so an authorization server's client_secret_expires_at was parsed into the catch-all map and never read. register_client then built OAuthClientConfig from client_id, client_secret, redirect_uri, scopes and application_type, and the expiry went no further.

Approach

  • OAuthClientConfig::client_secret_expires_at: Option<u64> — seconds since the Unix epoch, as RFC 7591 section 3.2.1 defines the field.
  • ClientRegistrationResponse parses client_secret_expires_at as a typed field instead of leaving it in additional_fields.
  • register_client normalises the value: None when no secret was issued (absent or empty string), when the server omitted the field, or when it reported 0 — RFC 7591 defines 0 as "never expires", which leaves nothing to schedule. A Some(secs) value is therefore always a real deadline. This follows the existing empty-string rule for client_secret, which is now computed once and reused.
  • The pre-registered and CIMD branches set None: no DCR secret was issued there.

Scope

Additive only. Both structs are #[non_exhaustive], so the new field is a minor-release change under VERSIONING.md, and register_client's signature is unchanged. AuthorizationSession::new still hands the config to configure_client without retaining it, so callers on that path see no behaviour change; surfacing the expiry there is a separate question and I left it out to keep this reviewable.

Regression tests

dcr_keeps_client_secret_expiry, dcr_treats_zero_client_secret_expiry_as_no_expiry, dcr_ignores_client_secret_expiry_without_a_secret, dcr_ignores_client_secret_expiry_for_an_empty_secret.

With the field initialised to None in register_client (mutation, everything else unchanged), dcr_keeps_client_secret_expiry fails with left: None, right: Some(1767225600).

Verification

Linux, Rust 1.96.1 (the version rust-toolchain.toml pins).

  • cargo test -p rmcp --lib --features auth — 593 passed, 0 failed.
  • cargo +nightly fmt --all -- --check — clean.
  • cargo clippy -p rmcp --lib --features auth -- -D warnings — clean.
  • cargo clippy -p rmcp --all-targets --features auth fails in test_cancelled_response and test_stdio_response_concurrency, which reference stdio while transport-io is off. That combination is not one CI runs (the clippy job uses --all-features); the failure reproduces without this change.

`AuthorizationManager::register_client` parsed the whole registration
response but returned an `OAuthClientConfig` with no expiry on it, so a
client that persists its registration could not tell when its
`client_secret` lapses — even though RFC 7591 section 3.2.1 requires the
field whenever a secret is issued.

`OAuthClientConfig` gains `client_secret_expires_at` (seconds since the
Unix epoch). It is `None` when no secret was issued, when the server
omitted the field, or when it reported `0` (never expires), so a `Some`
value is always an actual deadline to schedule against.

Both structs are `#[non_exhaustive]`, so the added field is additive and
ships in a minor release per VERSIONING.md. Closes modelcontextprotocol#1416.
@marcus-beauregard
marcus-beauregard requested a review from a team as a code owner November 20, 2026 00:42
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T00:45:43.703462Z b21cdc7 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown
Contributor

@michaelneale is on triage rotation this week and is the reviewer for this one.

Labels come from the PR labeler. Please review the change.

Automated triage. Labels are a first pass and the assigned maintainer has the final say.

This branch has not been deployed

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

Labels

T-core Core library changes T-transport Transport layer changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

register_client drops client_secret_expires_at from the registration response

1 participant