From ebcf1c29503277663a34518029f343b8d5ce7ad4 Mon Sep 17 00:00:00 2001 From: ciaranj Date: Sun, 18 Jul 2010 23:43:39 +0100 Subject: [PATCH 1/3] Weird, found a missing argument that I could swear I'd put in previously?!!? --- Readme.md | 2 +- lib/oauth.js | 11 +++++++++-- package.json | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Readme.md b/Readme.md index 96da511..32199cc 100644 --- a/Readme.md +++ b/Readme.md @@ -9,7 +9,7 @@ at express-auth (http://github.com/ciaranj/express-auth) Change History ============== - +* 0.7.6 - Added in oauth_verifier property to getAccessToken required for 1.0A * 0.7.5 - Added in a main.js to simplify the require'ing of OAuth * 0.7.4 - Minor change to add an error listener to the OAuth client (thanks troyk) * 0.7.3 - OAuth 2 now sends a Content-Length Http header to keep nginx happy :) diff --git a/lib/oauth.js b/lib/oauth.js index 224f94d..562e435 100644 --- a/lib/oauth.js +++ b/lib/oauth.js @@ -233,8 +233,15 @@ exports.OAuth.prototype._performSecureRequest= function( oauth_token, oauth_toke request.end(); } -exports.OAuth.prototype.getOauthAccessToken= function(oauth_token, oauth_token_secret, callback) { - this._performSecureRequest( oauth_token, oauth_token_secret, "GET", this._accessUrl, null, function(error, data, response) { +exports.OAuth.prototype.getOauthAccessToken= function(oauth_token, oauth_token_secret, oauth_verifier, callback) { + var extraParams= {}; + if( typeof oauth_verifier == "function" ) { + callback= oauth_verifier; + } else { + extraParams.oauth_verifier= oauth_verifier; + } + + this._performSecureRequest( oauth_token, oauth_token_secret, "GET", this._accessUrl, extraParams, function(error, data, response) { if( error ) callback(error); else { var results= querystring.parse( data ); diff --git a/package.json b/package.json index 8bcd76d..3b8db58 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { "name" : "oauth" -, "version" : "0.7.5" +, "version" : "0.7.6" , "directories" : { "lib" : "./lib" } , "main" : "main.js" , "author" : "Ciaran Jessup" From 1c93463189346f5e03ee70016b4111046a560de7 Mon Sep 17 00:00:00 2001 From: ciaranj Date: Mon, 19 Jul 2010 00:25:00 +0100 Subject: [PATCH 2/3] it looks like non oauth_ parameters where being included within the authorization headers I believe this to be incorrect. --- Readme.md | 3 ++- lib/oauth.js | 6 +++++- package.json | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Readme.md b/Readme.md index 32199cc..0ca4470 100644 --- a/Readme.md +++ b/Readme.md @@ -8,7 +8,8 @@ Also provides rudimentary OAuth2 support, tested against facebook connect and gi at express-auth (http://github.com/ciaranj/express-auth) Change History -============== +============== +* 0.7.7 - Looks like non oauth_ parameters where appearing within the Authorization headers, which I believe to be inccorrect. * 0.7.6 - Added in oauth_verifier property to getAccessToken required for 1.0A * 0.7.5 - Added in a main.js to simplify the require'ing of OAuth * 0.7.4 - Minor change to add an error listener to the OAuth client (thanks troyk) diff --git a/lib/oauth.js b/lib/oauth.js index 562e435..72e0f9f 100644 --- a/lib/oauth.js +++ b/lib/oauth.js @@ -193,8 +193,12 @@ exports.OAuth.prototype._performSecureRequest= function( oauth_token, oauth_toke // build request authorization header var authHeader="OAuth "; - for( var i= 0 ; i < orderedParameters.length; i++) { + for( var i= 0 ; i < orderedParameters.length; i++) { + // Whilst the all the parameters should be included within the signature, only the oauth_ arguments + // should appear within the authorization header. + if( orderedParameters[i][0].match('^oauth_') != "oauth_") { authHeader+= this._encodeData(orderedParameters[i][0])+"=\""+ this._encodeData(orderedParameters[i][1])+"\","; + } } authHeader= authHeader.substring(0, authHeader.length-1); diff --git a/package.json b/package.json index 3b8db58..5d44047 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { "name" : "oauth" -, "version" : "0.7.6" +, "version" : "0.7.7" , "directories" : { "lib" : "./lib" } , "main" : "main.js" , "author" : "Ciaran Jessup" From 40cc690275c7406dcf9e3a359ffe2ec6797e64bd Mon Sep 17 00:00:00 2001 From: ciaranj Date: Mon, 19 Jul 2010 00:29:17 +0100 Subject: [PATCH 3/3] Ooops != != == ! ;) --- lib/oauth.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/oauth.js b/lib/oauth.js index 72e0f9f..607e0c7 100644 --- a/lib/oauth.js +++ b/lib/oauth.js @@ -196,7 +196,7 @@ exports.OAuth.prototype._performSecureRequest= function( oauth_token, oauth_toke for( var i= 0 ; i < orderedParameters.length; i++) { // Whilst the all the parameters should be included within the signature, only the oauth_ arguments // should appear within the authorization header. - if( orderedParameters[i][0].match('^oauth_') != "oauth_") { + if( orderedParameters[i][0].match('^oauth_') == "oauth_") { authHeader+= this._encodeData(orderedParameters[i][0])+"=\""+ this._encodeData(orderedParameters[i][1])+"\","; } }