passport-cognito-oidc
v0.0.1
Published
Passport strategies for authenticating with Amazon Cognito user pool using OpenID Connect.
Downloads
2
Readme
passport-cognito-oidc
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.