Skip to content

Commit

Permalink
Only fetch keys that are required for the access type
Browse files Browse the repository at this point in the history
  • Loading branch information
N2D4 committed Dec 26, 2024
1 parent 9fca293 commit 640026c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions apps/backend/src/route-handlers/smart-request.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,9 @@ const parseAuth = withTraceSpan('smart request parseAuth', async (req: NextReque

const queryFuncs = {
project: () => projectId ? getProject(projectId) : Promise.resolve(null),
isClientKeyValid: () => projectId && publishableClientKey ? checkApiKeySet(projectId, { publishableClientKey }) : Promise.resolve(false),
isServerKeyValid: () => projectId && secretServerKey ? checkApiKeySet(projectId, { secretServerKey }) : Promise.resolve(false),
isAdminKeyValid: () => projectId && superSecretAdminKey ? checkApiKeySet(projectId, { superSecretAdminKey }) : Promise.resolve(false),
isClientKeyValid: () => projectId && publishableClientKey && requestType === "client" ? checkApiKeySet(projectId, { publishableClientKey }) : Promise.resolve(false),
isServerKeyValid: () => projectId && secretServerKey && requestType === "server" ? checkApiKeySet(projectId, { secretServerKey }) : Promise.resolve(false),
isAdminKeyValid: () => projectId && superSecretAdminKey && requestType === "admin" ? checkApiKeySet(projectId, { superSecretAdminKey }) : Promise.resolve(false),
user: () => projectId && accessToken ? extractUserFromAccessToken({ token: accessToken, projectId }) : Promise.resolve(null),
internalUser: () => projectId && adminAccessToken ? extractUserFromAdminAccessToken({ token: adminAccessToken, projectId }) : Promise.resolve(null),
} as const;
Expand Down

0 comments on commit 640026c

Please sign in to comment.