strategy.js
1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/**
* Module dependencies.
*/
var util = require('util')
, OpenIDStrategy = require('passport-openid').Strategy;
/**
* `Strategy` constructor.
*
* The Google authentication strategy authenticates requests by delegating to
* Google using the OpenID 2.0 protocol.
*
* Applications must supply a `validate` callback which accepts an `identifier`,
* and optionally a service-specific `profile`, and then calls the `done`
* callback supplying a `user`, which should be set to `false` if the
* credentials are not valid. If an exception occured, `err` should be set.
*
* Options:
* - `returnURL` URL to which Google will redirect the user after authentication
* - `realm` the part of URL-space for which an OpenID authentication request is valid
* - `profile` enable profile exchange, defaults to _true_
*
* Examples:
*
* passport.use(new GoogleStrategy({
* returnURL: 'http://localhost:3000/auth/google/return',
* realm: 'http://localhost:3000/'
* },
* function(identifier, profile, done) {
* User.findByOpenID(identifier, function (err, user) {
* done(err, user);
* });
* }
* ));
*
* @param {Object} options
* @param {Function} verify
* @api public
*/
function Strategy(options, validate) {
options = options || {};
options.providerURL = options.providerURL || 'https://www.google.com/accounts/o8/id';
options.profile = (options.profile === undefined) ? true : options.profile;
OpenIDStrategy.call(this, options, validate);
this.name = 'google';
}
/**
* Inherit from `OpenIDStrategy`.
*/
util.inherits(Strategy, OpenIDStrategy);
/**
* Expose `Strategy`.
*/
module.exports = Strategy;