passport-easydb
v0.2.0
Published
easydb authentication strategy for Passport.
Downloads
29
Maintainers
Readme
passport-easydb
easydb authentication strategy for Passport.
This repository contains a Passport strategy for authenticating with easydb.
This module lets you authenticate using easydb in your Node.js applications. By plugging into Passport, easydb authentication can be easily and unobtrusively integrated into any application or framework that supports Connect-style middleware, including Express.
This module was roughly based on passport-github.
Note: This is a very early version of this strategy, without tests or proper error handling. Use on your own risk!
Table of Contents
Install
npm install passport-easydb
Usage
Prerequisites
You need to have access to an easydb instance.
Configure Strategy
The only required option is url
(API URL of your easydb instance with trailing slash).
const Strategy = require('passport-easydb');
passport.use(new Strategy({
url: "https://easydb5-test.example.com/api/v1/"
},
function(accessToken, refreshToken, profile, cb) {
User.findOrCreate({ easydbId: profile.id }, function (err, user) {
return cb(err, user);
});
}
));
Authenticate Requests
Use passport.authenticate()
, specifying the "easydb"
strategy, to authenticate requests.
For example, as route middleware in an Express application:
app.get("/login/easydb", (req, res) => {
res.render("loginEasydb")
})
app.post("/login/easydb",
passport.authenticate("easydb", {
successRedirect: "/account",
failureRedirect: `/login/easydb`,
failureFlash: "Could not verify credentials."
})
)
Test
TODO
Maintainers
Publish
TODO
Contribute
PRs accepted.
Small note: If editing the README, please conform to the standard-readme specification.
TODOs
- [ ] Provide examples.
- [ ] Add testing.
- [ ] Handle errors.
- [ ] Improve documentation.
License
MIT © 2019 Verbundzentrale des GBV (VZG)