Fix: cookie timeout
All checks were successful
Go test / run-go-vet (push) Successful in 6s
Go test / check-swagger-up-to-date (push) Successful in 10s
Go test / run-go-test (push) Successful in 36s
Go test / cleanup-go-test (push) Successful in 14s
Go test / release-image (push) Successful in 3m20s

This commit is contained in:
2025-12-12 02:09:46 +08:00
parent 87ae3b76c2
commit 1cf3a9ef0b
6 changed files with 57 additions and 8 deletions

View File

@@ -3,6 +3,7 @@ package middlewares
import (
"context"
"net/http"
"time"
"gitea.konchin.com/go2025/backend/interfaces"
"gitea.konchin.com/go2025/backend/models"
@@ -46,10 +47,12 @@ func refreshAccessToken(
}
http.SetCookie(w, &http.Cookie{
Name: "access_token",
Value: ret,
Path: "/",
Secure: false,
Name: "access_token",
Value: ret,
Path: "/",
Secure: viper.GetBool("https"),
Expires: time.Now().Add(time.Duration(
viper.GetInt64("access-token-timeout")) * time.Second),
HttpOnly: true,
SameSite: http.SameSiteLaxMode,
})