chore(lib): fix SA4004

Signed-off-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
Xe Iaso 2025-07-03 04:08:32 +00:00
parent b8e0c1a961
commit e538f55e89
No known key found for this signature in database

View File

@ -94,9 +94,13 @@ func (s *Server) getTokenKeyfunc() jwt.Keyfunc {
func (s *Server) challengeFor(r *http.Request) (*challenge.Challenge, error) {
ckies := r.CookiesNamed(anubis.TestCookieName)
if len(ckies) == 0 {
return s.issueChallenge(r.Context(), r)
}
j := store.JSON[challenge.Challenge]{Underlying: s.store}
for _, ckie := range ckies {
ckie := ckies[0]
chall, err := j.Get(r.Context(), "challenge:"+ckie.Value)
if err != nil {
return nil, err
@ -105,9 +109,6 @@ func (s *Server) challengeFor(r *http.Request) (*challenge.Challenge, error) {
return &chall, nil
}
return s.issueChallenge(r.Context(), r)
}
func (s *Server) issueChallenge(ctx context.Context, r *http.Request) (*challenge.Challenge, error) {
id, err := uuid.NewV7()
if err != nil {