mirror of
				https://github.com/ClusterCockpit/cc-backend
				synced 2025-11-04 09:35:07 +01:00 
			
		
		
		
	Fix bug with jwt max-age option
This commit is contained in:
		@@ -130,8 +130,12 @@ func (ja *JWTAuthenticator) ProvideJWT(user *schema.User) (string, error) {
 | 
				
			|||||||
		"roles": user.Roles,
 | 
							"roles": user.Roles,
 | 
				
			||||||
		"iat":   now.Unix(),
 | 
							"iat":   now.Unix(),
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if ja.config != nil && ja.config.MaxAge != 0 {
 | 
						if ja.config != nil && ja.config.MaxAge != "" {
 | 
				
			||||||
		claims["exp"] = now.Add(time.Duration(ja.config.MaxAge)).Unix()
 | 
							d, err := time.ParseDuration(ja.config.MaxAge)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return "", errors.New("cannot parse max-age config key")
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							claims["exp"] = now.Add(d).Unix()
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return jwt.NewWithClaims(jwt.SigningMethodEdDSA, claims).SignedString(ja.privateKey)
 | 
						return jwt.NewWithClaims(jwt.SigningMethodEdDSA, claims).SignedString(ja.privateKey)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user