Skip to content

Commit 7d80f6d

Browse files
fix: preserve HTTP 425 during OAuth discovery
1 parent b127fce commit 7d80f6d

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

‎crates/rmcp/src/transport/auth.rs‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2639,7 +2639,7 @@ impl AuthorizationManager {
26392639
if status.is_server_error()
26402640
|| matches!(
26412641
status,
2642-
StatusCode::REQUEST_TIMEOUT | StatusCode::TOO_MANY_REQUESTS
2642+
StatusCode::REQUEST_TIMEOUT | StatusCode::TOO_EARLY | StatusCode::TOO_MANY_REQUESTS
26432643
)
26442644
{
26452645
return Err(Box::new(OAuthHttpError::UnexpectedStatus(status)));
@@ -3994,6 +3994,7 @@ mod tests {
39943994

39953995
#[rstest]
39963996
#[case::resource_request_timeout(StatusCode::REQUEST_TIMEOUT, 0, "https://mcp.example.com/mcp")]
3997+
#[case::resource_too_early(StatusCode::TOO_EARLY, 0, "https://mcp.example.com/mcp")]
39973998
#[case::resource_too_many_requests(
39983999
StatusCode::TOO_MANY_REQUESTS,
39994000
0,
@@ -4004,6 +4005,11 @@ mod tests {
40044005
1,
40054006
"https://mcp.example.com/.well-known/oauth-protected-resource"
40064007
)]
4008+
#[case::protected_metadata_too_early(
4009+
StatusCode::TOO_EARLY,
4010+
1,
4011+
"https://mcp.example.com/.well-known/oauth-protected-resource"
4012+
)]
40074013
#[case::protected_metadata_too_many_requests(
40084014
StatusCode::TOO_MANY_REQUESTS,
40094015
1,
@@ -4014,6 +4020,11 @@ mod tests {
40144020
2,
40154021
"https://auth.example.com/.well-known/oauth-authorization-server"
40164022
)]
4023+
#[case::authorization_too_early(
4024+
StatusCode::TOO_EARLY,
4025+
2,
4026+
"https://auth.example.com/.well-known/oauth-authorization-server"
4027+
)]
40174028
#[case::authorization_too_many_requests(
40184029
StatusCode::TOO_MANY_REQUESTS,
40194030
2,

0 commit comments

Comments
 (0)