
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
passport-latch
Advanced tools
This module lets you use using latch in your Node.js applications. By plugging into Passport, latch can be easily and unobtrusively integrated into any application or framework that supports Connect-style middleware, including Express.
Note that in contrast to most Passport strategies, latch usually requires that a user already be authenticated using an initial factor, although you can still use passport-latch as a normal Passport module to protect any operation. Requirements regarding when to require a second factor are a matter of application-level policy, and outside the scope of both Passport and this strategy.
$ npm install passport-latch
The latch strategy authorizes a user using his accountId previously obtained when pairing his account with latch.
passport.use('latch_status', new LatchStrategy({appId: 'vxXXNTbQUnKXR9tTiZRe', secretKey: 'xA4xFx8pCx4iY4AyJzeFb4sqvNmjiiNT4kk22FNN'},
function(user, done) {
// setup function, supply key and period to done callback
findAccountIdForUserId(user.id, function(err, obj) {
if (err) { return done(err); }
return done(null, obj.accountId);
});
}
));
Use passport.authenticate()
, specifying the 'latch'
strategy, to authenticate
requests.
For example, as route middleware in an Express application:
app.post('/latch-status',
passport.authenticate('latch_status', { operationId: 'vxXXNTbQUnKXR9tTiZRe',failureRedirect: '/latchblocked', failureFlash: true }),
function(req, res) {
res.redirect('/');
});
You can also use latch with any other Passport Strategy, just by quering the latch servers after a successful authentication:
passport.use('login_with_latch', new LocalStrategy(function(username, password, done) {
process.nextTick(function () {
// Find the user by username. If there is no user with the given
// username, or the password is not correct, set the user to `false` to
// indicate failure and set a flash message. Otherwise, return the
// authenticated `user`.
findByUsername(username, function(err, user) {
if (err) { return done(err); }
if (!user) { return done(null, false, { message: 'Invalid username or password' }); }
if (user.password != password) { return done(null, false, { message: 'Invalid username or password' }); }
// Once the authentication has been succesful, we look for his accountId by id
var accountId = findAccountIdForUserId(user.id, function(err, obj) {
if (err) { return false; }
if (obj) {
return obj.accountId;
} else {
return false;
}
});
if (accountId) {
var rv = latch.status(accountId, function(err, data) {
if ((err) || (!data)) {
return done(null, user);
}
if (data['data']['operations']['vxXXNTbQUnKXR9tTiZRe']['status'] == "on") {
// If it is 'on', it means that the operation is not blocked
return done(null, user);
} else {
// The operation is blocked by latch
return done(null, false, { message: 'Latch is blocking your login' });
}
});
} else {
return done(null, user);
}
})
});
}));
And then as route middleware in an Express application:
app.post('/loginlatch',
passport.authenticate('login_with_latch', { failureRedirect: '/loginlatch', failureFlash: true }),
function(req, res) {
res.redirect('/');
});
For a complete, working example, refer to the example.
$ npm install
$ make test
Copyright (c) 2014 ElevenPaths <http://www.elevenpaths.com/>
FAQs
Latch authentication strategy for Passport.
The npm package passport-latch receives a total of 0 weekly downloads. As such, passport-latch popularity was classified as not popular.
We found that passport-latch 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.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.