Fixed problem identifying OAuth request protocol

The protocol of a OAuth request wasn't being identified correctly. It
always considered that the request protocol was https.
This commit is contained in:
Luis Bosque 2013-05-14 18:01:37 +02:00
parent b16c5bb034
commit fcf95755b6
3 changed files with 14 additions and 3 deletions

View File

@ -1,5 +1,6 @@
1.3.10 1.3.10
------ ------
* Fixed problem identifying OAuth request protocol
1.3.9 1.3.9
----- -----

View File

@ -109,6 +109,7 @@ function handleQuery(req, res) {
var gn = "the_geom"; // TODO: read from configuration file var gn = "the_geom"; // TODO: read from configuration file
var user_id; var user_id;
var tableCacheItem; var tableCacheItem;
var requestProtocol = req.protocol;
try { try {
@ -180,7 +181,7 @@ function handleQuery(req, res) {
if(api_key) { if(api_key) {
ApiKeyAuth.verifyRequest(req, this); ApiKeyAuth.verifyRequest(req, this);
} else { } else {
oAuth.verifyRequest(req, this); oAuth.verifyRequest(req, this, requestProtocol);
} }
}, },
function queryExplain(err, data){ function queryExplain(err, data){

View File

@ -66,7 +66,7 @@ var oAuth = function(){
me.verifyRequest = function(req, callback){ me.verifyRequest = function(req, callback){
var that = this; var that = this;
//TODO: review this //TODO: review this
var http = arguments['2']; var httpProto = arguments['2'];
var passed_tokens; var passed_tokens;
var ohash; var ohash;
var signature; var signature;
@ -99,7 +99,16 @@ var oAuth = function(){
var method = req.method; var method = req.method;
var host = req.headers.host; var host = req.headers.host;
var path = http ? 'http://' + host + req.route.path : 'https://' + host + req.route.path;
if(!httpProto || (httpProto != 'http' && httpProto != 'https')) {
var msg = "Unknown HTTP protocol.";
err = new Error(msg);
err.http_status = 500;
callback(err);
return;
}
var path = httpProto + '://' + host + req.route.path;
that.splitParams(req.query); that.splitParams(req.query);
// remove signature from passed_tokens // remove signature from passed_tokens