fix: preserve legacy JWT lifetime semantics
This commit is contained in:
@@ -186,11 +186,11 @@ type jwtClaims struct {
|
|||||||
jwt.StandardClaims
|
jwt.StandardClaims
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewToken(username string, timeoutMinutes int) (string, error) {
|
func NewToken(username string, _ int) (string, error) {
|
||||||
if timeoutMinutes <= 0 {
|
// CHFS v4 keeps the JWT itself valid for one year. session.timeout is
|
||||||
timeoutMinutes = 30
|
// retained as a compatibility configuration field, but it does not alter
|
||||||
}
|
// the JWT exp claim in the original implementation.
|
||||||
claims := jwtClaims{Acc: username, StandardClaims: jwt.StandardClaims{ExpiresAt: time.Now().Add(time.Duration(timeoutMinutes) * time.Minute).Unix()}}
|
claims := jwtClaims{Acc: username, StandardClaims: jwt.StandardClaims{ExpiresAt: time.Now().Add(365 * 24 * time.Hour).Unix()}}
|
||||||
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
|
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
|
||||||
return token.SignedString([]byte(jwtSecret))
|
return token.SignedString([]byte(jwtSecret))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user