chore(orchestration): validate PK when throwIfKeyNotFound (#11190)

CLOSES: FRMW-2895
This commit is contained in:
Carlos R. L. Rodrigues
2025-01-29 16:17:36 -03:00
committed by GitHub
parent e0bd2a79b0
commit e98d3c615e
14 changed files with 209 additions and 118 deletions

View File

@@ -33,21 +33,18 @@ export async function ensurePublishableApiKeyMiddleware(
const query = req.scope.resolve(ContainerRegistrationKeys.QUERY)
try {
const { data } = await query.graph(
{
entity: "api_key",
fields: ["id", "token", "sales_channels_link.sales_channel_id"],
filters: {
token: publishableApiKey,
type: ApiKeyType.PUBLISHABLE,
$or: [
{ revoked_at: { $eq: null } },
{ revoked_at: { $gt: new Date() } },
],
},
const { data } = await query.graph({
entity: "api_key",
fields: ["id", "token", "sales_channels_link.sales_channel_id"],
filters: {
token: publishableApiKey,
type: ApiKeyType.PUBLISHABLE,
$or: [
{ revoked_at: { $eq: null } },
{ revoked_at: { $gt: new Date() } },
],
},
{ throwIfKeyNotFound: true }
)
})
apiKey = data[0]
} catch (e) {