master
Bel LaPointe 2019-03-06 14:11:18 -07:00
parent bf638ad193
commit b1d98520c3
1 changed files with 5 additions and 5 deletions

10
main.go
View File

@ -17,7 +17,7 @@ import (
func main() {
var path, host, method, body, headers, brandID, issuer string
var ca, cert, key string
var ca, cert, key, secret string
var needJWT, verbose bool
var timeout time.Duration
flag.StringVar(&method, "method", "get", "method for request")
@ -33,6 +33,7 @@ func main() {
flag.StringVar(&ca, "ca", "", "ca for server")
flag.StringVar(&cert, "cert", "", "cert for client")
flag.StringVar(&key, "key", "", "key for client")
flag.StringVar(&secret, "secret", "dnKgzTPNZyEd2Kfop", "secret for jwt")
flag.Parse()
if !strings.HasPrefix(host, "http") {
@ -45,7 +46,6 @@ func main() {
host+"/"+strings.Trim(path, "/"),
strings.NewReader(body),
)
fmt.Println(req)
if err != nil {
panic(err)
}
@ -56,7 +56,7 @@ func main() {
}
}
if needJWT {
setJWT(req, brandID, issuer)
setJWT(req, brandID, issuer, secret)
}
if verbose {
@ -107,9 +107,9 @@ func makeClient(timeout time.Duration, ca, cert, key string) *http.Client {
}
}
func setJWT(r *http.Request, brandID string, issuer string) {
func setJWT(r *http.Request, brandID string, issuer string, secret string) {
signer := &jwt.Signer{
Key: []byte("dnKgzTPNZyEd2Kfop"),
Key: []byte(secret),
DefaultClaims: jwt.Claims{
Audience: "qualtrics",
Issuer: issuer,