timing attack

This commit is contained in:
Daniel Ponte 2024-07-15 22:44:17 -04:00
parent e30896ee4c
commit 054ea37239

View file

@ -42,13 +42,14 @@ func (s *Server) Login(ctx context.Context, username, password string) (token st
}
if found == nil {
_ = bcrypt.CompareHashAndPassword([]byte("lol@timing"), []byte(password))
return "", ErrLoginFailed
}
} else {
err = bcrypt.CompareHashAndPassword([]byte(found.Password), []byte(password))
if err != nil {
return "", ErrLoginFailed
}
}
return s.NewToken(found.ID), nil
}