passport-orange-openidconnect
Advanced tools
Comparing version 0.0.9 to 0.0.10
{ | ||
"name": "passport-orange-openidconnect", | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"description": "passport version for managing Orange openidconnect protocol", | ||
@@ -9,16 +9,7 @@ "main": "index.js", | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/thierryorange/passport-orange-openidconnect.git" | ||
}, | ||
"author": "thierrybalandier <thierry.balandier@orange.com>", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/thierryorange/passport-orange-openidconnect/issues" | ||
}, | ||
"homepage": "https://github.com/thierryorange/passport-orange-openidconnect", | ||
"dependencies": { | ||
"passport-oauthkermit": "0.0.7", | ||
"passport-oauthkermit": "0.0.8", | ||
"pkginfo": "^0.3.0" | ||
} | ||
} |
131
strategy.js
@@ -7,65 +7,4 @@ /** | ||
/** | ||
* `Strategy` constructor. | ||
* | ||
* The Cloud Foundry authentication strategy authenticates requests by delegating to | ||
* Cloud Foundry using the OAuth 2.0 protocol. | ||
* | ||
* Applications must supply a `verify` callback which accepts an `accessToken`, | ||
* `refreshToken` and 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: | ||
* - `clientID` your Cloud Foundry application's client id | ||
* - `clientSecret` your Cloud Foundry application's client secret | ||
* - `callbackURL` URL to which Cloud Foundry will redirect the user after granting authorization | ||
* | ||
* Examples 1: | ||
* var CloudFoundryStrategy = require('passport-cloudfoundry').Strategy; | ||
* var cfStrategy = new CloudFoundryStrategy({ | ||
* clientID: '123-456-789', | ||
* clientSecret: 'shhh-its-a-secret' | ||
* callbackURL: 'https://myapp.cloudfoundry.com/auth/cloudfoundry/callback' | ||
* }, | ||
* function(accessToken, refreshToken, profile, done) { | ||
* User.findOrCreate(..., function (err, user) { | ||
* done(err, user); | ||
* }); | ||
* }); | ||
* | ||
* passport.use(cfStrategy); | ||
* | ||
* Call cfStrategy.reset() to reset when user is logged out (along w/ req.logout()). | ||
* | ||
* Examples 2 (w/ 'state' parameter): | ||
* var CloudFoundryStrategy = require('passport-cloudfoundry').Strategy; | ||
* var cfStrategy = new CloudFoundryStrategy({ | ||
* clientID: '123-456-789', | ||
* clientSecret: 'shhh-its-a-secret' | ||
* callbackURL: 'https://myapp.cloudfoundry.com/auth/cloudfoundry/callback', | ||
* passReqToCallback: true //<-- pass this to get req from CF.com to callback | ||
* }, | ||
* function(req, accessToken, refreshToken, profile, done) { | ||
* //verify things like 'state' in req.query (be sure to set: passReqToCallback=true) | ||
* if(req.query.state === 'stateValueIpreviouslySent') { | ||
* User.findOrCreate(..., function (err, user) { | ||
* done(err, user); | ||
* }); | ||
* } else { | ||
* done({error: 'state value didnt match.. CSRF?'}); | ||
* } | ||
* User.findOrCreate(..., function (err, user) { | ||
* done(err, user); | ||
* }); | ||
* }); | ||
* | ||
* @param {Object} options | ||
* @param {Function} verify A callback function to which accessToken, refreshToken, profile, done are sent back | ||
* @api public | ||
*/ | ||
function Strategy(options, verify) { | ||
console.log('passport-orange-openidconnect:Strategy'); | ||
// console.log('passport-orange-openidconnect:Strategy'); | ||
options = options || {}; | ||
@@ -75,3 +14,3 @@ options.authorizationURL = options.authorizationURL || 'https://api.orange.com/oauth/v2/authorize'; | ||
//Send clientID & clientSecret in 'Authorization' header | ||
// Send clientID & clientSecret in 'Authorization' header | ||
var auth = 'Basic ' + new Buffer(options.clientID + ':' + options.clientSecret).toString('base64'); | ||
@@ -87,3 +26,3 @@ options.customHeaders = { | ||
console.log('passport-orange-openidconnect:Strategy this._origCustomHeader='+this._origCustomHeader); | ||
//console.log('passport-orange-openidconnect:Strategy this._origCustomHeader='+this._origCustomHeader); | ||
@@ -108,5 +47,5 @@ OAuth2Strategy.call(this, options, verify); | ||
/** | ||
* Retrieve user profile from Cloud Foundry. | ||
* Retrieve Orange user profile | ||
* | ||
* This function calls /info endpoint of Cloud Foundry and returns the result | ||
* This function calls /userinfo endpoint of Orange and returns the result | ||
* as 'profile' | ||
@@ -119,7 +58,7 @@ * | ||
Strategy.prototype.userProfile = function (accessToken, done) { | ||
console.log('passport-orange-openidconnect:userProfile'); | ||
//console.log('passport-orange-openidconnect:userProfile'); | ||
this._oauth2.get(this._userProfileURI, accessToken, function (err, body, res) { | ||
if (err) { | ||
try { | ||
console.log('passport-orange-openidconnect:userProfile err='+JSON.stringify(err)); | ||
//console.log('passport-orange-openidconnect:userProfile err='+JSON.stringify(err)); | ||
} catch (e) { | ||
@@ -132,3 +71,3 @@ } | ||
done(null, JSON.parse(body)); | ||
console.log('passport-orange-openidconnect:userProfile body='+JSON.parse(body)); | ||
//console.log('passport-orange-openidconnect:userProfile body='+JSON.parse(body)); | ||
} catch (e) { | ||
@@ -141,3 +80,3 @@ done(e); | ||
/** | ||
* Set user profile URI for a Cloud Foundry installation. | ||
* Set user profile URI for a Orange user | ||
* Default value: https://api.orange.com/openidconnect/v1/userinfo | ||
@@ -148,3 +87,3 @@ * | ||
Strategy.prototype.setUserProfileURI = function (userProfileURI) { | ||
console.log('passport-orange-openidconnect:setUserProfileURI '+userProfileURI); | ||
//console.log('passport-orange-openidconnect:setUserProfileURI '+userProfileURI); | ||
this._userProfileURI = userProfileURI; | ||
@@ -163,3 +102,3 @@ }; | ||
this._oauth2._customHeaders['Authorization'] = this._origCustomHeader['Authorization']; | ||
console.log('passport-orange-openidconnect: '+this._oauth2._customHeaders); | ||
//console.log('passport-orange-openidconnect: '+this._oauth2._customHeaders); | ||
}; | ||
@@ -175,3 +114,3 @@ | ||
Strategy.prototype.authorizationParams = function(options) { | ||
console.log('passport-orange-openidconnect: '+this._stateParamCallback); | ||
//console.log('passport-orange-openidconnect: '+this._stateParamCallback); | ||
if(this._stateParamCallback) { | ||
@@ -183,48 +122,2 @@ return {'state': this._stateParamCallback()}; | ||
/* | ||
* Sets a callback function to generate 'state' param's random value. | ||
* | ||
* @param {callback} Set a callback function that returns a random string | ||
* @return null | ||
* | ||
* In the app set this callback to a function that returns a random string that'll be | ||
* used as 'state' param's value. | ||
* | ||
* *************** | ||
* For example: | ||
* *************** | ||
* var cfStrategy = new CloudFoundryStrategy(..., finalCallback); | ||
* | ||
* //set a callback to generate 'state' value. | ||
* cfStrategy.setStateParamCallBack(generateState); | ||
* | ||
* | ||
* Where.. 'generateState' generates new state and stores is somwhere | ||
* and returns that random value back. | ||
* // Temporarily store `state` ids | ||
* var states = {}; | ||
* // Generates a random value to be used as 'state' param during authorization | ||
* function generateStateParam() { | ||
* var state = uuid.v4(); | ||
* states[state] = true; | ||
* return state; | ||
* } | ||
* | ||
* Finally, in your 'finalCallback',check if that state exists | ||
* if(req.query.state && states[req.query.state]) { | ||
* done(null, user); | ||
* //delete it from memory | ||
* delete states[req.query.state]; | ||
* } else { | ||
* done({"error": 'state value didn't match. possible CSRF?'}) | ||
* } | ||
* | ||
*/ | ||
Strategy.prototype.setStateParamCallBack = function(callback) { | ||
console.log('passport-orange-openidconnect: '+setStateParamCallBack); | ||
this._stateParamCallback = callback; | ||
}; | ||
/** | ||
@@ -231,0 +124,0 @@ * Expose `Strategy`. |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
71740
110
1
+ Addedoauthkermit@0.0.7(transitive)
+ Addedpassport-oauthkermit@0.0.8(transitive)
- Removedoauthkermit@0.0.6(transitive)
- Removedpassport-oauthkermit@0.0.7(transitive)
Updatedpassport-oauthkermit@0.0.8