@@ -16,12 +16,14 @@ package main
1616
1717import (
1818 "context"
19+ "crypto/tls"
1920 "encoding/json"
2021 "errors"
2122 "fmt"
2223 "io"
2324 "io/fs"
2425 "net"
26+ "net/http"
2527 "net/url"
2628 "os"
2729 "os/signal"
@@ -224,6 +226,18 @@ func (r *appState) import_(cliCtx *cli.Context) error {
224226func (r * appState ) login (cliCtx * cli.Context ) error {
225227 ctx := cliCtx .Context
226228
229+ if cliCtx .Bool ("insecure" ) {
230+ fmt .Fprintf (cliCtx .App .ErrWriter , "Warning: server TLS validation is disabled\n " )
231+ httpClient := & http.Client {
232+ Transport : & http.Transport {
233+ TLSClientConfig : & tls.Config {
234+ InsecureSkipVerify : true ,
235+ },
236+ },
237+ }
238+ ctx = context .WithValue (ctx , oauth2 .HTTPClient , httpClient )
239+ }
240+
227241 if cliCtx .NArg () != 1 {
228242 return autherr .CodedErrorf (autherr .CodeBadParams , "expected exactly 1 positional argument, a cluster name" )
229243 }
@@ -349,6 +363,10 @@ func makeApp(root *appState) *cli.App {
349363 Name : "alias" ,
350364 Usage : "Comma-separated list of alias hostnames for this cluster" ,
351365 }
366+ insecureFlag := & cli.BoolFlag {
367+ Name : "insecure" ,
368+ Usage : "Disable server TLS validation" ,
369+ }
352370
353371 app := & cli.App {
354372 Name : "engflow_auth" ,
@@ -386,7 +404,7 @@ credential helper protocol.`),
386404Initiates an interactive OAuth2 flow to log into the cluster at
387405CLUSTER_URL.` ),
388406 Action : root .login ,
389- Flags : []cli.Flag {aliasFlag , storeFlag },
407+ Flags : []cli.Flag {aliasFlag , storeFlag , insecureFlag },
390408 },
391409 {
392410 Name : "logout" ,
0 commit comments