fix: sesión sin vencimiento práctico (90 años JWT + cookie persistente)
- JWT exp: 1 año → 90 años - Cookie Verify-Rest-Token: sin MaxAge (session cookie) → MaxAge 90 años - Session store: 1 año → 90 años Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
b3b6f6705d
commit
2ee5e2ea83
+3
-1
@@ -21,10 +21,11 @@ func (t *Token) CreateToken(c *fiber.Ctx, userID uint, secret string, expire ...
|
||||
|
||||
claims := token.Claims.(jwt.MapClaims)
|
||||
claims["id"] = userID
|
||||
const ninetyYears = int64(90 * 365 * 24 * 3600)
|
||||
if len(expire) > 0 {
|
||||
t.Expire = expire[0]
|
||||
} else {
|
||||
t.Expire = 31536000 // 1 año por defecto si no se configura
|
||||
t.Expire = ninetyYears
|
||||
}
|
||||
expiresIn := time.Now().Add(time.Duration(t.Expire) * time.Second).Unix()
|
||||
claims["exp"] = expiresIn
|
||||
@@ -37,6 +38,7 @@ func (t *Token) CreateToken(c *fiber.Ctx, userID uint, secret string, expire ...
|
||||
c.Cookie(&fiber.Cookie{
|
||||
Name: "Verify-Rest-Token",
|
||||
Value: tokenHash,
|
||||
MaxAge: int(ninetyYears),
|
||||
Secure: false,
|
||||
HTTPOnly: true,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user