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!
npm install passport-easydb
You need to have access to an easydb instance.
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);
});
}
));
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."
})
)
TODO
TODO
PRs accepted.
Small note: If editing the README, please conform to the standard-readme specification.
- Provide examples.
- Add testing.
- Handle errors.
- Improve documentation.
MIT © 2019 Verbundzentrale des GBV (VZG)