passport-domain
v0.0.3
Published
$ npm install passport-domain
Downloads
3
Readme
Install
$ npm install passport-domain
Usage
Configure Strategy
The domain authentication strategy authenticates users using a third-party
authenticator and domain. The strategy
requires a verify
callback, which receives an access token,
and calls cb
providing a user.
passport.use(
new DomainStrategy(
{
callbackURL: "http://localhost:3000/auth/domain/callback",
},
function (domain, cb) {
User.findOrCreate({ domain: domain }, function (err, user) {
return cb(err, user);
});
}
)
);
Authenticate Requests
Use passport.authenticate()
, specifying the 'domain'
strategy, to
authenticate requests.
For example, as route middleware in an Express application:
app.get("/auth/domain", passport.authenticate("domain"));
app.get(
"/auth/domain/callback",
passport.authenticate("domain", { failureRedirect: "/auth" }),
function (req, res) {
// Successful authentication, redirect home.
res.redirect("/");
}
);