passport-cognito-oidc
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

passport-cognito-oidc

License: MIT

Passport strategies for authenticating with Amazon Cognito user pool using OpenID Connect.

This is a library for the backend that depends on Express. If you are looking for a frontend library, you may use Amplify Library. Also, if you prefer to use Cognito user pools API for sign-in, the AWS SDK is available.

Usage

import express from 'express';
import passport from 'passport';
import session from 'express-session';
import { Strategy as CognitoOIDCStrategy } from 'passport-cognito-oidc';

const app: express.Express = express()

passport.use(new CognitoOIDCStrategy({
  clientId: '<CLIENT_ID>',
  clientSecret: '<CLIENT_SECRET>',
  region: '<REGION>',
  userPoolId: '<USER_POOL_ID>',
  redirectUri: '<REDIRECT_URI>'
}));

/* ---- express-session ----*/
app.use(session({
  name: 'YOUR-SESSION-NAME',
  secret: 'YOUR-SECRET',
  resave: true,
  saveUninitialized: true
}));

app.get('/',
  passport.authenticate('cognito', {}),
  (req: express.Request, res: express.Response) => {
    res.send('OK');
  }
);

Contributing

Thanks for your feedback and contribution to this repo! Please feel free to open issues and send pull-requests.

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i passport-cognito-oidc

Weekly Downloads

2

Version

0.0.1

License

MIT

Unpacked Size

14.7 kB

Total Files

9

Last publish

Collaborators

  • kg0r0