sanpassport

5.0.0 • Public • Published

sanpassport

NPM Version NPM Downloads Build Status bitHound Overall Score bitHound Dependencies bitHound Dev Dependencies bitHound Code Code Climate Issue Count

About

Passport passport-local and passport-google-oauth wrapper.

NPM

Settings

Install sanpassport

$ npm install sanpassport

An example:

//see http://passportjs.org/docs/configure
let sanpassport = require('sanpassport')(
  {
    serialise: (user,done) => { // optional
      // ...
    },
    deserialise: (user,done) => { //optional
      // ...
    },
    local:{
      func: (username, password, done) => {
        //...
      },
      options: { //optional
        usernameField: 'email',
        passwordField: 'password'
      },
      authenticate: (req, res, next) => {
        // ...
        next();
      }
    },
    google: {
      func: (accessToken, refreshToken, profile, done) => {
        //...
      },
      options: {
        clientID: "your_client_id",
        clientSecret: "SHHHH! It's a secret",
        failureRedirect : "/"
      }
    },
    jwt: {
      func: (jwt_payload, done) => {
 
      },
      options: {  
        // see https://www.npmjs.com/package/passport-jwt#usage
      }
    }
  }
);

Use

An example with express.js:

app.use(sanpassport.initialize);
app.use(sanpassport.session);//optional
// google
app.post("/loginGoogle", sanpassport.google.login, function(req, res, next){
  //...
});
 
app.get("callback/URL", sanpassport.google.callback, function(req,res, next){
  //...
});
 
// local
app.post("/login", sanpassport.local.login, function(req, res, next){
  //...
});
app.post("/logout", sanpassport.local.logout, function(req, res, next){
  //...
});
app.post("/secure/route", sanpassport.local.authenticate, function(req, res){
  //...
});
 
// jwt
app.post("/token", function(req, res){
 
});
app.post(
  "/secure/jwt",
  sanpassport.jwt.authenticate,
  function(req, res){
  //...
});

See test/basic.js for more details.

To Do

  • Strategies
    • Local
    • Google OAuth2.0
    • JSON Web Token
    • Facebook
    • Twitter
    • OAuth
  • New Strategy

Changelog

5.0.0

4.0.1 (26-05-2017)

4.0.0 (17-01-2017)

  • Node v6 or newer only.
  • Google Oauth supported.

3.0.0 (27-10-2016)

  • Travis integration.
  • Logout removed as param.
  • Strategy Local options added as params.

2.2.0 (26-10-2016)

  • Logout function added as param.

2.1.0 (7-10-2016)

  • ensureAuthenticated functions added as param.

2.0.2 (8-9-2016)

  • Password validation.

2.0.1 (7-9-2016)

  • Strategy Function added as param.
  • Passport dependencie and removed as param.
  • Serialize user with id or _id.
  • Model create method beside new instance.
  • Test module

1.4.0 (25-7-2016)

  • README with examples.

1.0.0 (12-06-2016)

Start

Package Sidebar

Install

npm i sanpassport

Weekly Downloads

0

Version

5.0.0

License

GPL-3.0

Last publish

Collaborators

  • sanjorgek