diff --git a/NEWS.md b/NEWS.md index 8abe4ff8..38a7988d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,6 @@ 1.3.10 ------ +* Fixed problem identifying OAuth request protocol 1.3.9 ----- diff --git a/app/controllers/app.js b/app/controllers/app.js index aeceeb14..c522709b 100755 --- a/app/controllers/app.js +++ b/app/controllers/app.js @@ -109,6 +109,7 @@ function handleQuery(req, res) { var gn = "the_geom"; // TODO: read from configuration file var user_id; var tableCacheItem; + var requestProtocol = req.protocol; try { @@ -180,7 +181,7 @@ function handleQuery(req, res) { if(api_key) { ApiKeyAuth.verifyRequest(req, this); } else { - oAuth.verifyRequest(req, this); + oAuth.verifyRequest(req, this, requestProtocol); } }, function queryExplain(err, data){ diff --git a/app/models/oauth.js b/app/models/oauth.js index 2210fae4..a87c9f89 100644 --- a/app/models/oauth.js +++ b/app/models/oauth.js @@ -66,7 +66,7 @@ var oAuth = function(){ me.verifyRequest = function(req, callback){ var that = this; //TODO: review this - var http = arguments['2']; + var httpProto = arguments['2']; var passed_tokens; var ohash; var signature; @@ -99,7 +99,16 @@ var oAuth = function(){ var method = req.method; 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); // remove signature from passed_tokens