Repository navigation
Sign in through Client ID Metadata Documents in managed OAuth - #259
Merged
Merged
Conversation
Operators can configure managed OAuth clients for authorization servers that accept OAuth Client ID Metadata Documents, without registering a client with each service. The runtime publishes the installation's document at /oauth/client-metadata.json on the managed OAuth origin, listing the callback of every such client. Its URL is the client ID; authorization, code exchange, refresh and revocation use PKCE without a client secret and send the configured RFC 8707 resource. Tokens follow the existing rules: apps receive placeholders bound to the client's hosts, refresh grants stay bound to app, organization and caller, and granted scopes must stay within the client's scopes.
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
widefleet-docs | 125a478 | Nov 20 2026, 11:36 PM |
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.
What changes
Configuration. A managed OAuth client can now name an authorization server that accepts OAuth Client ID Metadata Documents instead of a registered client:
{ "origin": "https://oauth.example.com", "clientName": "Widefleet", "clients": { "tracker": { "registration": "client-id-metadata-document", "authorizationUrl": "https://auth.tracker.example/authorize", "tokenUrl": "https://auth.tracker.example/token", "resource": "https://mcp.tracker.example/mcp", "issuer": "https://auth.tracker.example", "revocationUrl": "https://auth.tracker.example/revoke", "scopes": ["read", "write"], "hosts": ["https://mcp.tracker.example"] } } }Such a client has no
clientIdorclientSecret.clientNameis optional and defaults toWidefleet. Existing registered clients are unchanged.Document. The runtime serves
GET /oauth/client-metadata.jsonon the managed OAuth origin before app authentication, next to the existing callbacks. Its URL is the client ID. It lists the callback/oauth/callback/<client>of every metadata document client,token_endpoint_auth_method: noneand the authorization code and refresh token grants. Without such a client, or on another origin, the path falls through to normal routing.Broker. Authorization, code exchange, refresh and revocation use Better Auth's generic OAuth 2.0 helpers as a public client: PKCE,
client_idset to the document URL, no client secret, and the configuredresource(RFC 8707) on every request. Placeholders, bound refresh grants, scope limits and issuer checks work as for registered clients. A metadata document client's callback returns to/auth/callback/<client>on the app, since it has no Better Auth provider.managedOAuth().callback()is renamed tohandle(), because it now serves both public routes.Not included
Tests
packages/app-runtime/src/oauth.test.ts: the document and its origin, method and client checks; authorization URL, token, refresh and revocation requests without a secret; resource omission; callback separation; strict configuration; silent error responses.packages/app-runtime/src/oauth-metadata-document.test.ts: sign-in, a resource call, refresh and revocation against@cloudflare/workers-oauth-providerin workerd withclientIdMetadataDocumentEnabled, which fetches the published document and names the client from it.pnpm check, the app runtime and template suites andapps/control-plane/tests/managed-oauth-runtime.test.tspass locally.

Confidence Score: 5/5
The PR appears safe to merge; no actionable issues were found.Summary
Adds managed OAuth sign-in through Client ID Metadata Documents.
No actionable issues were found. tnkuehne explicitly deferred template adoption. Tests were reviewed but not run.
Diagram
Reviews (1) · Last reviewed commit: "Sign in through Client ID Metadata Docum..." · Reviewed by Greptile