Permalink
Browse files

Merge branch 'skyrock'

Conflicts:
	README.md
  • Loading branch information...
2 parents debc503 + f34f6d4 commit 30751ac55cbe42c7709c05f56b0e9bd273379893 @ciaranj committed Jun 19, 2012
View
@@ -21,6 +21,7 @@ Provides out of the box authentication strategies for:
* Google (Oauth 1 & OAuth 2 clients)
* Yammer (Stephen Belanger)
* Linkedin (Stephen Belanger)
+* Skyrock.com (Nicolas Quiénot)
Take Care!
@@ -53,62 +54,63 @@ Run
Changelog
=========
- * 0.5.3
+ * **0.5.3**
Fix GitHub strategy to work with v3 of their API (older API versions no longer work!) (Dennis Reimann)
- * 0.5.2
+ Added new Skyrock.com provider (Nicolas Quiénot)
+ * **0.5.2**
Allow multiple users per application in Oauth Provider (3 legged) (Evan Prodromou)
Improved the behaviour of the OAuth Provider's Form/POST signing behaviours ( Evan Prodromou )
Fix broken 3-legged OAuth provider support ( Jason Chu )
- * 0.5.1
+ * **0.5.1**
Change Google OAuth2 strategy to only request (and retrieve) the authenticating user's profile information (and optionally their e-mail address.)
- * 0.5.0
+ * **0.5.0**
Update to support connect 2.0.0
New 2-legged OAuth provider support ( Jason Chu )
Yammer Support added (Stephen Belanger)
Linkedin Support added (Stephen Belanger)
Support for configuring Facebook's OAuth dialog mode ( Barada Sahu )
Stopped some global scope pollution ( Fabian Jakobs )
- * 0.4.1
+ * **0.4.1**
Provide support to allow the authentication scope to 'survive' authentication redirects e.g. twitter, facebook etc. Allowing for scope usage with these strategies.
- * 0.4.0
+ * **0.4.0**
Introduce new tracing capabilities (provide an option of trace:true/function when constructing the auth middleware)
Introduce 2 new 'events/callbacks' : firstLoginHandler and logoutHandler to allow fairly standard authentication strategies.
Restructured the code to help with others reading it :)
Although I'm bumping the version number this release is still backwards compatible with 0.3.x, it just introduces significant new functionality.
- * 0.3.2
+ * **0.3.2**
Fixed Google OAuth Strategy
Provided *new* Google OAuth2 Strategy
- * 0.3.1
+ * **0.3.1**
Fixing package.json (no real changes)
- * 0.3.0
+ * **0.3.0**
Modified 'request.Authenticate(...)' to pass back 'undefined' when an active authentication strategy has required a communication with the browser to fully complete the authentication process. - *Possible Breaking change*
Fixed various failure cases for nearly all strategies (utilising the new 'undefined' authentication type)
Migrated Foursquare strategy to OAuth2 (requires at least v0.9.3 of node-oauth)
New getglue strategy
logout now takes an (optional) callback [this should be the default that is used.]
- * 0.2.3
- Added support for BitBucket (Thanks http://github.com/fjakobs)
- Fixed bug introduced in 0.2.2 when dealing with strategies that 'fail'
- * 0.2.2
- Added index.js ( Pau Ramon Revilla ) to root folder for easier inclusion
- Added support for SSO with http://t.sina.com.cn/ ( Danny Siu )
- Added hd query parameter to allow Google Hosted Domain for google sSO strategy ( Olmo Maldonado )
+ * **0.2.3**
+ Added support for BitBucket (Thanks http://github.com/fjakobs)
+ Fixed bug introduced in 0.2.2 when dealing with strategies that 'fail'
+ * **0.2.2**
+ Added index.js ( Pau Ramon Revilla ) to root folder for easier inclusion
+ Added support for SSO with http://t.sina.com.cn/ ( Danny Siu )
+ Added hd query parameter to allow Google Hosted Domain for google sSO strategy ( Olmo Maldonado )
Adds prelimenary support for the new HTTP MAC authentication scheme as defined by RFC-to-be:
http://tools.ietf.org/html/draft-hammer-oauth-v2-mac-token ( Eran Hammer-Lahav )
Added support for SSO with google (not using OpenId, but OAuth, so an intermediary approach) (Masahiro Hayashi)
Twitter strategy now supports OAuth Callback Urls (Ben Marvell)
Added option 'isAutoRespond' to handle authentication errors by the application with the HTTP Schemes. (Eran Hammer-Lahav)
Support for 'scoped' users (aka multiple con-current authentications) (Logan Aube)
- * 0.2.1
+ * **0.2.1**
Removed dead file that was seemingly breaking nDistro
- * 0.2.0
+ * **0.2.0**
Updated HTTP strategies c/o Robbie Clutton no longer require passwords to be stored in the plain. - *Breaking change*
Changed the default javascript file from auth.js to index.js. - *Breaking change*
Fixed the isAuthenticated mechanism to work with mongodb (Lakin Wecker, Richard Walsh)
Realm parameter now ignored in the Authorization header for the OAuth Provider strategy (Wade Simmons)
- * 0.1.3
+ * **0.1.3**
Strategies can now be written that do not require the session middleware.
- * 0.1.2
+ * **0.1.2**
Added in new strategy that allows your authentication strategy to be a custom OAuth provider.
- * 0.1.0
+ * **0.1.0**
New simplified configuration (connect idiomatic) of strategies implemented.
View
@@ -85,6 +85,7 @@ app.use(connect.static(__dirname + '/public'))
, auth.Http({validatePassword: validatePasswordFunction, getSharedSecretForUser: getSharedSecretForUserFunction})
, auth.Never()
, auth.Twitter({consumerKey: twitterConsumerKey, consumerSecret: twitterConsumerSecret})
+ , auth.Skyrock({consumerKey: skyrockConsumerKey, consumerSecret: skyrockConsumerSecret, callback: skyrockCallbackAddress})
, auth.Facebook({appId : fbId, appSecret: fbSecret, scope: "email", callback: fbCallbackAddress})
, auth.Github({appId : ghId, appSecret: ghSecret, callback: ghCallbackAddress})
, auth.Yahoo({consumerKey: yahooConsumerKey, consumerSecret: yahooConsumerSecret, callback: yahooCallbackAddress})
@@ -33,4 +33,7 @@ exports.linkedinConsumerSecret= "";
exports.linkedinCallback= "http://localhost/auth/linkedin_callback";
exports.yammerConsumerKey= "";
exports.yammerConsumerSecret= "";
-exports.yammerCallback= "http://localhost/auth/yammer_callback";
+exports.yammerCallback= "http://localhost/auth/yammer_callback";
+exports.skyrockConsumerKey= "";
+exports.skyrockConsumerSecret= "";
+exports.skyrockCallbackAddress= "http://local.host/auth/skyrock_callback";
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -109,6 +109,14 @@ <h2 id="slogan"></h2>
<td><a href="?login_with=linkedin"><img src="https://developer.linkedin.com/sites/default/files/js-signin.png"/></a></td>
</tr>
<tr class="row-a">
+ <td class="first">Skyrock</td>
+ <td><div style="float:left;margin-left:5px">
+ <a href="?login_with=skyrock" style="border:0px">
+ <img style="border:0px" src="/skyrock-connect-black.png"/>
+ </a>
+ </div></td>
+ </tr>
+ <tr class="row-a">
<td class="first">Twitter</td>
<td><div style="float:left;margin-left:5px">
<a href="?login_with=twitter" style="border:0px">
@@ -191,4 +199,4 @@ <h2 id="slogan"></h2>
<!-- footer ends-->
</div>
</body>
- </html>
+ </html>
@@ -0,0 +1,106 @@
+/*!
+* Skyrock.com auth strategie
+* see http://www.skyrock.com/developer/
+* MIT Licensed
+*/
+var OAuth= require("oauth").OAuth,
+ url = require("url"),
+ http = require('http');
+
+Skyrock = module.exports= function(options, server) {
+ options= options || {}
+ var that= {};
+ var my= {};
+
+ // Construct the internal OAuth client
+ my._oAuth = new OAuth(
+ "https://api.skyrock.com/v2/oauth/initiate"
+ , "https://api.skyrock.com/v2/oauth/token"
+ , options.consumerKey
+ , options.consumerSecret
+ , "1.0"
+ , options.callback || null
+ , "HMAC-SHA1"
+ );
+
+ // Give the strategy a name
+ that.name = options.name || "skyrock";
+
+ // Build the authentication routes required
+ that.setupRoutes= function(app) {
+ app.use('/auth/skyrock_callback', function(req, res){
+ req.authenticate([that.name], function(error, authenticated) {
+ res.writeHead(303, { 'Location': req.session.skyrock_redirect_url });
+ res.end('');
+ });
+ });
+ }
+
+ // Declare the method that actually does the authentication
+ that.authenticate= function(request, response, callback) {
+ //todo: if multiple connect middlewares were doing this, it would be more efficient to do it in the stack??
+ var parsedUrl= url.parse(request.originalUrl, true);
+
+ //todo: makw the call timeout ....
+ var self= this;
+ if( request.getAuthDetails()['skyrock_login_attempt_failed'] === true ) {
+ // Because we bounce through authentication calls across multiple requests
+ // we use this to keep track of the fact we *Really* have failed to authenticate
+ // so that we don't keep re-trying to authenticate forever.
+ delete request.getAuthDetails()['skyrock_login_attempt_failed'];
+ self.fail( callback );
+ } else {
+ if( parsedUrl.query && parsedUrl.query.denied ) {
+ self.trace( 'User denied OAuth Access' );
+ request.getAuthDetails()['skyrock_login_attempt_failed'] = true;
+ self.fail(callback);
+ } else if( parsedUrl.query && parsedUrl.query.oauth_token && request.session.auth["skyrock_oauth_token_secret"] ) {
+ self.trace( 'Phase 2/2 : Requesting an OAuth access token.' );
+ my._oAuth.getOAuthAccessToken(parsedUrl.query.oauth_token, request.session.auth["skyrock_oauth_token_secret"], parsedUrl.query.oauth_verifier,
+ function( error, oauth_token, oauth_token_secret, additionalParameters ) {
+ if( error ) {
+ self.trace( 'Error retrieving the OAuth Access Token: ' + JSON.stringify(error) );
+ request.getAuthDetails()['skyrock_login_attempt_failed'] = true;
+ self.fail(callback);
+ } else {
+ self.trace( 'Successfully retrieved the OAuth Access Token' );
+ request.session.auth["skyrock_oauth_token_secret"]= oauth_token_secret;
+ request.session.auth["skyrock_oauth_token"]= oauth_token;
+
+ // Get user profile data.
+ my._oAuth.getProtectedResource("https://api.skyrock.com/v2/user/get.json", 'get', oauth_token, oauth_token_secret, function (error, data, response) {
+ if (error) {
+ self.fail(callback);
+ } else {
+ var result = JSON.parse(data);
+ var user = {
+ username: result.username
+ , firstname: result.firstname
+ , name: result.name
+ , user_url: result.user_url
+ };
+ self.executionResult.user = user;
+ self.success(user, callback);
+ }
+ })
+ }
+ });
+ } else {
+ self.trace( 'Phase 1/2 - Requesting an OAuth Request Token' )
+ my._oAuth.getOAuthRequestToken(function(error, oauth_token, oauth_token_secret, oauth_authorize_url, additionalParameters ) {
+ if(error) {
+ self.trace( 'Error retrieving the OAuth Request Token: ' + JSON.stringify(error) );
+ callback(null); // Ignore the error upstream, treat as validation failure.
+ } else {
+ self.trace( 'Successfully retrieved the OAuth Request Token' );
+ request.session['skyrock_redirect_url']= request.originalUrl;
+ request.session.auth["skyrock_oauth_token_secret"]= oauth_token_secret;
+ request.session.auth["skyrock_oauth_token"]= oauth_token;
+ self.redirect(response, "https://api.skyrock.com/v2/oauth/authenticate?oauth_token=" + oauth_token, callback);
+ }
+ });
+ }
+ }
+ }
+ return that;
+};

0 comments on commit 30751ac

Please sign in to comment.