mirror of
https://github.com/pomerium/pomerium.git
synced 2025-06-13 16:24:16 +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
|
@ -2,14 +2,18 @@ package authclient
|
|||
|
||||
import (
|
||||
"crypto/tls"
|
||||
|
||||
"github.com/skratchdot/open-golang/open"
|
||||
)
|
||||
|
||||
type config struct {
|
||||
open func(rawURL string) error
|
||||
tlsConfig *tls.Config
|
||||
}
|
||||
|
||||
func getConfig(options ...Option) *config {
|
||||
cfg := new(config)
|
||||
WithBrowserCommand("")(cfg)
|
||||
for _, o := range options {
|
||||
o(cfg)
|
||||
}
|
||||
|
@ -19,6 +23,19 @@ func getConfig(options ...Option) *config {
|
|||
// An Option modifies the config.
|
||||
type Option func(*config)
|
||||
|
||||
// WithBrowserCommand returns an option to configure the browser command.
|
||||
func WithBrowserCommand(browserCommand string) Option {
|
||||
return func(cfg *config) {
|
||||
if browserCommand == "" {
|
||||
cfg.open = open.Run
|
||||
} else {
|
||||
cfg.open = func(rawURL string) error {
|
||||
return open.RunWith(rawURL, browserCommand)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// WithTLSConfig returns an option to configure the tls config.
|
||||
func WithTLSConfig(tlsConfig *tls.Config) Option {
|
||||
return func(cfg *config) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue