Passport is Express-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.
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(newLocalStrategy(
function(username, password, done) {
User.findOne({ username: username }, function (err, user) {
if (err) { returndone(err); }
if (!user) { returndone(null, false); }
if (!user.verifyPassword(password)) { returndone(null, false); }
returndone(null, user);
});
}
));
There are 480+ strategies. Find the ones you want at: passportjs.org
Sessions
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.
To use Passport in an Express or
Connect-based application, configure it
with the required passport.initialize() middleware. If your application uses
persistent login sessions (recommended, but not required), passport.session()
middleware must also be used.
The npm package pasportt receives a total of 0 weekly downloads. As such, pasportt popularity was classified as not popular.
We found that pasportt demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.It has 0 open source maintainers collaborating on the project.
Package last updated on 01 Nov 2024
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.
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
By Kirill Boychenko, Peter van der Zee - Jan 29, 2025