Skip to content

Commit 058e98a

Browse files
committed
fix: v1Public auth, hash api key before check
1 parent 3863dfa commit 058e98a

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

api/auth/auth.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ func (s *Server) Check(ctx context.Context, request *auth.CheckRequest) (res *au
6363

6464
var apiKey playerdb.ApiKey
6565
if strings.HasPrefix(apiKeyStr, ApiKeyPrefix) {
66-
apiKey, err = s.store.GetApiKeyByHash(ctx, apiKeyStr[len(ApiKeyPrefix):])
66+
h := sha256.Sum256([]byte(apiKeyStr))
67+
hash := hex.EncodeToString(h[:])
68+
apiKey, err = s.store.GetApiKeyByHash(ctx, hash)
6769
if errors.Is(err, playerdb.ErrNoRows) {
6870
apiKey.ID = ""
6971
} else if err != nil {

0 commit comments

Comments
 (0)