pomerium-cli: add support for a custom browser command (#2617)

This commit is contained in:
Caleb Doxsey 2021-09-21 08:31:30 -06:00 committed by GitHub
parent efffe57bf0
commit a7442b1498
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 58 additions and 17 deletions

View file

@ -16,6 +16,7 @@ import (
)
func init() {
addBrowserFlags(kubernetesExecCredentialCmd)
addTLSFlags(kubernetesExecCredentialCmd)
kubernetesCmd.AddCommand(kubernetesExecCredentialCmd)
kubernetesCmd.AddCommand(kubernetesFlushCredentialsCmd)
@ -61,7 +62,9 @@ var kubernetesExecCredentialCmd = &cobra.Command{
tlsConfig = getTLSConfig()
}
ac := authclient.New(authclient.WithTLSConfig(tlsConfig))
ac := authclient.New(
authclient.WithBrowserCommand(browserOptions.command),
authclient.WithTLSConfig(tlsConfig))
rawJWT, err := ac.GetJWT(context.Background(), serverURL)
if err != nil {
fatalf("%s", err)

View file

@ -57,3 +57,13 @@ func getTLSConfig() *tls.Config {
}
return cfg
}
var browserOptions struct {
command string
}
func addBrowserFlags(cmd *cobra.Command) {
flags := cmd.Flags()
flags.StringVar(&browserOptions.command, "browser-cmd", "",
"custom browser command to run when opening a URL")
}

View file

@ -87,6 +87,7 @@ var tcpCmd = &cobra.Command{
}()
tun := tcptunnel.New(
tcptunnel.WithBrowserCommand(browserOptions.command),
tcptunnel.WithDestinationHost(dstHost),
tcptunnel.WithProxyHost(pomeriumURL.Host),
tcptunnel.WithTLSConfig(tlsConfig),