fix(oauth): stop advertising registration_endpoint when the issuer has no DCR - #36
Merged
Merged
Conversation
…s no DCR
buildOAuthMetadata hardcoded `{issuer}/oauth2/register` into the
authorization-server metadata regardless of whether the issuer supports Dynamic
Client Registration. After disabling DCR on our WorkOS tenant, this server kept
advertising an endpoint that answers 400 dynamic_client_registration_disabled,
while WorkOS's own metadata correctly omitted it. A client discovering us would
therefore attempt registration and fail, rather than concluding DCR is
unavailable and using a pre-registered client.
registration_endpoint is optional in RFC 8414, so omitting it is the correct
signal. Set OAUTH_REGISTRATION_ENDPOINT=none to omit it; unset keeps the derived
default, so existing deployments are unchanged.
Tests cover the config parsing (none/NONE/None, and the unchanged default) and
assert key ABSENCE both on the metadata object and on the real HTTP response
from a mounted mcpAuthMetadataRouter.
Release 0.1.10; version bumped in package.json, package-lock.json and
src/server.ts.
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.
Problem
buildOAuthMetadatahardcodes{issuer}/oauth2/registerinto the authorization-server metadata whether or not the issuer supports DCR.After disabling DCR on our WorkOS tenant, the two documents disagreed:
registration_endpoint…/oauth2/register— returns 400 dynamic_client_registration_disabledA client discovering the server through our metadata attempts registration and fails, instead of concluding DCR is unavailable and using a pre-registered client.
Solution
registration_endpointis optional in RFC 8414, so omitting it is the correct signal.OAUTH_REGISTRATION_ENDPOINT=none(case-insensitive, trimmed) omits the field. Checked beforenormalizeUrl, which would otherwise rejectnoneas an invalid URL.Backward compatibility
Unset keeps the derived default. A test pins that. No existing deployment changes.
Tests
155 passing (up from 149). Config parsing for
none/NONE/None/noneand the unchanged default; key absence asserted both on the metadata object and on the real HTTP response from a mountedmcpAuthMetadataRouter— not merely a falsy value.Related
Same root cause as the derived
/oauth2/authorize+/oauth2/tokendefaults being wrong for Entra (real:/oauth2/v2.0/authorize). Fetching the issuer's own discovery document at startup would fix that whole class; this PR fixes the one instance that is actively wrong in production.