Skip to content

fix(oauth): stop advertising registration_endpoint when the issuer has no DCR - #36

Merged
marselsel merged 1 commit into
mainfrom
fix/optional-registration-endpoint
Aug 7, 2026
Merged

fix(oauth): stop advertising registration_endpoint when the issuer has no DCR#36
marselsel merged 1 commit into
mainfrom
fix/optional-registration-endpoint

Conversation

@marselsel

Copy link
Copy Markdown
Owner

Problem

buildOAuthMetadata hardcodes {issuer}/oauth2/register into the authorization-server metadata whether or not the issuer supports DCR.

After disabling DCR on our WorkOS tenant, the two documents disagreed:

Document registration_endpoint
This server …/oauth2/register — returns 400 dynamic_client_registration_disabled
WorkOS's own metadata absent

A 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_endpoint is optional in RFC 8414, so omitting it is the correct signal. OAUTH_REGISTRATION_ENDPOINT=none (case-insensitive, trimmed) omits the field. Checked before normalizeUrl, which would otherwise reject none as 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/none and the unchanged default; key absence asserted both on the metadata object and on the real HTTP response from a mounted mcpAuthMetadataRouter — not merely a falsy value.

Related

Same root cause as the derived /oauth2/authorize + /oauth2/token defaults 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.

…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.
@marselsel
marselsel merged commit 91936bd into main Aug 7, 2026
2 checks passed
@marselsel
marselsel deleted the fix/optional-registration-endpoint branch August 7, 2026 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant