-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Always pass a valid redirect_uri callback parameter (localhost:8976) to Cloudflare OAuth API, even when the --callback-host and --callback-port params would not be accepted
#9396
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
Conversation
🦋 Changeset detectedLatest commit: ba6c018 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@gnekich could you clarify what issue this is fixing? Both the linked issues have been closed. If possible, could you open a new issue with a reproduction of what's going wrong? |
|
Just to be clear. The issue we are currently having is with this setting: --callback-host=0.0.0.0 Currently when working inside Docker we need to listen for localhost on 0.0.0.0. However, the login and callback urls still need to specify localhost as the host. Currently, this is not working as setting callback-host=0.0.0.0 also changes the host in login and callback urls to 0.0.0.0 which results in an error and prevents the authorization page from loading. The current workaround is to manually replace 0.0.0.0 in the login url with localhost and everything works. |
|
@gnekich could you create a new issue with a reproduction of the problem you're seeing? |
petebacondarwin
left a comment
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.
Thanks for putting this PR together.
It took me a while to get my head around what the actual problem was.
In general I think this is a good idea, but I have left some comments for changes before we can really land this.
af84b65 to
30bdb49
Compare
|
Just rebased and pushed a handful of changes that fit with my suggestions above. |
create-cloudflare
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
redirect_uri callback parameter (localhost:8976) to Cloudflare OAuth API, even when the --callback-host and --callback-port params would not be accepted
…6`) to Cloudflare OAuth API, even when the `--callback-host` and `--callback-port` params would not be accepted. The OAuth provider only accepts `localhost:8976` as the host and port in the `redirect_uri` parameter of the login request. One can configure the Wrangler's OAuth callback server to listen on custom host, via `--callback-host` (e.g. 0.0.0.0 or 127.0.0.1), and port, via `--callback-port`. This is useful when running Wrangler inside a Docker container (or equivalent) where it is not possible to listen on `localhost`. In this case, you can configure Wrangler to listen on a different host and/or port but then it is up to you to configure your container to map `localhost:8976` to the host and port on which Wrangler is listening. **Example:** Running the callback server on `127.0.0.1:8989`: ``` wrangler login --calback-host=127.0.0.1 --callback-port=8989 ``` results in Wrangler listening on 127.0.0.1:8989 and a login URL that looks like: ``` https://dash.cloudflare.com/oauth2/auth?...&redirect_uri=http%3A%2F%2Flocalhost%3A8976%2Foauth%2Fcallback&... ``` Note that the `redirect_uri` is always `localhost:8976` whatever the callback host and port are.
30bdb49 to
3b9f10b
Compare
Co-authored-by: emily-shen <69125074+emily-shen@users.noreply.github.com>
Fixes #5937
Fixes #9065
Fixes #11959
The OAuth provider only accepts
localhost:8976as the host and port in theredirect_uriparameter of the login request.One can configure the Wrangler's OAuth callback server to listen on custom host, via
--callback-host(e.g. 0.0.0.0 or 127.0.0.1), and port, via--callback-port.This is useful when running Wrangler inside a Docker container (or equivalent) where it is not possible to listen on
localhost.In this case, you can configure Wrangler to listen on a different host and/or port but then it is up to you to configure your container to map
localhost:8976to the host and port on which Wrangler is listening.Example
Running the callback server on
127.0.0.1:8989:results in Wrangler listening on 127.0.0.1:8989 and a login URL that looks like:
Note that the
redirect_uriis alwayslocalhost:8976whatever the callback host and port are.