Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
passport-restify
Advanced tools
Passport Restify is Restify-compatible authentication middleware for Node.js.
Passport's sole purpose is to authenticate requests, which it does through an extensible set of plugins known as strategies. Passport does not mount routes or assume any particular database schema, which maximizes flexibility and allows application-level decisions to be made by the developer. The API is simple: you provide Passport a request to authenticate, and Passport provides hooks for controlling what occurs when authentication succeeds or fails.
$ npm install passport-restify
Passport uses the concept of strategies to authenticate requests. Strategies can range from verifying username and password credentials, delegated authentication using OAuth (for example, via Facebook or Twitter), or federated authentication using OpenID.
Before authenticating requests, the strategy (or strategies) used by an application must be configured.
passport.use(new LocalStrategy(
function(username, password, done) {
User.findOne({ username: username }, function (err, user) {
if (err) { return done(err); }
if (!user) { return done(null, false); }
if (!user.verifyPassword(password)) { return done(null, false); }
return done(null, user);
});
}
));
There are 300+ strategies. Find the ones you want at: passportjs.org
Passport will maintain persistent login sessions. In order for persistent sessions to work, the authenticated user must be serialized to the session, and deserialized when subsequent requests are made.
Passport does not impose any restrictions on how your user records are stored. Instead, you provide functions to Passport which implements the necessary serialization and deserialization logic. In a typical application, this will be as simple as serializing the user ID, and finding the user by ID when deserializing.
passport.serializeUser(function(user, done) {
done(null, user.id);
});
passport.deserializeUser(function(id, done) {
User.findById(id, function (err, user) {
done(err, user);
});
});
Passport provides an authenticate()
function, which is used as route
middleware to authenticate requests.
app.post('/login',
passport.authenticate('local', { failureRedirect: '/login' }),
function(req, res) {
res.redirect('/');
});
Passport has a comprehensive set of over 300 authentication strategies covering social networking, enterprise integration, API services, and more.
There is a Strategy Search at passportjs.org
The following table lists commonly used strategies:
Strategy | Protocol | Developer |
---|---|---|
Local | HTML form | Jared Hanson |
OpenID | OpenID | Jared Hanson |
BrowserID | BrowserID | Jared Hanson |
OAuth 2.0 | Jared Hanson | |
OpenID | Jared Hanson | |
OAuth / OAuth 2.0 | Jared Hanson | |
OAuth | Jared Hanson |
passport-local
)
The modules page on the wiki lists other useful modules that build upon or integrate with Passport.
$ npm install
$ make test
This project is supported by Auth0
Copyright (c) 2011-2015 Jared Hanson <http://jaredhanson.net/>
FAQs
Simple, unobtrusive authentication for Restify.
The npm package passport-restify receives a total of 246 weekly downloads. As such, passport-restify popularity was classified as not popular.
We found that passport-restify 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
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.