5.0.0 • Published 7 years ago
sanpassport v5.0.0
sanpassport
About
Passport passport-local and passport-google-oauth wrapper.
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
- OAuth
- New Strategy
Changelog
5.0.0
- New formmat
- JWT strategy
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
5.0.0
7 years ago
4.0.1
7 years ago
4.0.0
7 years ago
3.0.0
8 years ago
2.2.0
8 years ago
2.1.0
8 years ago
2.0.2
8 years ago
2.0.1
8 years ago
2.0.0
8 years ago
1.7.0
8 years ago
1.6.2
8 years ago
1.6.1
8 years ago
1.6.0
8 years ago
1.5.0
8 years ago
1.4.0
8 years ago
1.3.0
8 years ago
1.2.0
8 years ago
1.1.0
8 years ago
1.0.0
8 years ago