aws-user-authentication

1.1.3 • Public • Published

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}`);
});

/aws-user-authentication/

    Package Sidebar

    Install

    npm i aws-user-authentication

    Weekly Downloads

    6

    Version

    1.1.3

    License

    ISC

    Unpacked Size

    4.33 kB

    Total Files

    5

    Last publish

    Collaborators

    • abubakar014