From 41883e5e9c5067a8a35130be727116d422155a9a Mon Sep 17 00:00:00 2001 From: ashanfernando Date: Wed, 7 Sep 2016 01:15:48 +0530 Subject: [PATCH] Custom Authorization function is initialized with the environmental variables of endpoint function issue fix Fix for Issue #97 --- src/createAuthScheme.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/createAuthScheme.js b/src/createAuthScheme.js index f98c0ad28..0d8c4c09d 100644 --- a/src/createAuthScheme.js +++ b/src/createAuthScheme.js @@ -59,6 +59,11 @@ module.exports = function createAuthScheme(authFun, funName, endpointPath, optio methodArn: `arn:aws:execute-api:${options.region}::/${options.stage}/${funName}/${endpointPath}`, }; + // Set environment variables + const newEnvVars = toPlainOrEmptyObject(populatedAuthFun.environment); + resetEnvVariables(this.envVars, newEnvVars); + this.envVars = newEnvVars; + // Create the Authorization function handler let handler; @@ -103,9 +108,6 @@ module.exports = function createAuthScheme(authFun, funName, endpointPath, optio } }); - // Set environment variables - resetEnvVariables({}, toPlainOrEmptyObject(populatedAuthFun.environment)); - // Execute the Authorization Function handler(event, lambdaContext, lambdaContext.done); },