fix passkey

server/internal/passkey/passkey.go
 的 takeSession,过期校验只在显式设置了 Expires 时才生效(与 go-webauthn 库内部 !IsZero() 的检查一致)
This commit is contained in:
Sakurasan
2026-08-19 00:00:51 +08:00
parent 8495694671
commit 3e7efb3c88
2 changed files with 60 additions and 1 deletions
+4 -1
View File
@@ -235,7 +235,10 @@ func (s *Service) takeSession(challenge string) (webauthn.SessionData, bool) {
delete(s.sessions, challenge)
}
s.mu.Unlock()
if ok && time.Now().After(sess.Expires) {
// Expires 可能为零值:go-webauthn 默认 Enforce=false 不设过期时间。
// 零值时间恒早于 now,直接 After 会把每个 challenge 都判为过期,
// 与库内部一致,仅当显式设置了过期时间才做校验。
if ok && !sess.Expires.IsZero() && time.Now().After(sess.Expires) {
return webauthn.SessionData{}, false
}
return sess, ok