Skip to content

feat: configurable OAuth callback port for gws auth login#1

Open
Copilot wants to merge 8 commits intomainfrom
copilot/add-oauth-callback-host-port
Open

feat: configurable OAuth callback port for gws auth login#1
Copilot wants to merge 8 commits intomainfrom
copilot/add-oauth-callback-host-port

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 6, 2026

The OAuth loopback callback server always bound to 127.0.0.1 on an OS-assigned random port with localhost hardcoded in the redirect URI — making it impossible to use a fixed port (required when the OAuth app has specific redirect URIs registered) or in Docker/CI environments where port-forwarding is used.

Changes

  • New CLI flag on gws auth login:
    • --callback-port PORT — port to bind the callback server (default: 0 = OS-assigned)
  • Env var support via clap's env feature (CLI takes precedence):
    • GOOGLE_WORKSPACE_CLI_CALLBACK_PORT
  • Bind address: always binds to 0.0.0.0:{port}, supporting Docker/CI port-forwarding scenarios
  • Redirect URI: always uses localhost as the hostname
  • Routing: when a non-default port is specified, routes to login_with_proxy_support (yup-oauth2 doesn't expose port configuration)
  • clap env feature added to the dependency

Example

# Fixed port — matches redirect URI registered in Google Cloud Console
gws auth login --callback-port 8080

# Or via env vars (e.g. in CI)
GOOGLE_WORKSPACE_CLI_CALLBACK_PORT=8080 gws auth login

[!WARNING]

Original prompt

actually, during the login, there is no way to set the host and the port for the ouath callback.
your duty is to implement this using both CLI parameters and enc variables

Copilot AI changed the title [WIP] Add ability to set host and port for OAuth callback feat: configurable OAuth callback host and port for gws auth login Apr 6, 2026
Copilot AI requested a review from ilteoood April 6, 2026 08:15
@ilteoood ilteoood marked this pull request as ready for review April 6, 2026 08:19
@ilteoood
Copy link
Copy Markdown
Owner

ilteoood commented Apr 6, 2026

@copilot check the code review made here and apply the needed changes

Copy link
Copy Markdown
Author

Copilot AI commented Apr 6, 2026

@copilot check the code review made here and apply the needed changes

Applied the IPv6 fix from the Gemini review (commit 0cf8428): bare IPv6 addresses in callback_host (those containing : but not already wrapped in [...]) are now enclosed in square brackets in the redirect URI, producing a valid URL like http://[::1]:8080 instead of http://::1:8080.

ilteoood and others added 2 commits April 6, 2026 11:35
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@ilteoood
Copy link
Copy Markdown
Owner

ilteoood commented Apr 6, 2026

Let's change the whole implementation, remove the host definition and always use 0.0.0.0

Keep the port logic as is

@copilot

Copy link
Copy Markdown
Author

Copilot AI commented Apr 6, 2026

Let's change the whole implementation, remove the host definition and always use 0.0.0.0

Keep the port logic as is
...

Done in 7c58be7. Removed --callback-host / GOOGLE_WORKSPACE_CLI_CALLBACK_HOST entirely. The callback server now always binds to 0.0.0.0:{port} and always uses localhost in the redirect URI. Port logic (default 0 = OS-assigned, --callback-port / GOOGLE_WORKSPACE_CLI_CALLBACK_PORT) is unchanged.

Copilot AI changed the title feat: configurable OAuth callback host and port for gws auth login feat: configurable OAuth callback port for gws auth login Apr 6, 2026
ilteoood and others added 2 commits April 6, 2026 11:56
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
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.

2 participants