aws-user-authentication
v1.1.3
Published
Express authentication middleware for express app
Downloads
9
Readme
AWS-Cognito JWT Authenticator
AWS-Cognito JWT authentication using express middleware.
Installation
Install my-project with npm
npm install aws-user-authentication
or
yarn add aws-user-authentication
Features
AWS Cognito Authentication
Express middleware
- Singleton pattern
Usage/Examples
const express = require('express');
const jwks = require('./jwks.json');
const auth = new (require('aws-user-authentication'))({
jwks,
isTokenBearer: true,
clientId: '<CLIENT_ID>',
tokenUse: 'access' || 'id',
userPoolId: '<USER_POOL_ID>',
key: '<AUTHENTICATION_KEY_IN_HEADER>',
});
const app = express();
const PORT = process.env.PORT || 3000;
app.get('/', new Authentication().validator, (req, res) => {
console.log('Get request');
return res.json('Hello World!');
});
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});