@nrfcloud/api-gateway-authorizer

Custom authorizer for API Gateway

Usage no npm install needed!

<script type="module">
  import nrfcloudApiGatewayAuthorizer from 'https://cdn.skypack.dev/@nrfcloud/api-gateway-authorizer';
</script>

README

Custom API Gateway Authorizer

npm version Build Status Test Coverage
Greenkeeper badge semantic-release Commitizen friendly
DeepScan Grade Known Vulnerabilities Maintainability

Authorizes requests to the nRF Cloud API with Cognito Tokens.

It fetches the Cognito Identity ID for the user pool token. The user information will be on event.requestContext.authorizer:

{
    cognitoIdentityId: 'us-east-1:...', 
    'cognito:username': 'alex.doe@example.com',
    email: 'alex.doe@example.com'
}

Tests

Set these environment variables:

user_pool_url=https://cognito-idp.us-east-1.amazonaws.com/us-east-1_fdiBa7JSO
identity_pool_id=us-east-1:c00e1327-dfc2-4aa7-a484-8ca366d11a68
username=user@example.com
password=changeme
client_id=bmoej5j8t187jmnumu00jrt2v
AWS_ACCESS_KEY_ID=changeme
AWS_SECRET_ACCESS_KEY=changeme