Skip to content

Commit 40c6c21

Browse files
NO-SNOW log JWT claims on debug loglevel (#1309)
1 parent 6988c5f commit 40c6c21

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

auth.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ func prepareJWTToken(config *Config) (string, error) {
481481
if config.PrivateKey == nil {
482482
return "", errors.New("trying to use keypair authentication, but PrivateKey was not provided in the driver config")
483483
}
484+
logger.Debug("preparing JWT for keypair authentication")
484485
pubBytes, err := x509.MarshalPKIXPublicKey(config.PrivateKey.Public())
485486
if err != nil {
486487
return "", err
@@ -491,20 +492,22 @@ func prepareJWTToken(config *Config) (string, error) {
491492
userName := strings.ToUpper(config.User)
492493

493494
issueAtTime := time.Now().UTC()
494-
token := jwt.NewWithClaims(jwt.SigningMethodRS256, jwt.MapClaims{
495+
jwtClaims := jwt.MapClaims{
495496
"iss": fmt.Sprintf("%s.%s.%s", accountName, userName, "SHA256:"+base64.StdEncoding.EncodeToString(hash[:])),
496497
"sub": fmt.Sprintf("%s.%s", accountName, userName),
497498
"iat": issueAtTime.Unix(),
498499
"nbf": time.Date(2015, 10, 10, 12, 0, 0, 0, time.UTC).Unix(),
499500
"exp": issueAtTime.Add(config.JWTExpireTimeout).Unix(),
500-
})
501+
}
502+
token := jwt.NewWithClaims(jwt.SigningMethodRS256, jwtClaims)
501503

502504
tokenString, err := token.SignedString(config.PrivateKey)
503505

504506
if err != nil {
505507
return "", err
506508
}
507509

510+
logger.Debugf("successfully generated JWT with following claims: %v", jwtClaims)
508511
return tokenString, err
509512
}
510513

0 commit comments

Comments
 (0)