Skip to content

Instantly share code, notes, and snippets.

View mauricio-santos-deel's full-sized avatar

Mauricio Santos mauricio-santos-deel

View GitHub Profile
@mauricio-santos-deel
mauricio-santos-deel / aws-jwt-lambda-authorizer
Created June 12, 2019 16:29
Example of Aws Lambda Authorizer that uses JWT
const jwtLib = require('jsonwebtoken');
const jwksClient = require('jwks-rsa');
const util = require('util'); // node-js util
var httpRequestPromise = require('request-promise');
module.exports.handler = async (event, context) => {
try {
const jwtToken = getToken(event);
const jwtDecoded = jwtLib.decode(jwtToken, { complete: true });
const myAppUserId = jwtDecoded.payload.userId;