Skip to content

Commit 20a3f49

Browse files
committed
improve key hash verification
1 parent de9f68a commit 20a3f49

File tree

1 file changed

+2
-3
lines changed
  • packages/api/internal/auth

1 file changed

+2
-3
lines changed

packages/api/internal/auth/key.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,11 @@ func GenerateKey(prefix string) (Key, error) {
4545
}
4646

4747
func VerifyKey(prefix string, key string) (string, error) {
48-
parts := strings.Split(key, prefix)
49-
if len(parts) != 2 {
48+
if !strings.HasPrefix(key, prefix) {
5049
return "", fmt.Errorf("invalid key prefix")
5150
}
5251

53-
keyValue := parts[1]
52+
keyValue := key[len(prefix):]
5453
keyBytes, err := hex.DecodeString(keyValue)
5554
if err != nil {
5655
return "", fmt.Errorf("invalid key")

0 commit comments

Comments
 (0)