fix(token): utilize a more accurate comparison method (#5594)

This commit is contained in:
Damian Debkowski authored and GitHub committed 2025-03-13 15:08:09 -07:00
1 parent 132a52c5d9
commit 32be170562
1 file changed
+2 -1
+2 -1
View File
@@ -5,6 +5,7 @@ package authtoken
import (
"context"
"crypto/subtle"
"database/sql"
"fmt"
"time"
@@ -240,7 +241,7 @@ func (r *Repository) ValidateToken(ctx context.Context, id, token string, opt ..
return nil, nil
}
if retAT.GetToken() != token {
if subtle.ConstantTimeCompare([]byte(retAT.GetToken()), []byte(token)) == 0 {
return nil, nil
}
// retAT.Token set to empty string so the value is not returned as described in the methods' doc.