We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 3b7fba3 + a1bfd19 commit 61acec1Copy full SHA for 61acec1
1 file changed
apps/api/src/lib/auth-validation.ts
@@ -3,7 +3,9 @@ import {
3
type ApiKeyWithWebsiteAndOrganization,
4
getApiKeyByKey,
5
} from "@api/db/queries/api-keys";
6
+import { env } from "@api/env";
7
import {
8
+ hashApiKey,
9
isValidPublicApiKeyFormat,
10
isValidSecretApiKeyFormat,
11
} from "@api/utils/api-keys";
@@ -313,7 +315,9 @@ export async function authenticateWithPrivateKey(
313
315
throw new AuthValidationError(401, "Invalid private API key format");
314
316
}
317
- return await getApiKeyFromRedis(privateKey, db);
318
+ // Private keys are HMAC-hashed before storage, so hash before lookup
319
+ const hashedKey = hashApiKey(privateKey, env.API_KEY_SECRET);
320
+ return await getApiKeyFromRedis(hashedKey, db);
321
322
323
/**
0 commit comments