Repository navigation
feat(transport): keep client_secret_expires_at from client registration - #1478
Open
marcus-beauregard wants to merge 1 commit into
Open
marcus-beauregard wants to merge 1 commit into
marcus-beauregard wants to merge 1 commit into
Conversation
`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.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AuthorizationManager::register_clientdeserialized the whole RFC 7591 registration response but returned only anOAuthClientConfig, which had no expiry on it — so a client that stores its registration could not tell when the issuedclient_secretlapses.OAuthClientConfignow carriesclient_secret_expires_at.Fixes #1416.
Root cause
ClientRegistrationResponseends with#[serde(flatten)] additional_fields, so an authorization server'sclient_secret_expires_atwas parsed into the catch-all map and never read.register_clientthen builtOAuthClientConfigfromclient_id,client_secret,redirect_uri,scopesandapplication_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.ClientRegistrationResponseparsesclient_secret_expires_atas a typed field instead of leaving it inadditional_fields.register_clientnormalises the value:Nonewhen no secret was issued (absent or empty string), when the server omitted the field, or when it reported0— RFC 7591 defines0as "never expires", which leaves nothing to schedule. ASome(secs)value is therefore always a real deadline. This follows the existing empty-string rule forclient_secret, which is now computed once and reused.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, andregister_client's signature is unchanged.AuthorizationSession::newstill hands the config toconfigure_clientwithout 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
Noneinregister_client(mutation, everything else unchanged),dcr_keeps_client_secret_expiryfails withleft: None, right: Some(1767225600).Verification
Linux, Rust 1.96.1 (the version
rust-toolchain.tomlpins).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 authfails intest_cancelled_responseandtest_stdio_response_concurrency, which referencestdiowhiletransport-iois off. That combination is not one CI runs (the clippy job uses--all-features); the failure reproduces without this change.