Repository navigation
[Access] Document dynamic loopback OAuth callback ports #34342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
kennyj42
wants to merge
2
commits into
production
Choose a base branch
from
kjohnson/oauth-loopback-callback-ports
base: production
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
src/content/changelog/access/2026-10-14-oauth-loopback-callback-ports.mdx
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| --- | ||
| title: Dynamic loopback callback ports for Access OAuth clients | ||
| description: Managed OAuth and MCP portal client OAuth accept port changes on registered loopback callback URIs. | ||
| date: 2026-10-14 | ||
| products: | ||
| - access | ||
| - cloudflare-one | ||
| --- | ||
|
|
||
| Managed OAuth and MCP portal client OAuth allow desktop and CLI clients to choose an available local callback port at runtime. Clients no longer need to listen on the exact port in their registered loopback redirect URI. | ||
|
|
||
| For example, a client registered with this callback: | ||
|
|
||
| ```txt | ||
| http://127.0.0.1:3000/callback | ||
| ``` | ||
|
|
||
| can authorize with: | ||
|
|
||
| ```txt | ||
| http://127.0.0.1:49152/callback | ||
| ``` | ||
|
|
||
| Only the port can change. The scheme, host, path, and query must match exactly. The exception applies to `127.0.0.1`, `[::1]`, and explicitly registered `localhost` callbacks. Public clients must use PKCE with `S256`. If the port changes, the token exchange must include the exact `redirect_uri` used during authorization. | ||
|
|
||
| For matching rules and application settings, refer to [Loopback callback ports](/cloudflare-one/access-controls/applications/http-apps/managed-oauth/#loopback-callback-ports). | ||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -156,7 +156,7 @@ To test, open an MCP client and [connect to the MCP portal](/cloudflare-one/acce | |
| Configure these settings in the **Advanced settings** tab of your [self-hosted app](#enable-managed-oauth-on-a-self-hosted-application), [MCP server application](#enable-managed-oauth-on-an-mcp-server-application), or [MCP server portal](#enable-managed-oauth-on-an-mcp-server-portal). | ||
|
|
||
| - **Allow localhost clients**: Allow any client with redirect URIs on `localhost`. | ||
| - **Allow loopback clients**: Allow any client with redirect URIs on `127.0.0.1`. | ||
| - **Allow loopback clients**: Allow any client with redirect URIs on `127.0.0.1` or `[::1]`. | ||
| - **Allowed redirect URIs**: Redirect URIs allowed for dynamically registered clients (for example, `https://playground.ai.cloudflare.com/*`). The URL must use `https`. Paths may end in `/*` to match all sub-paths. | ||
| - **Grant session duration**: How long the OAuth refresh token remains valid. | ||
| - **Access token lifetime**: How long an OIDC Access token can be used to authenticate with your application. Cloudflare recommends configuring a short **Access token lifetime** (default 15 minutes) in conjunction with a longer **Grant session duration**. When the access token expires, Cloudflare uses the refresh token to issue a new one after re-evaluating the user against your Access policies. When the refresh token expires, the user must re-authenticate with the identity provider. | ||
|
|
@@ -218,6 +218,22 @@ Configure these settings via the `oauth_configuration` object on the [Access app | |
| </TabItem> | ||
| </Tabs> | ||
|
|
||
| ### Loopback callback ports | ||
|
|
||
| Desktop and CLI clients can choose an available local callback port at runtime. Managed OAuth and MCP portal client OAuth accept a different port from the one in a registered redirect URI for these hosts: | ||
|
|
||
| - `127.0.0.1` | ||
| - `[::1]` | ||
| - `localhost`, when explicitly registered | ||
|
|
||
| Only the port can change. The scheme (`http` or `https`), host, path, and query must match the registered URI exactly. For example, a client registered with `http://127.0.0.1:3000/callback` can authorize with `http://127.0.0.1:49152/callback`, but not `http://localhost:49152/callback` or a different callback path. Non-loopback redirect URIs still require an exact registered match. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above, port can only change during registration. it needs to be consistent between token exchange an authorization |
||
|
|
||
| Public clients must use Proof Key for Code Exchange (PKCE) with `S256`. When the callback port differs from the registered port, the client must send the exact authorization-time `redirect_uri` when exchanging the authorization code for tokens. Omitting it or sending a different URI causes the exchange to fail. | ||
|
|
||
| Managed OAuth still checks the application's [Dynamic Client Registration settings](#managed-oauth-settings). This port exception does not bypass those settings or register a different callback host. | ||
|
|
||
| This behavior applies to the local callback between an MCP client and Cloudflare. It does not change the [upstream OAuth callback URLs](/cloudflare-one/access-controls/ai-controls/mcp-portals/#upstream-oauth-callback-urls) registered with an upstream MCP server's OAuth provider. | ||
|
|
||
| ## Authorization flow | ||
|
|
||
| When managed OAuth is enabled, Access returns a `401` response instead of a `302` redirect to non-browser clients. The `401` includes a `WWW-Authenticate` header that points the client to Access's OAuth discovery metadata. | ||
|
|
||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we do want a changelog for this, we should probably call out that the port does need to remain the same between authorization and token exchange.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would call out more clearly that this constraint only applies to the loosening of port checks