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:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user