fix: normalize API key expiry timestamps to UTC (#2137)

Store authorization timestamps as timestamptz and normalize Unix expiry
inputs to UTC so tenant/platform API keys expire at the intended instant
even when the app process timezone differs from the PostgreSQL session.
This commit is contained in:
wizardchen
2026-07-21 18:24:16 +08:00
committed by lyingbug
parent 59fed12643
commit 0f2c6cee11
9 changed files with 150 additions and 12 deletions
+2 -2
View File
@@ -150,8 +150,8 @@ func (h *SystemHandler) CreatePlatformAPIKey(c *gin.Context) {
}
var expiresAt *time.Time
if req.ExpiresAt != nil {
value := time.Unix(*req.ExpiresAt, 0)
if !value.After(time.Now()) {
value := time.Unix(*req.ExpiresAt, 0).UTC()
if !value.After(time.Now().UTC()) {
c.Error(apperrors.NewValidationError("expires_at_unix must be in the future"))
return
}
+2 -2
View File
@@ -685,8 +685,8 @@ func (h *TenantHandler) CreateAPIKey(c *gin.Context) {
}
var expiresAt *time.Time
if req.ExpiresAt != nil {
t := time.Unix(*req.ExpiresAt, 0)
if !t.After(time.Now()) {
t := time.Unix(*req.ExpiresAt, 0).UTC()
if !t.After(time.Now().UTC()) {
c.Error(errors.NewValidationError("expires_at_unix must be in the future"))
return
}