Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion apps/api/src/lib/auth-validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import {
type ApiKeyWithWebsiteAndOrganization,
getApiKeyByKey,
} from "@api/db/queries/api-keys";
import { env } from "@api/env";
import {
hashApiKey,
isValidPublicApiKeyFormat,
isValidSecretApiKeyFormat,
} from "@api/utils/api-keys";
Expand Down Expand Up @@ -313,7 +315,9 @@ export async function authenticateWithPrivateKey(
throw new AuthValidationError(401, "Invalid private API key format");
}

return await getApiKeyFromRedis(privateKey, db);
// Private keys are HMAC-hashed before storage, so hash before lookup
const hashedKey = hashApiKey(privateKey, env.API_KEY_SECRET);
return await getApiKeyFromRedis(hashedKey, db);
}

/**
Expand Down
Loading