fix(idp): apply RFC 7591 §2 defaults to DCR registration response#174
Open
cmatte wants to merge 1 commit into
Open
fix(idp): apply RFC 7591 §2 defaults to DCR registration response#174cmatte wants to merge 1 commit into
cmatte wants to merge 1 commit into
Conversation
The DCR handler stored req.GrantTypes, req.ResponseTypes, and req.TokenEndpointAuthMethod verbatim. When the caller omitted them, the persisted fosite client used empty values and the registration response returned `null` for the arrays and `""` for the auth method. Per RFC 7591 §2 the server should default these optional fields to `["authorization_code"]`, `["code"]`, and `"client_secret_basic"`. Strict clients (e.g. LM Studio's Zod schema) reject the non-compliant response with `expected array, received null`; lenient clients (Claude) tolerate it. Defaults are applied immediately after JSON binding, so both the stored client and the response inherit them in one place. Fixes sigbit#173 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Fixes #173.
Summary
POST /.idp/registerreturnsgrant_types: null,response_types: null, andtoken_endpoint_auth_method: ""whenever the caller omits these optional fields. RFC 7591 §2 requires the server to apply defaults:["authorization_code"],["code"], and"client_secret_basic". Strict clients (LM Studio's Zod schema) reject the non-compliant response withexpected array, received null; lenient clients (Claude desktop/mobile/web) tolerate it, which is presumably why the bug went unnoticed for the "verified" clients.Patch
Apply the defaults to the request struct immediately after
c.ShouldBindJSON(&req), so both the persistedfosite.DefaultClientand the registration response inherit them in one place. Any caller-supplied values are preserved verbatim.Verification
Registration request that omits the fields (what LM Studio sends):
Before:
{ "grant_types": null, "response_types": null, "token_endpoint_auth_method": "" }After:
{ "grant_types": ["authorization_code"], "response_types": ["code"], "token_endpoint_auth_method": "client_secret_basic" }LM Studio 0.4.15 then connects successfully against a proxy running the patched build — verified end-to-end on two production deployments (one Garmin Connect MCP, one medical-data MCP) before opening this PR.
Notes
grant_types_supported,response_types_supported); only the DCR registration response was non-compliant.handleRegisterif you'd prefer; let me know and I'll push a follow-up.