From 2ce3b86e0ff69538935db3149d1ed2f24aea09a3 Mon Sep 17 00:00:00 2001 From: Ben Burwell Date: Mon, 13 Apr 2020 23:57:13 -0400 Subject: Simplify --- client/client.go | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) (limited to 'client') diff --git a/client/client.go b/client/client.go index b84e09a..22194d2 100644 --- a/client/client.go +++ b/client/client.go @@ -1,7 +1,6 @@ package client import ( - "bufio" "bytes" "crypto/tls" "encoding/base64" @@ -11,9 +10,7 @@ import ( "io/ioutil" "net/http" "net/url" - "os" "path" - "strings" "time" "github.com/nsheridan/cashier/lib" @@ -22,10 +19,6 @@ import ( "golang.org/x/crypto/ssh/agent" ) -var ( - errNeedsReason = errors.New("reason required") -) - // SavePublicFiles installs the public part of the cert and key. func SavePublicFiles(prefix string, cert *ssh.Certificate, pub ssh.PublicKey) error { if prefix == "" { @@ -114,9 +107,6 @@ func send(sr *lib.SignRequest, token, ca string, ValidateTLSCertificate bool) (* defer resp.Body.Close() signResponse := &lib.SignResponse{} if resp.StatusCode != http.StatusOK { - if resp.StatusCode == http.StatusForbidden && strings.HasPrefix(resp.Header.Get("X-Need-Reason"), "required") { - return signResponse, errNeedsReason - } return signResponse, fmt.Errorf("bad response from server: %s", resp.Status) } if err := json.NewDecoder(resp.Body).Decode(signResponse); err != nil { @@ -125,15 +115,6 @@ func send(sr *lib.SignRequest, token, ca string, ValidateTLSCertificate bool) (* return signResponse, nil } -func promptForReason() (message string) { - fmt.Print("Enter message: ") - scanner := bufio.NewScanner(os.Stdin) - if scanner.Scan() { - message = scanner.Text() - } - return message -} - // Sign sends the public key to the CA to be signed. func Sign(pub ssh.PublicKey, token string, conf *Config) (*ssh.Certificate, error) { var err error @@ -152,10 +133,7 @@ func Sign(pub ssh.PublicKey, token string, conf *Config) (*ssh.Certificate, erro if err == nil { break } - if err != nil && err == errNeedsReason { - s.Message = promptForReason() - continue - } else if err != nil { + if err != nil { return nil, errors.Wrap(err, "error sending request to CA") } } -- cgit v1.2.3