Skip to content

Cognito IAM Authorizer which authenticates Cognito JWT token and attach Cognito UserPool User Groups Permission to invoke API Gateway

License

Notifications You must be signed in to change notification settings

serverless-projects/cognito-iam-authorizer

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cognito-iam-authorizer

Cognito IAM Authorizer which authenticates Cognito JWT token and attach Cognito UserPool User Groups Permission to invoke API Gateway.

It is ideal to be used in a AWS Lambda function since it has been optimised to fetch roles and policies parallely. It also provides a method to validate the ID Token that is sent by Cognito after the user has been validated.

Installation

Usage

const CognitoIamAuthoriser = require("cognito-iam-authoriser")

CognitoIamAuthoriser.validateCognitoIdToken(idToken, pemFileObj, iss, function (err, message) {
        if (!err) {
            console.log("Token validated successfully..");
            CognitoIamAuthoriser.buildPolicyFromIam(idToken, function (err, policyDocument) {
                if (policyDocument) {
                    callback(null, policyDocument)
                }
                else {
                    callback(err);
                }
            });
        }
        else {
            callback(err);
        }
    });

Contributing

About

Cognito IAM Authorizer which authenticates Cognito JWT token and attach Cognito UserPool User Groups Permission to invoke API Gateway

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%