https://github.com/nash403/passport-anonym-uuid
Anonymous authentication strategy for Passport that supply an uuid.
https://github.com/nash403/passport-anonym-uuid
anonymous authentication nodejs passport passport-anonym-uuid strategy uuid
Last synced: 5 months ago
JSON representation
Anonymous authentication strategy for Passport that supply an uuid.
- Host: GitHub
- URL: https://github.com/nash403/passport-anonym-uuid
- Owner: nash403
- License: mit
- Created: 2017-02-23T12:26:30.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2021-01-18T14:51:48.000Z (over 4 years ago)
- Last Synced: 2025-04-11T10:00:29.086Z (6 months ago)
- Topics: anonymous, authentication, nodejs, passport, passport-anonym-uuid, strategy, uuid
- Language: JavaScript
- Homepage:
- Size: 9.77 KB
- Stars: 4
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# passport-anonym-uuid
[Passport](http://passportjs.org/) 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](http://www.senchalabs.org/connect/)-style middleware, including
[Express](http://expressjs.com/).## 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_"}`.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](https://github.com/NetOxygen/passport-req.git). 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](http://expressjs.com/)
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](https://github.com/nash403/passport-anonym-uuid/tree/master/examples/basic).
## Tests
$ npm install
$ npm test## Credits
This package is almost a copy of [passport-anonymous](https://github.com/jaredhanson/passport-anonymous) made by [Jared Hanson](http://github.com/jaredhanson).- [Honoré Nintunze](https://github.com/nash403)
- [Jared Hanson](http://github.com/jaredhanson)## License
[The MIT License](http://opensource.org/licenses/MIT)
Copyright (c) 2017 Honoré Nintunze