1
0
mirror of https://github.com/smallstep/cli.git synced 2025-08-09 03:22:43 +03:00

Add STEP_OPEN_BROWSER env var to skip opening a browser and just output the authURL.

This commit is contained in:
Joe Doss
2025-02-11 16:25:39 -06:00
committed by Herman Slatman
parent f5a0bca360
commit c8872948a4

View File

@@ -784,18 +784,24 @@ func (o *oauth) DoLoopbackAuthorization() (*token, error) {
return nil, err return nil, err
} }
if err := exec.OpenInBrowser(authURL, o.browser); err != nil { skipBrowser := os.Getenv("STEP_OPEN_BROWSER") == "false"
fmt.Fprintln(os.Stderr, "Cannot open a web browser on your platform.")
fmt.Fprintln(os.Stderr) if !skipBrowser {
fmt.Fprintln(os.Stderr, "Open a local web browser and visit:") if err := exec.OpenInBrowser(authURL, o.browser); err != nil {
fmt.Fprintln(os.Stderr) fmt.Fprintln(os.Stderr, "Cannot open a web browser on your platform.")
fmt.Fprintln(os.Stderr, authURL) fmt.Fprintln(os.Stderr)
fmt.Fprintln(os.Stderr) fmt.Fprintln(os.Stderr, "Open a local web browser and visit:")
fmt.Fprintln(os.Stderr)
fmt.Fprintln(os.Stderr, authURL)
fmt.Fprintln(os.Stderr)
} else {
fmt.Fprintln(os.Stderr, "Your default web browser has been opened to visit:")
fmt.Fprintln(os.Stderr)
fmt.Fprintln(os.Stderr, authURL)
fmt.Fprintln(os.Stderr)
}
} else { } else {
fmt.Fprintln(os.Stderr, "Your default web browser has been opened to visit:") fmt.Fprintln(os.Stderr, authURL)
fmt.Fprintln(os.Stderr)
fmt.Fprintln(os.Stderr, authURL)
fmt.Fprintln(os.Stderr)
} }
// Wait for response and return the token // Wait for response and return the token