@@ -481,6 +481,7 @@ func prepareJWTToken(config *Config) (string, error) {
481
481
if config .PrivateKey == nil {
482
482
return "" , errors .New ("trying to use keypair authentication, but PrivateKey was not provided in the driver config" )
483
483
}
484
+ logger .Debug ("preparing JWT for keypair authentication" )
484
485
pubBytes , err := x509 .MarshalPKIXPublicKey (config .PrivateKey .Public ())
485
486
if err != nil {
486
487
return "" , err
@@ -491,20 +492,22 @@ func prepareJWTToken(config *Config) (string, error) {
491
492
userName := strings .ToUpper (config .User )
492
493
493
494
issueAtTime := time .Now ().UTC ()
494
- token := jwt . NewWithClaims ( jwt . SigningMethodRS256 , jwt.MapClaims {
495
+ jwtClaims := jwt.MapClaims {
495
496
"iss" : fmt .Sprintf ("%s.%s.%s" , accountName , userName , "SHA256:" + base64 .StdEncoding .EncodeToString (hash [:])),
496
497
"sub" : fmt .Sprintf ("%s.%s" , accountName , userName ),
497
498
"iat" : issueAtTime .Unix (),
498
499
"nbf" : time .Date (2015 , 10 , 10 , 12 , 0 , 0 , 0 , time .UTC ).Unix (),
499
500
"exp" : issueAtTime .Add (config .JWTExpireTimeout ).Unix (),
500
- })
501
+ }
502
+ token := jwt .NewWithClaims (jwt .SigningMethodRS256 , jwtClaims )
501
503
502
504
tokenString , err := token .SignedString (config .PrivateKey )
503
505
504
506
if err != nil {
505
507
return "" , err
506
508
}
507
509
510
+ logger .Debugf ("successfully generated JWT with following claims: %v" , jwtClaims )
508
511
return tokenString , err
509
512
}
510
513
0 commit comments