Skip to content
This repository has been archived by the owner on Feb 25, 2019. It is now read-only.

protocol/OpenID.js works against master #71

Merged
merged 1 commit into from
Mar 4, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions config/passport.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var _ = require('lodash')
, path = require('path')
, util = require('util')
, config = require(path.join(cwd, 'config.' + env + '.json'))
, providers = require('../providers')
, providers = require('../lib/providers')
, LocalStrategy = require('passport-local').Strategy
, base64url = require('base64url')
, User = require('../models/User')
Expand Down Expand Up @@ -59,14 +59,14 @@ module.exports = function (passport) {

if (config.providers) {
Object.keys(config.providers).forEach(function (name) {
var provider = providers[name]
, client = config.providers[name]
, protocol = (provider && provider.protocol)
|| (client && client.protocol)
, strategy = require('../protocols/' + protocol)
var providerConf = config.providers[name]
, provider = ( providers[name] ? providers[name] : providerConf )
, protocol = provider.protocol
, strategy = require('../lib/protocol/' + protocol)
;

passport.use(strategy.initialize(provider, client));
provider.id = name;
passport.use(strategy.initialize(provider, providerConf));
});
}

Expand Down
33 changes: 25 additions & 8 deletions protocols/OpenID.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,31 @@
*/

var passport = require('passport')
, OpenIDStrategy = require('passport-openid')
, Strategy = require('passport-openid').Strategy
, util = require('util')
, User = require('../../models/User')
;

/**
* OpenIDStrategy
*
* Provider is an object defining the details of the authentication API.
* Client is an object containing provider registration info and options.
* Verify is the Passport callback to invoke after authenticating
*/

function OpenIDStrategy (provider, verify) {
this.provider = provider;
this.name = provider.id;
if (! provider.returnURL) {
provider.returnURL = provider.callbackURL;
}
Strategy.call(this, provider, verify);
this.client = provider;
this.verify = verify;
}

util.inherits(OpenIDStrategy, Strategy);

/**
* Verifier
Expand All @@ -16,8 +37,8 @@ function verifier (req, identifier, userInfo, done) {
// Raw OpenID Provider response should be stored
// for consistency with other protocols.
var auth = {
// identifier?
// req.query?
id: request.query['openid.identity'],
req_query: req.query
};

userInfo.id = request.query['openid.identity'];
Expand All @@ -36,14 +57,10 @@ OpenIDStrategy.verifier = verifier;


/**
* Initialize
* Initialize - note provider === configuration
*/

function initialize (provider, configuration) {
// provider may be null with this strategy?
// possibly merge with configuration if it's
// an object?

configuration.profile = true;
configuration.passReqToCallback = true;

Expand Down