X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=skyquake%2Fframework%2Fcore%2Fapi_utils%2Futils.js;h=68775f8fede9ea3227de1329fdf69b67c2080d47;hb=3d39b18290b9cb3e10c1a80d91ac4819e7c58474;hp=0d1990c64a097306ef1eb68c7de0b049a39a4786;hpb=05b0bf7615e179d26d14d5d40f021fa3db9142a6;p=osm%2FUI.git diff --git a/skyquake/framework/core/api_utils/utils.js b/skyquake/framework/core/api_utils/utils.js index 0d1990c64..68775f8fe 100644 --- a/skyquake/framework/core/api_utils/utils.js +++ b/skyquake/framework/core/api_utils/utils.js @@ -95,7 +95,7 @@ var validateResponse = function(callerName, error, response, body, resolve, reje var checkAuthorizationHeader = function(req) { return new Promise(function(resolve, reject) { - if (req.get('Authorization') == null) { + if (req.session && req.session.authorization == null) { reject(); } else { resolve(); @@ -200,7 +200,7 @@ var passThroughConstructor = function(app) { uri: uri, method: 'GET', headers: _.extend({}, CONSTANTS.HTTP_HEADERS.accept[type], { - 'Authorization': req.get('Authorization'), + 'Authorization': req.session && req.session.authorization, forever: CONSTANTS.FOREVER_ON, rejectUnauthorized: false, }) @@ -217,6 +217,15 @@ var passThroughConstructor = function(app) { }); } +var getPortForProtocol = function(protocol) { + switch (protocol) { + case 'http': + return 8000; + case 'https': + return 8443; + } +} + module.exports = { /** * Ensure confd port is on api_server variable. @@ -233,5 +242,7 @@ module.exports = { sendSuccessResponse: sendSuccessResponse, - passThroughConstructor: passThroughConstructor + passThroughConstructor: passThroughConstructor, + + getPortForProtocol: getPortForProtocol };