From 850052c4a5644c7b7553e211c29c8b035f3e4422 Mon Sep 17 00:00:00 2001 From: Bel LaPointe Date: Fri, 19 Apr 2019 07:23:57 -0600 Subject: [PATCH] basic auth --- main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index f9fdcc5..6066bf3 100644 --- a/main.go +++ b/main.go @@ -24,7 +24,7 @@ type LagReader struct { func main() { var bodyRepeat int - var path, host, method, body, headers, brandID, issuer string + var path, host, method, body, headers, brandID, issuer, basicAuth string var ca, cert, key, secret string var needJWT, verbose, jsonPP bool var timeout, lag time.Duration @@ -34,6 +34,7 @@ func main() { flag.StringVar(&body, "body", "", "body for request") flag.IntVar(&bodyRepeat, "bodyrepeat", 1, "repeat body for request") flag.StringVar(&brandID, "brand", "testencresponse", "brandID for request JWT") + flag.StringVar(&basicAuth, "auth", "", "comma separated user,password for basic auth") flag.StringVar(&headers, "headers", "", "headers as k=v,k=v for request") flag.StringVar(&issuer, "issuer", "dataprocessing,responseengine,fieldset-definitions,qualtrics,objectstore,svs,monolith,ex,blixt,null,responseengine", "issuer for jwt") flag.BoolVar(&needJWT, "jwt", true, "need jwt boolean") @@ -77,6 +78,10 @@ func main() { if needJWT { setJWT(req, brandID, issuer, secret) } + if basicAuth != "" { + splits := strings.Split(basicAuth, ",") + req.SetBasicAuth(splits[0], splits[1]) + } if verbose { fmt.Fprintf(os.Stderr, "%v\n", req)