
Research
Security News
Lazarus Strikes npm Again with New Wave of Malicious Packages
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
passport-cognito-oauth2
Advanced tools
Passport strategy for authenticating and fetching profile data from AWS Cognito User pools using OAuth2 and the Amazon SDK
Passport strategy for authenticating and fetching profile data from AWS Cognito User pools using OAuth2 and the Amazon SDK
$ npm install passport-cognito-oauth2
The Cognito OAuth 2.0 authentication strategy authenticates requests using the
OAuth 2.0 framework and retrieves user data from AWS Cognito User Pools.
The strategy requires a verify
callback, which accepts these
credentials and calls done
providing a user, as well as options
specifying a
consumer key, consumer secret, and callback URL.
const passport = require('passport')
const CognitoOAuth2Strategy = require('passport-cognito-oauth2');
const options = {
callbackURL: 'https://myapp.com/auth/cognito/callback',
clientDomain: 'https://myapp.auth.us-west-2.amazoncognito.com',
clientID: '123-456-789',
clientSecret: 'shhh-its-a-secret',
region: 'us-west-2'
};
function verify(accessToken, refreshToken, profile, done) {
User.findOrCreate(profile, (err, user) => {
done(err, user);
});
}
passport.use(new CognitoOAuth2Strategy(options, verify));
passport.serializeUser((user, done) => done(null, user));
passport.deserializeUser((obj, done) => done(null, obj));
Use passport.authenticate()
, specifying the 'cognito-oauth2'
strategy, to
authenticate requests.
For example, as route middleware in an Express application:
app.get('/auth/cognito',
passport.authenticate('cognito-oauth2')
);
app.get('/auth/cognito/callback',
passport.authenticate('cognito-oauth2'),
(req,res) => res.send(req.user)
);
When you create your App Client, you will need to generate an App Client Secret
Your App client settings will need:
Enabled Identity Providers: Cognito User Pool
Callback URL(s): options.callbackURL
Allowed OAuth Flows: Authorization code grant
Allowed OAuth Scopes: [openid, aws.cognito.signin.user.admin, profile]
You must also configure a Domain name for use as options.clientDomain
FAQs
Passport strategy for authenticating and fetching profile data from AWS Cognito User pools using OAuth2 and the Amazon SDK
The npm package passport-cognito-oauth2 receives a total of 535 weekly downloads. As such, passport-cognito-oauth2 popularity was classified as not popular.
We found that passport-cognito-oauth2 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.
Security News
Opengrep continues building momentum with the alpha release of its Playground tool, demonstrating the project's rapid evolution just two months after its initial launch.