fix(cli): surface auth URL so headless logins can complete
Closed
JO
6mo ago+30+30+01234567890123456789-4-4-0123456789
Summary
Closes #3949.
superset auth login hangs on headless Linux hosts because openBrowser() invokes xdg-open via fire-and-forget exec() — when xdg-open is missing the failure is silent and no URL is ever surfaced.
Fix
- Add an optional
onAuthUrl(url)callback to a newLoginOptionsinterface inlib/auth.ts. - Refactor
login(signal)→login(options). Single internal caller updated. - In the auth command, the callback prints the URL via
p.log.info(...). On TTY clack interleaves it with the running spinner; on non-TTY it's a clean info line.
Browser auto-launch is unchanged for GUI users — openBrowser() is still invoked after the URL is surfaced.
Test plan
- On macOS (TTY): browser still opens; URL also appears as a
p.log.infoline, interleaves cleanly with the spinner. - On Linux ARM64 headless (Hetzner Neoverse-N1, no
xdg-open): URL is now printed. Combined withssh -L 51789:localhost:51789 <host>the OAuth loopback callback completes through the tunnel and CLI logs in successfully. -
bun run lint:fix && bun run typecheck— couldn't run locally; relying on CI.
Scope
packages/cli/src/lib/auth.ts— newLoginOptions;login()signature refactor; URL hoisted to a const;onAuthUrlinvoked beforeopenBrowser.packages/cli/src/commands/auth/login/command.ts— pass options including the callback.
Out of scope (potential follow-ups)
openBrowser()still doesn't actually awaitexec()completion. Surfacing the URL eagerly sidesteps that for users; makingopenBrowsertruly synchronous is a separate change.- A
--no-browserflag for purely scripted flows.
Summary by cubic
Print the OAuth authorization URL during superset auth login so headless Linux hosts can complete login when no default browser is available. Auto-launch still works; this adds a visible URL fallback.
- Bug Fixes
- Added
LoginOptionswith optionalonAuthUrl(url)and refactoredlogin(signal)tologin({ signal, ... }). - The auth command logs the URL before launching the browser, allowing copy/paste on headless hosts.
- If an
onAuthUrlcallback throws, close the loopback server to avoid port leaks and “All loopback ports in use” errors.
- Added
Summary by CodeRabbit
- Improvements
- Enhanced authentication flow: the app now exposes a handler to surface the authorization URL and will print a fallback message with the URL during login if needed, improving visibility and reliability when completing sign-in from the browser.