passport-daangn v1.0.12
passport-daangn
Passport strategy for daangn authenticating
Install
$ npm install passport-daangn
Usage
Configure Strategy
The daangn authentication strategy authenticates users using a code.
The strategy requires a verify
callback, which accepts these
credentials and calls done
providing a user.
passport.use(new LocalStrategy(function (access_token, done) {}));
Available Options
This strategy takes an optional options hash before the function, e.g. new LocalStrategy({/* options */, callback})
.
The available options are:
codeField
- Optional, defaults to 'code'env
- Optional, defaults to 'dev'scope
- Optional, defaults to 'account/profile'app_id
- Essentialapp_secret
- Essential
Both fields define the name of the properties in the POST body that are sent to the server.
Parameters
By default, LocalStrategy
expects to find credentials in parameters
named code. If your site prefers to name these fields
differently, options are available to change the defaults.
passport.use(new LocalStrategy({
codeField: 'authCode',
env: 'live',
scope: 'account/profile',
app_id: '',
app_secret: '',
},
function(access_token, done) {
// ...
}
));
The verify callback can be supplied with the request
object by setting
the passReqToCallback
option to true, and changing callback arguments
accordingly.
passport.use(new LocalStrategy({
codeField: 'authCode',
env: 'live',
scope: 'account/profile'
passReqToCallback: true,
app_id: '',
app_secret: '',
},
function(req, access_token, done) {
// request object is now first argument
// ...
}
));
Authenticate Requests
Use passport.authenticate()
, specifying the 'daangn'
strategy, to
authenticate requests.
For example, as route middleware in an Express application:
app.post(
"/login",
passport.authenticate("daangn", { failureRedirect: "/login" }),
function (req, res) {
res.redirect("/");
}
);
License
Copyright (c) 2011-2015 Jared Hanson [http://jaredhanson.net/](http://jaredhanson.net/)