| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
…et_basic RFC 6749 section 2.3 says client credentials should not be in the request body when they are already in the Authorization header. The basic auth branch stripped client_secret but left client_id, so strict token endpoints (Keycloak, Okta in strict mode) reject the request as presenting two auth methods at once. Drop client_id too, and flip the two basic auth tests plus the refresh test that asserted the old behavior. Fixes modelcontextprotocol#3138
authenticate_request() required client_id in the form body unconditionally, even for client_secret_basic clients that already present it via the Authorization header. Stripping client_id from the body for Basic auth (the actual fix here) is correct per RFC 6749 section 2.3, but broke our own server: it had nothing to look the client up by. Decode the Basic header up front and fall back to it when the body doesn't have client_id. The three token request models (authorization_code, refresh_token, jwt-bearer) had the same body-required assumption baked in; client_id is now optional there too, backfilled from the already- authenticated client before the code/token ownership checks that rely on it.
| Back | FazBrowse Home | New Git URL |
RFC 6749 section 2.3 requires that with HTTP Basic auth, client credentials must not also appear in the request body. prepare_token_auth stripped client_secret from the body for the client_secret_basic branch but left client_id in, so strict token endpoints (Keycloak, Okta in strict mode, and the RFC 6749 compliance test suite) reject the request as presenting two authentication methods at once.
Fixes #3138, fixes #1315
Two existing tests asserted the old behavior explicitly, updated both to assert the corrected one, and added the same check to the refresh token test for symmetry.
Server-side companion fix
#1315 asked for exactly this: a fallback to the Authorization header when the body omits client_id. It's also required here, not just nice to have -- the client-only change above breaks this SDK's own reference auth server: ClientAuthenticator.authenticate_request() required client_id in the form body unconditionally, and the three token request models (AuthorizationCodeRequest, RefreshTokenRequest, JwtBearerRequest) had the same assumption baked in as a required field. A client that stops sending client_id in the body got rejected by our own server with invalid_client: Missing client_id — a regression, not a fix, without this half.
Fixed both:
How Has This Been Tested?
Breaking Changes
None for callers. client_id is optional on the token request models now but always resolved (body or Basic header) before use.
Types of changes
Checklist
Additional context
Two other independent attempts at the client-only half (#3159, #3160) hit this same server-side incompatibility in CI and were closed without a fix — this PR includes the missing half.