Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

passport-anonym-uuid

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

passport-anonym-uuid

Anonymous authentication strategy for Passport that supply an uuid.

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
454
increased by28.61%
Maintainers
1
Weekly downloads
 
Created
Source

passport-anonym-uuid

Passport strategy for anonymous authentication with a unique uuid for the anonymous user.

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.

Install

$ npm install passport-anonym-uuid

Usage

Configure Strategy

The anonymous authentication strategy passes authentication for a request, with req.user supplied with {uuid: "anonymous_<uuid>"}.

passport.use(new AnonymIdStrategy());

If you pass a done verify function to the strategy it will be supplied with req and the generated uuid. With such verify callback, you can use this strategy the same way as passport-req. The strategy will not touch the user object returned by the callback.

Authenticate Requests

Use passport.authenticate(), specifying the 'anonymId' 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:

app.post('/hello', 
  passport.authenticate(['basic', 'anonymId'], { session: false }),
  function(req, res) {
    if (!req.user.uuid) {
      res.json({ name: req.user.username });
    } else {
      res.json({ name: req.user.uuid });
    }
  });

Examples

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

Tests

$ npm install
$ npm test

Credits

This package is almost a copy of passport-anonymous made by Jared Hanson.

License

The MIT License

Copyright (c) 2017 Honoré Nintunze

Keywords

FAQs

Package last updated on 23 Feb 2017

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc