Skip to content

Commit 34fbb47

Browse files
committed
[auth] use of constant time compare for registration token
1 parent aeed25e commit 34fbb47

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

internal/sms-gateway/modules/auth/service.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package auth
22

33
import (
44
"crypto/sha256"
5+
"crypto/subtle"
56
"encoding/hex"
67
"fmt"
78
"time"
@@ -99,7 +100,7 @@ func (s *Service) AuthorizeRegistration(token string) error {
99100
return nil
100101
}
101102

102-
if token == s.config.PrivateToken {
103+
if subtle.ConstantTimeCompare([]byte(token), []byte(s.config.PrivateToken)) == 1 {
103104
return nil
104105
}
105106

0 commit comments

Comments
 (0)