Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion cmd/engflow_auth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ package main

import (
"context"
"crypto/tls"
"encoding/json"
"errors"
"fmt"
"io"
"io/fs"
"net"
"net/http"
"net/url"
"os"
"os/signal"
Expand Down Expand Up @@ -224,6 +226,18 @@ func (r *appState) import_(cliCtx *cli.Context) error {
func (r *appState) login(cliCtx *cli.Context) error {
ctx := cliCtx.Context

if cliCtx.Bool("insecure") {
fmt.Fprintf(cliCtx.App.ErrWriter, "Warning: server TLS validation is disabled\n")
httpClient := &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
},
},
}
ctx = context.WithValue(ctx, oauth2.HTTPClient, httpClient)
}

if cliCtx.NArg() != 1 {
return autherr.CodedErrorf(autherr.CodeBadParams, "expected exactly 1 positional argument, a cluster name")
}
Expand Down Expand Up @@ -349,6 +363,10 @@ func makeApp(root *appState) *cli.App {
Name: "alias",
Usage: "Comma-separated list of alias hostnames for this cluster",
}
insecureFlag := &cli.BoolFlag{
Name: "insecure",
Usage: "Disable server TLS validation",
}

app := &cli.App{
Name: "engflow_auth",
Expand Down Expand Up @@ -386,7 +404,7 @@ credential helper protocol.`),
Initiates an interactive OAuth2 flow to log into the cluster at
CLUSTER_URL.`),
Action: root.login,
Flags: []cli.Flag{aliasFlag, storeFlag},
Flags: []cli.Flag{aliasFlag, storeFlag, insecureFlag},
},
{
Name: "logout",
Expand Down