From faf659121236aa3cabd5d1ebced32b634e3b0ce9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mark=20Lis=C3=A9?= Date: Wed, 16 Oct 2024 15:41:00 -0700 Subject: [PATCH] NOBUG: Disable authorizer --- handlers/authorizer/index.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/handlers/authorizer/index.js b/handlers/authorizer/index.js index 0325287..9864be4 100644 --- a/handlers/authorizer/index.js +++ b/handlers/authorizer/index.js @@ -11,6 +11,8 @@ const verifier = CognitoJwtVerifier.create({ exports.handler = async function (event, context, callback) { logger.debug('event', JSON.stringify(event)); + return await authorizeAll(event); + try { const headers = event?.headers; const authorization = event?.headers?.Authorization; @@ -51,6 +53,16 @@ exports.handler = async function (event, context, callback) { return getDenyPolicy(event.methodArn); }; +async function authorizeAll(event) { + const arnPrefix = event.methodArn.split(':').slice(0, 6); + const joinedArnPrefix = arnPrefix.slice(0, 5).join(':'); + const apiIDString = arnPrefix[5]; + const apiString = apiIDString.split('/')[0]; + const fullAPIMethods = joinedArnPrefix + ':' + apiString + '/' + process.env.STAGE_NAME + '/*'; + console.log("fullAPIMethods:", fullAPIMethods); + return generatePolicy('pub', 'Allow', fullAPIMethods); +} + async function getUserData(sub) { const dynamodb = new DynamoDBClient(); const params = {