mirror of
https://github.com/pomerium/pomerium.git
synced 2025-06-09 06:12:42 +02:00
pomerium-cli: add support for a custom browser command (#2617)
This commit is contained in:
parent
efffe57bf0
commit
a7442b1498
8 changed files with 58 additions and 17 deletions
|
@ -9,14 +9,12 @@ import (
|
|||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/skratchdot/open-golang/open"
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
||||
var openBrowser = open.Run
|
||||
|
||||
// An AuthClient retrieves an authentication JWT via the Pomerium login API.
|
||||
type AuthClient struct {
|
||||
cfg *config
|
||||
|
@ -141,5 +139,11 @@ func (client *AuthClient) runOpenBrowser(ctx context.Context, li net.Listener, s
|
|||
return fmt.Errorf("failed to read login url: %w", err)
|
||||
}
|
||||
|
||||
return openBrowser(string(bs))
|
||||
err = client.cfg.open(string(bs))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to open browser url: %w", err)
|
||||
}
|
||||
|
||||
_, _ = fmt.Fprintf(os.Stderr, "Your browser has been opened to visit:\n\n%s\n\n", string(bs))
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue