Skip to content

Instantly share code, notes, and snippets.

@bzcorn
Created April 5, 2018 09:52
Show Gist options
  • Save bzcorn/e870a40a581001b191de53c345a42dbd to your computer and use it in GitHub Desktop.
Save bzcorn/e870a40a581001b191de53c345a42dbd to your computer and use it in GitHub Desktop.
"use strict";
const OktaJwtVerifier = require("@okta/jwt-verifier");
console.log("Loading function");
const issuer = "https://dev-XXXXX.oktapreview.com/oauth2/default";
const cid = "";
exports.handler = (event, context, callback) => {
const verifier = new OktaJwtVerifier({
issuer: issuer,
assertClaims: {
aud: "api://default"
cid: cid
}
});
const accessTokenString = event.key1
// const accessTokenString = event.authorizationToken
// const methodArn = event.methodArn
verifier
.verifyAccessToken(accessTokenString)
.then(jwt => {
// the token is valid
// TODO: Generate AWS IAM Policy
console.log(jwt.claims);
callback(null, response);
})
.catch(err => {
// something went horribly wrong
console.log("Error found!");
console.log(err);
callback("Unauthorized", response);
});
Promise.all([verifier]).then(function(values) {
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment