Skip to content
This repository was archived by the owner on Jan 18, 2024. It is now read-only.

briebug/passport-custom

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

passport-custom

Build Coverage Quality Dependencies Tips

Passport strategy for authenticating with custom logic.

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

Install

$ npm install passport-custom 

Usage

Configure Strategy

The custom authentication strategy authenticates users by custom logic. The strategy requires a verify callback, which is where the custom logic goes and calls done providing a user.

passport.use(new CustomStrategy( function(done) { User.findOne({ uid: 1 }, function (err, user) { if (err) { return done(err); } if (!user) { return done(null, false); } return done(null, user); }); } )); 

Authenticate Requests

Use passport.authenticate(), specifying the 'custom' strategy, to authenticate requests.

For example, as route middleware in an Express application:

app.post('/login', passport.authenticate('custom', { failureRedirect: '/login' }), function(req, res) { res.redirect('/'); }); 

Examples

For complete, working examples, refer to the multiple examples included.

Tests

$ npm install $ npm test 

Credits

License

The MIT License

Copyright (c) 2011-2014 Michael Bell

About

Custom logic authentication strategy for Passport and Node.js.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 70.4%
  • Makefile 29.6%