Configurable auto signoff duration

This commit is contained in:
LittleSheep 2024-12-29 22:21:56 +08:00
parent f33497d002
commit 9c0abdb46f

View File

@ -2,11 +2,13 @@ package services
import ( import (
"fmt" "fmt"
"git.solsynth.dev/hypernet/passport/pkg/authkit/models"
"gorm.io/datatypes"
"time" "time"
"git.solsynth.dev/hypernet/passport/pkg/authkit/models"
"gorm.io/datatypes"
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"
"github.com/spf13/viper"
"github.com/google/uuid" "github.com/google/uuid"
@ -214,7 +216,7 @@ func RotateTicket(ticket models.AuthTicket, fullyRestart ...bool) (models.AuthTi
} }
func DoAutoSignoff() { func DoAutoSignoff() {
duration := 7 * 24 * time.Hour duration := viper.GetDuration("security.auto_signoff") * time.Second
deadline := time.Now().Add(-duration) deadline := time.Now().Add(-duration)
log.Debug().Time("before", deadline).Msg("Now signing off tickets...") log.Debug().Time("before", deadline).Msg("Now signing off tickets...")