feat: publish sanitized custom.97 source
This commit is contained in:
1022 files changed
+69903
-19207
No files matched your search
+12
-8
@@ -1,7 +1,6 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/QuantumNous/new-api/common"
|
||||
@@ -10,8 +9,9 @@ import (
|
||||
|
||||
const authArtifactCleanupInterval = time.Hour
|
||||
|
||||
// StartAuthArtifactCleanup removes expired dashboard Sessions and old
|
||||
// one-time authentication flows. Only the master instance performs cleanup.
|
||||
// StartAuthArtifactCleanup removes expired dashboard Sessions, old one-time
|
||||
// authentication flows and access tokens that expired beyond the revoked
|
||||
// session retention. Only the master instance performs cleanup.
|
||||
func StartAuthArtifactCleanup() {
|
||||
if !common.IsMasterNode {
|
||||
return
|
||||
@@ -30,9 +30,9 @@ func cleanupAuthArtifacts() {
|
||||
now := time.Now()
|
||||
count, err := model.CountUserSessionsCreatedSince(0, now.Add(-time.Hour).Unix())
|
||||
if err != nil {
|
||||
common.SysError("failed to count hourly user session issuance: " + err.Error())
|
||||
common.SysError(common.LogText("failed to count hourly user session issuance: %s", err.Error()))
|
||||
} else if count > int64(common.UserSessionHourlyAlertThreshold) {
|
||||
common.SysError(fmt.Sprintf(
|
||||
common.SysError(common.LogText(
|
||||
"hourly user session issuance exceeded alert threshold: count=%d threshold=%d window_seconds=%d",
|
||||
count,
|
||||
common.UserSessionHourlyAlertThreshold,
|
||||
@@ -40,12 +40,16 @@ func cleanupAuthArtifacts() {
|
||||
))
|
||||
}
|
||||
if err := model.DeleteExpiredUserSessions(now.Unix()); err != nil {
|
||||
common.SysError("failed to delete expired user sessions: " + err.Error())
|
||||
common.SysError(common.LogText("failed to delete expired user sessions: %s", err.Error()))
|
||||
}
|
||||
if err := model.DeleteOldRevokedUserSessions(now.Unix()); err != nil {
|
||||
common.SysError("failed to delete old revoked user sessions: " + err.Error())
|
||||
common.SysError(common.LogText("failed to delete old revoked user sessions: %s", err.Error()))
|
||||
}
|
||||
if err := model.DeleteExpiredAuthFlows(now); err != nil {
|
||||
common.SysError("failed to delete expired authentication flows: " + err.Error())
|
||||
common.SysError(common.LogText("failed to delete expired authentication flows: %s", err.Error()))
|
||||
}
|
||||
accessTokenExpiredBefore := now.Unix() - int64(common.UserSessionRevokedRetentionDays)*24*60*60
|
||||
if err := model.DeleteExpiredUserAccessTokens(accessTokenExpiredBefore); err != nil {
|
||||
common.SysError(common.LogText("failed to delete expired access tokens: %s", err.Error()))
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user