Anonymous authentication strategy for Passport and Node.js.
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples/basic Add example. Jul 31, 2012
lib Delint. Aug 2, 2013
support/mk Remove unused support files. Mar 8, 2014
test Delint tests. Mar 8, 2014
.gitignore Update support files. Mar 8, 2014
.jshintrc Update support files. Mar 8, 2014
.npmignore Update support files. Mar 8, 2014
.travis.yml Disable node 0.6 tests on Travis CI. Mar 9, 2014
LICENSE Update support files. Mar 8, 2014
Makefile Update support files. Mar 8, 2014 Add code sponsor placement. Sep 17, 2017
package.json Update support files. Mar 8, 2014


Build Coverage Quality Dependencies Tips

Passport strategy for anonymous authentication.

This module lets you provide anonymous authentication in your Node.js applications. By plugging into Passport, anonymous authentication can be easily and unobtrusively integrated into any application or framework that supports Connect-style middleware, including Express.


$ npm install passport-anonymous


Configure Strategy

The anonymous authentication strategy passes authentication for a request, with req.user remaining undefined.

passport.use(new AnonymousStrategy());

Authenticate Requests

Use passport.authenticate(), specifying the 'anonymous' strategy, to pass authentication of a request. This is typically used alongside a strategy that verifies credentials, as a fallback for routes that prefer authentication but can also respond to unauthenticated requests.

For example, as route middleware in an Express application:'/hello', 
  passport.authenticate(['basic', 'anonymous'], { session: false }),
  function(req, res) {
    if (req.user) {
      res.json({ name: req.user.username });
    } else {
      res.json({ name: 'anonymous' });


For a complete, working example, refer to the login example.


$ npm install
$ npm test



The MIT License

Copyright (c) 2012-2013 Jared Hanson <>