Auth config to limit auth steps

This commit is contained in:
2024-10-13 01:45:08 +08:00
parent 0f18c6ff16
commit 9287e6c5cc
6 changed files with 60 additions and 9 deletions

View File

@ -54,7 +54,11 @@ func NewTicket(user models.Account, ip, ua string) (models.AuthTicket, error) {
if count := CountUserFactor(user.ID); count <= 0 {
return ticket, fmt.Errorf("specified user didn't enable sign in")
} else {
cfg := user.AuthConfig.Data()
steps = min(steps, int(count))
if cfg.MaximumAuthSteps >= 1 {
steps = min(steps, cfg.MaximumAuthSteps)
}
}
ticket = models.AuthTicket{