Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
passport-cookie
Advanced tools
Readme
Cookie authentication strategy for Passport
This module lets you authenticate HTTP requests using cookies, it only allows you to recover the content of a cookie.
By plugging into Passport, bearer token support can be easily and unobtrusively integrated into any application or framework that supports Connect-style middleware, including Express..
$ npm install passport-cookie
The cookie authentication strategy authenticates users using a cookie. The strategy requires a verify callback, which accepts that credential and calls done providing a user.
passport.use(new CookieStrategy(
function(token, done) {
User.findByToken({ token: token }, function(err, user) {
if (err) { return done(err); }
if (!user) { return done(null, false); }
return done(null, user);
});
}
));
You can pass the following options to the CookieStrategy
:
- `cookieName`: Cookie name (defaults to "token")
- `signed`: Are the cookie signed? (defaults to false)
- `passReqToCallback`: when `true`, `req` is the first argument to the verify callback (default: `false`)
passport.use(new CookieStrategy({
cookieName: 'auth',
signed: true,
passReqToCallback: true
}, function(req, token, done) {
User.findByToken({ token: token }, function(err, user) {
if (err) { return done(err); }
if (!user) { return done(null, false); }
return done(null, user);
});
})
Use passport.authenticate()
, specifying the 'cookie' strategy, to authenticate
requests. Requests containing cookies do not require session support, so the
session option can be set to false
.
For example, as route middleware in an Express application:
app.get("/profile",
passport.authenticate("cookie", { session: false }),
function(req, res) {
res.json(req.user);
});
$ npm install
$ npm test
Thanks to Jared Hanson for his great Passport
Made with ❤ by ROJO 2 (http://rojo2.com)
FAQs
Cookie authentication strategy for Passport
The npm package passport-cookie receives a total of 14,300 weekly downloads. As such, passport-cookie popularity was classified as popular.
We found that passport-cookie 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.