Fix P1 security findings for FRE-4806

- Add DD_API_KEY and DD_SITE to Zod validation schema (config.ts)
- Truncate API key before storing in user.id to prevent Sentry leak (auth.middleware.ts)
This commit is contained in:
2026-05-12 12:42:42 -04:00
parent 01ffe79bbe
commit 56016a6124
2 changed files with 7 additions and 2 deletions

View File

@@ -46,9 +46,10 @@ export async function authMiddleware(fastify: FastifyInstance) {
if (apiKey) {
// In production, validate API key against database
authReq.apiKey = apiKey;
const apiKeyPrefix = apiKey.slice(0, 8);
authReq.user = {
id: `api-${apiKey}`,
email: `api-${apiKey}@services.internal`,
id: `api-${apiKeyPrefix}...`,
email: `api-${apiKeyPrefix}@services.internal`,
role: 'service',
};
authReq.authType = 'api-key';