-
Notifications
You must be signed in to change notification settings - Fork 377
Description
Problem
gws auth login starts a local HTTP server on a random port for the OAuth callback. This works great on local machines, but on remote dev servers (SSH), localhost in the browser doesn't reach the remote machine. The current workaround is:
- Run
gws auth loginand note the random port in the redirect URL - Open a second terminal and set up SSH port forwarding (
ssh -L <port>:localhost:<port> host) - Open the auth URL in the browser
The port changes every run, so this can't be pre-configured. It's the biggest friction point in setting up gws on a remote machine.
Proposed solution
The underlying yup_oauth2 library already supports two alternatives to the random-port flow via InstalledFlowReturnMethod:
pub enum InstalledFlowReturnMethod {
Interactive, // copy-paste code, no HTTP server
HTTPRedirect, // random port (current behavior)
HTTPPortRedirect(u16), // fixed port
}1. --port PORT flag
Use HTTPPortRedirect(port) instead of HTTPRedirect when specified. This lets users pre-configure a fixed SSH tunnel (e.g. in ~/.ssh/config) and never think about ports again.
gws auth login --account user@example.com --port 34899# ~/.ssh/config — one-time setup
Host devbox
LocalForward 34899 localhost:34899
2. --no-browser flag
Use InstalledFlowReturnMethod::Interactive, which displays a URL, the user opens it manually, and pastes the authorization code back into the terminal. No HTTP server, no port forwarding needed at all. This is the same pattern gcloud auth login --no-launch-browser uses.
gws auth login --account user@example.com --no-browserScope
Both changes are small — the flag parsing and flow-method selection in auth_commands.rs, roughly:
let method = if let Some(port) = port_flag {
yup_oauth2::InstalledFlowReturnMethod::HTTPPortRedirect(port)
} else if no_browser {
yup_oauth2::InstalledFlowReturnMethod::Interactive
} else {
yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect
};Environment
- Remote Linux devbox (Debian 11) accessed via SSH
gwsv0.5.0 built from source with Cargo