@filevinepros/from-gateway
v1.0.0
Published
Verify that a lamba request came from the gateway
Downloads
1
Readme
from-gateway
Verify that a lamba request came from the gateway
Usage
const fromGateway = require('@filevinepros/from-gateway');
const gatewayToken = process.env.GATEWAY_TOKEN;
const jwtPublicKey = process.env.PUBLIC_KEY;
const authorize = fromGateway(gatewayToken, jwtPublicKey);
// lambda authorizer input
// see https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-lambda-authorizer-input.html
const event = {
methodArn: 'arn:aws:....',
headers: {
Authorization: 'Bearer yourJwtAccessTokenString',
'x-fv-gateway-token': 'yourProvidedGatewayToken'
}
}
// lambda authorizer context
const context = {
// ...
}
// lambda authorizer callback
// see https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-lambda-authorizer-output.html
const callback = (err, iamPolicyAndPrincipal) => {
// ...
}
// you won't typically invoke the authorize function directly;
// instead you'll export the authorize function and reference
// it in the serverless.yml
authorize(event, context, callback);