From 1e5ba290c4088ffaaa99c9bdc0727cf8786f65de Mon Sep 17 00:00:00 2001 From: grumbulon Date: Fri, 20 Jan 2023 10:10:27 -0500 Subject: [PATCH] make jwt expiration consistent with cookies --- internal/api/jwt.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/api/jwt.go b/internal/api/jwt.go index abb5d11..84d2fda 100644 --- a/internal/api/jwt.go +++ b/internal/api/jwt.go @@ -2,6 +2,7 @@ package api import ( "fmt" + "time" "git.freecumextremist.com/grumbulon/pomme/internal" "github.com/go-chi/jwtauth/v5" @@ -16,7 +17,11 @@ func init() { } func makeToken(username string) (tokenString string, err error) { - if _, tokenString, err = tokenAuth.Encode(map[string]interface{}{"username": username, "admin": "false"}); err == nil { + claim := map[string]interface{}{"username": username, "admin": false} + + jwtauth.SetExpiry(claim, time.Now().Add(time.Hour)) + + if _, tokenString, err = tokenAuth.Encode(claim); err == nil { return }