NOTICKET: Refactor with sessions. Now holds auth on server
authorKIRAN KASHALKAR <kiran.kashalkar@riftio.com>
Fri, 24 Mar 2017 05:08:50 +0000 (01:08 -0400)
committerKIRAN KASHALKAR <kiran.kashalkar@riftio.com>
Fri, 24 Mar 2017 05:08:50 +0000 (01:08 -0400)
Signed-off-by: KIRAN KASHALKAR <kiran.kashalkar@riftio.com>
27 files changed:
skyquake/framework/core/api_utils/constants.js
skyquake/framework/core/api_utils/sockets.js
skyquake/framework/core/api_utils/utils.js
skyquake/framework/core/modules/api/descriptorModelMetaAPI.js
skyquake/framework/core/modules/api/projectManagementAPI.js
skyquake/framework/core/modules/api/restconf.js
skyquake/framework/core/modules/api/sessions.js [new file with mode: 0644]
skyquake/framework/core/modules/api/userManagementAPI.js
skyquake/framework/core/modules/routes/configuration.js
skyquake/framework/core/modules/routes/navigation.js
skyquake/framework/core/modules/routes/sessions.js [new file with mode: 0644]
skyquake/framework/core/views/login.html [new file with mode: 0644]
skyquake/framework/utils/utils.js
skyquake/package.json
skyquake/plugins/about/api/about.js
skyquake/plugins/accounts/api/accounts.js
skyquake/plugins/accounts/api/cloud_account/cloudAccount.js
skyquake/plugins/accounts/api/config_agent/configAgent.js
skyquake/plugins/accounts/api/sdn_account/sdnAccount.js
skyquake/plugins/composer/api/composer.js
skyquake/plugins/composer/api/packageFileHandler.js
skyquake/plugins/config/api/ro.js
skyquake/plugins/debug/api/debug.js
skyquake/plugins/launchpad/api/launchpad.js
skyquake/plugins/logging/api/logging.js
skyquake/plugins/logging/api/transforms.js
skyquake/skyquake.js

index 0aac7d2..7f54797 100644 (file)
@@ -73,6 +73,7 @@ constants.SOCKET_BASE_PORT = 3500;
 constants.SOCKET_POOL_LENGTH = 20;
 constants.SERVER_PORT = process.env.SERVER_PORT || 8000;
 constants.SECURE_SERVER_PORT = process.env.SECURE_SERVER_PORT || 8443;
+constants.REJECT_UNAUTHORIZED = false;
 
 constants.BASE_PACKAGE_UPLOAD_DESTINATION = 'upload/packages/';
 constants.PACKAGE_MANAGER_SERVER_PORT = 4567;
index 5e0b25b..0cd4918 100644 (file)
@@ -33,6 +33,7 @@ var url = require('url');
 var sockjs = require('sockjs');
 var websocket_multiplex = require('websocket-multiplex');
 var utils = require('./utils.js');
+var configurationAPI = require('../modules/api/configuration.js');
 
 
 var Subscriptions = function() {
@@ -278,7 +279,7 @@ function PollingSocket(url, req, interval, config) {
   self.isClosed = false;
   var requestHeaders = {};
   _.extend(requestHeaders, {
-    'Authorization': req.get('Authorization')
+    Cookie: req.get('Cookie')
   });
 
   var pollServer = function() {
index 5b17279..68775f8 100644 (file)
@@ -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,
                                })
index b0223b2..34d30b3 100644 (file)
@@ -36,7 +36,7 @@ ModelMeta.get = function(req) {
                 uri: utils.confdPort(api_server) + '/api/schema/nsd-catalog/nsd',
                 method: 'GET',
                 headers: _.extend({}, constants.HTTP_HEADERS.accept.collection, {
-                    'Authorization': req.get('Authorization')
+                    'Authorization': req.session && req.session.authorization
                 }),
                 forever: constants.FOREVER_ON,
                 rejectUnauthorized: false,
@@ -46,7 +46,7 @@ ModelMeta.get = function(req) {
                 uri: utils.confdPort(api_server) + '/api/schema/vnfd-catalog/vnfd',
                 method: 'GET',
                 headers: _.extend({}, constants.HTTP_HEADERS.accept.collection, {
-                    'Authorization': req.get('Authorization')
+                    'Authorization': req.session && req.session.authorization
                 }),
                 forever: constants.FOREVER_ON,
                 rejectUnauthorized: false,
index d73eb21..8eace6b 100644 (file)
@@ -36,7 +36,7 @@ ProjectManagement.get = function(req) {
                 uri: utils.confdPort(api_server) + '/api/operational/project',
                 method: 'GET',
                 headers: _.extend({}, constants.HTTP_HEADERS.accept.data, {
-                    'Authorization': req.get('Authorization')
+                    'Authorization': req.session && req.session.authorization
                 }),
                 forever: constants.FOREVER_ON,
                 rejectUnauthorized: false,
@@ -75,7 +75,7 @@ ProjectManagement.create = function(req) {
                 uri: utils.confdPort(api_server) + '/api/config/project',
                 method: 'POST',
                 headers: _.extend({}, constants.HTTP_HEADERS.accept.data, {
-                    'Authorization': req.get('Authorization')
+                    'Authorization': req.session && req.session.authorization
                 }),
                 forever: constants.FOREVER_ON,
                 json: data,
@@ -115,7 +115,7 @@ ProjectManagement.update = function(req) {
                 uri: utils.confdPort(api_server) + '/api/config/project',
                 method: 'PUT',
                 headers: _.extend({}, constants.HTTP_HEADERS.accept.data, {
-                    'Authorization': req.get('Authorization')
+                    'Authorization': req.session && req.session.authorization
                 }),
                 forever: constants.FOREVER_ON,
                 json: data,
@@ -157,7 +157,7 @@ ProjectManagement.delete = function(req) {
         _.extend(requestHeaders,
             constants.HTTP_HEADERS.accept.data,
             constants.HTTP_HEADERS.content_type.data, {
-                'Authorization': req.get('Authorization')
+                'Authorization': req.session && req.session.authorization
             });
         rp({
             url: url,
index 5ba0eb5..03f2721 100644 (file)
@@ -45,7 +45,7 @@ restconfAPI['streams'].get = function(req) {
             url: uri + url + '?deep',
             method: 'GET',
             headers: _.extend({}, constants.HTTP_HEADERS.accept.data, {
-                'Authorization': req.get('Authorization')
+                'Authorization': req.session && req.session.authorization
             }),
             forever: constants.FOREVER_ON,
             rejectUnauthorized: false,
diff --git a/skyquake/framework/core/modules/api/sessions.js b/skyquake/framework/core/modules/api/sessions.js
new file mode 100644 (file)
index 0000000..c8a0223
--- /dev/null
@@ -0,0 +1,205 @@
+/*
+ * 
+ *   Copyright 2016 RIFT.IO Inc
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+
+/**
+ * sessions api module. Provides API functions for sessions
+ * @module framework/core/modules/api/sessions
+ * @author Kiran Kashalkar <kiran.kashalkar@riftio.com>
+ */
+
+var Promise = require('bluebird');
+var constants = require('../../api_utils/constants');
+var utils = require('../../api_utils/utils');
+var request = utils.request;
+var rp = require('request-promise');
+var sessionsAPI = {};
+var _ = require('lodash');
+var base64 = require('base-64');
+var APIVersion = '/v2';
+
+function logAndReject(mesg, reject) {
+    res.errorMessage = {
+        error: mesg
+    }
+    console.log(mesg);
+    reject(res);
+}
+
+function logAndRedirectToLogin(mesg, res, req) {
+    console.log(mesg);
+    res.render('login.html?api_server=' + req.query['api_server']);
+    res.end();
+}
+
+sessionsAPI.create = function(req, res) {
+    var api_server = req.query["api_server"];
+    var uri = utils.confdPort(api_server);
+    var login_url = uri + APIVersion + '/api/login';
+    var project_url = uri + APIVersion + '/api/operational/project';
+    var authorization_header_string = 'Basic ' + base64.encode(req.body['username'] + ':' + req.body['password']);
+    return new Promise(function(resolve, reject) {
+        Promise.all([
+            rp({
+                url: login_url,
+                method: 'POST',
+                headers: _.extend({}, constants.HTTP_HEADERS.accept.data, {
+                    'Authorization': authorization_header_string
+                }),
+                forever: constants.FOREVER_ON,
+                rejectUnauthorized: constants.REJECT_UNAUTHORIZED,
+                resolveWithFullResponse: true
+            }),
+            rp({
+                url: project_url,
+                method: 'GET',
+                headers: _.extend({}, constants.HTTP_HEADERS.accept.collection, {
+                    'Authorization': authorization_header_string
+                }),
+                forever: constants.FOREVER_ON,
+                rejectUnauthorized: constants.REJECT_UNAUTHORIZED,
+                resolveWithFullResponse: true
+            })
+
+        ]).then(function(results) {
+            // results[0].statusCode => 200/201
+            // results[1].body.collection['rw-project:project'] => List of projects OR 204 with no content
+            if (results[0].statusCode != constants.HTTP_RESPONSE_CODES.SUCCESS.OK) {
+                var errorMsg = 'Invalid credentials provided!';
+                logAndRedirectToLogin(errorMsg, res, req);
+                return;
+            }
+
+            var username = req.body['username'];
+            var project_list_for_user = [];
+
+            if (results[1].statusCode == constants.HTTP_RESPONSE_CODES.SUCCESS.NO_CONTENT) {
+                console.log('No projects added or user ', username ,' not privileged to view projects.');
+            } else {
+                // go through projects and get list of projects that this user belongs to.
+                // pick first one as default project?
+
+                var projects = JSON.parse(results[1].body).collection['rw-project:project'];
+                projects && projects.map(function(project) {
+                    project['project-config'] &&
+                    project['project-config']['user'] &&
+                    project['project-config']['user'].map(function(user) {
+                        if (user['user-name'] == username) {
+                            project_list_for_user.push(project.name);
+                        }
+                    });
+                });
+
+                req.session.projectId = (project_list_for_user.length > 0) && project_list_for_user[0];
+            }
+
+            req.session.authorization = authorization_header_string;
+            req.session.loggedIn = true;
+
+            var successMsg = 'User =>' + username + ' successfully logged in.';
+            successMsg += req.session.projectId ? 'Project =>' + req.session.projectId + ' set as default.' : '';
+
+            console.log(successMsg);
+
+            var response = {
+                statusCode: constants.HTTP_RESPONSE_CODES.SUCCESS.CREATED,
+                data: JSON.stringify({
+                    status: successMsg
+                })
+            };
+            resolve(response);
+
+        }).catch(function(error) {
+            // Something went wrong - Redirect to /login
+            var errorMsg = 'Error logging in or getting list of projects. Error: ' + error;
+            console.log(errorMsg);
+            logAndRedirectToLogin(errorMsg, res, req);
+        });
+    })
+};
+
+sessionsAPI.addProjectToSession = function(req, res) {
+    return new Promise(function(resolve, reject) {
+        if (req.session && req.session.loggedIn == true) {
+            req.session.projectId = req.params.projectId;
+            var successMsg = 'Added project' + projectId + ' to session' + req.sessionID;
+            console.log(successMsg);
+
+            return resolve ({
+                statusCode: constants.HTTP_RESPONSE_CODES.SUCCESS.OK,
+                data: JSON.stringify({
+                    status: successMsg
+                })
+            });
+        }
+
+        var errorMsg = 'Session does not exist or not logged in';
+        logAndReject(errorMsg, reject);
+    });
+}
+
+sessionsAPI.delete = function(req, res) {
+    var reqRef = req;
+    var res = res;
+    var api_server = req.query["api_server"];
+    var uri = utils.confdPort(api_server);
+    var url = uri + '/api/logout';
+    return new Promise(function(resolve, reject) {
+        Promise.all([
+            rp({
+                url: url,
+                method: 'POST',
+                headers: _.extend({}, constants.HTTP_HEADERS.accept.data, {
+                    'Authorization': req.session.authorization
+                }),
+                forever: constants.FOREVER_ON,
+                rejectUnauthorized: constants.REJECT_UNAUTHORIZED
+            }),
+            new Promise(function(success, failure) {
+                req.session.destroy(function(err) {
+                    if (err) {
+                        var errorMsg = 'Error deleting session. Error: ' + err;
+                        console.log(errorMsg);
+                        success({
+                            status: 'error',
+                            message: errorMsg
+                        });
+                    }
+
+                    var successMsg = 'Success deleting session';
+                    console.log(successMsg);
+
+                    success({
+                        status: 'success',
+                        message: successMsg
+                    });
+                });
+            })
+        ]).then(function(result) {
+            // assume the session was deleted!
+            var message = 'Session was deleted.'
+            logAndRedirectToLogin(message, res, req);
+
+        }).catch(function(error) {
+            var message = 'Error deleting session or logging out. Error:' + error;
+            logAndRedirectToLogin(message, res, req);
+        });
+    });
+}
+
+
+module.exports = sessionsAPI;
index 3972122..e88a5dc 100644 (file)
@@ -36,7 +36,7 @@ UserManagement.get = function(req) {
                 uri: utils.confdPort(api_server) + '/api/operational/user-config/users',
                 method: 'GET',
                 headers: _.extend({}, constants.HTTP_HEADERS.accept.data, {
-                    'Authorization': req.get('Authorization')
+                    'Authorization': req.session && req.session.authorization
                 }),
                 forever: constants.FOREVER_ON,
                 rejectUnauthorized: false,
@@ -75,7 +75,7 @@ UserManagement.create = function(req) {
                 uri: utils.confdPort(api_server) + '/api/config/user-config',
                 method: 'POST',
                 headers: _.extend({}, constants.HTTP_HEADERS.accept.data, {
-                    'Authorization': req.get('Authorization')
+                    'Authorization': req.session && req.session.authorization
                 }),
                 forever: constants.FOREVER_ON,
                 json: data,
@@ -115,7 +115,7 @@ UserManagement.update = function(req) {
             uri: utils.confdPort(api_server) + '/api/operations/change-password',
             method: 'POST',
             headers: _.extend({}, constants.HTTP_HEADERS.accept.data, {
-                'Authorization': req.get('Authorization')
+                'Authorization': req.session && req.session.authorization
             }),
             forever: constants.FOREVER_ON,
             json: {
@@ -136,7 +136,7 @@ UserManagement.update = function(req) {
                 uri: utils.confdPort(api_server) + '/api/config/user-config',
                 method: 'PUT',
                 headers: _.extend({}, constants.HTTP_HEADERS.accept.data, {
-                    'Authorization': req.get('Authorization')
+                    'Authorization': req.session && req.session.authorization
                 }),
                 forever: constants.FOREVER_ON,
                 json: data,
@@ -179,7 +179,7 @@ UserManagement.delete = function(req) {
         _.extend(requestHeaders,
             constants.HTTP_HEADERS.accept.data,
             constants.HTTP_HEADERS.content_type.data, {
-                'Authorization': req.get('Authorization')
+                'Authorization': req.session && req.session.authorization
             });
         rp({
             url: url,
index b789ff0..37d87fe 100644 (file)
@@ -74,7 +74,7 @@ function checkAuth(uri, req){
             uri: uri,
             method: 'GET',
             headers: _.extend({}, {
-                'Authorization': req.get('Authorization'),
+                'Authorization': req.session && req.session.authorization,
                 forever: CONSTANTS.FOREVER_ON,
                 rejectUnauthorized: false,
             })
index 82c7ec5..9b8fbf7 100644 (file)
@@ -37,8 +37,20 @@ Router.use(bodyParser.urlencoded({
     extended: true
 }));
 
-Router.get('/', cors(), function(req, res, next) {
-       res.redirect('/launchpad/?api_server=' + req.protocol + '://' + configurationAPI.globalConfiguration.get().api_server + '&upload_server=' + req.protocol + '://' + (configurationAPI.globalConfiguration.get().upload_server || req.hostname));
+Router.get('/login.html', cors(), function(req, res) {
+       res.render('login.html');
+       res.end();
+});
+
+Router.get('/', cors(), function(req, res) {
+       var api_server = req.query['api_server'] || (req.protocol + '://' + configurationAPI.globalConfiguration.get().api_server);
+       if (req.session.loggedIn) {
+               console.log('Logged in. Redirect to launchpad')
+               res.redirect('/launchpad/?api_server=' + api_server + '&upload_server=' + req.protocol + '://' + (configurationAPI.globalConfiguration.get().upload_server || req.hostname));
+       } else {
+               console.log('Redirect to login.html');
+               res.redirect('login.html?api_server=' + api_server);
+       }
 });
 
 Router.get('/nav', cors(), function(req, res) {
diff --git a/skyquake/framework/core/modules/routes/sessions.js b/skyquake/framework/core/modules/routes/sessions.js
new file mode 100644 (file)
index 0000000..bd2179b
--- /dev/null
@@ -0,0 +1,62 @@
+
+/*
+ *
+ *   Copyright 2016 RIFT.IO Inc
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+
+/**
+ * Node sessions routes module.
+ * Provides a RESTful API to manage sessions.
+ * @module framework/core/modules/routes/sessions
+ * @author Kiran Kashalkar <kiran.kashalkar@riftio.com>
+ */
+
+var cors = require('cors');
+var bodyParser = require('body-parser');
+var sessionsAPI = require('../api/sessions');
+var Router = require('express').Router();
+var utils = require('../../api_utils/utils');
+var CONSTANTS = require('../../api_utils/constants.js');
+var request = require('request');
+var _ = require('lodash');
+
+Router.use(bodyParser.json());
+Router.use(cors());
+Router.use(bodyParser.urlencoded({
+    extended: true
+}));
+
+Router.post('/session', cors(), function(req, res) {
+    sessionsAPI.create(req, res).then(function(data) {
+        utils.sendSuccessResponse(data, res);
+       });
+});
+
+// For project switcher UI
+Router.put('/session/:projectId', cors(), function(req, res) {
+    sessionsAPI.addProjectToSession(req, res).then(function(data) {
+        utils.sendSuccessResponse(data, res);
+    }, function(error) {
+        utils.sendErrorResponse(error, res);
+    });
+});
+
+Router.delete('/session', cors(), function(req, res) {
+    sessionsAPI.delete(req, res);
+});
+
+
+module.exports = Router;
diff --git a/skyquake/framework/core/views/login.html b/skyquake/framework/core/views/login.html
new file mode 100644 (file)
index 0000000..eb5e714
--- /dev/null
@@ -0,0 +1,118 @@
+<html>
+<head>
+<style>
+    html, body {
+        height:100%;
+        width:100%;
+        background: #f1f1f1;
+    }
+
+    #loginForm {
+        display: flex;
+        flex-direction: column;
+        height: 100%;
+        text-align: center;
+        align-items: center;
+    }
+
+    #loginForm .logo {
+        background: url('/img/svg/osm-logo_color_rgb.svg') no-repeat center;
+        background-size: contain;
+        width: 154px;
+        height: 102px;
+        margin-left: auto;
+        margin-right: auto;
+        margin-top: 150px;
+        margin-bottom: 20px;
+    }
+
+    #loginForm input {
+        width: 550px;
+        height: 65px;
+        min-width: auto;
+        margin-bottom: 40px;
+        box-shadow: inset 0 1px 2px rgba(0, 0, 0, .39), 0 -1px 1px #fff, 0 1px 0 #fff;
+        font-size: 20px;
+        padding-left: 25px;
+    }
+
+    #loginForm #submit {
+        display: inline-block;
+        -webkit-box-shadow: 4px 4px 1px 0 #d9d9d9;
+        -moz-box-shadow: 4px 4px 1px 0 #d9d9d9;
+        box-shadow: 4px 4px 1px 0 #d9d9d9;
+        background-color: #333;
+        color: #fff;
+        text-decoration: none;
+    }
+
+    #loginForm .title {
+        margin-bottom: 40px;
+        font-size: 1.625rem;
+        font-weight: 400;
+        text-decoration: none;
+        text-transform: uppercase;
+        font-family: roboto-thin, Helvetica, Arial, sans-serif;
+    }
+
+</style>
+<title>Login Page</title>
+<script src='/jquery'></script>
+<script>
+
+function getSearchParams(url) {
+    var a = document.createElement('a');
+    a.href = url;
+    var params = {};
+    var items = a.search.replace('?', '').split('&');
+    for (var i = 0; i < items.length; i++) {
+      if (items[i].length > 0) {
+        var key_value = items[i].split('=');
+        params[key_value[0]] = key_value[1];
+      }
+    }
+    return params;
+}
+
+$(document).ready(function() {
+    var username;
+    var pass;
+    var api_server = getSearchParams(window.location).api_server;
+    $('#submit').click(function() {
+        username=$('#username').val();
+        pass=$('#password').val();
+        /*
+        * Perform some validation here.
+        */
+        $.ajax({
+            url: '/session?api_server=' + api_server,
+            type: 'POST',
+            data: {
+                username: username,
+                password: pass
+            },
+            success: function(data) {
+                window.location.href='/?api_server=' + api_server;
+            }
+        });
+    });
+
+    $('#loginForm').on('keyup', function(e) {
+        if (e.keyCode == 13) {
+            $('#submit').click();
+        }
+    });
+});
+
+</script>
+</head>
+<body>
+    <form id='loginForm' autocomplete='on'>
+        <div class='logo'> </div>
+        <h1 class='title'>Launchpad Login</h1>
+        <input type='text' size='40' placeholder='Username' id='username'><br />
+        <input type='password' size='40' placeholder='Password' id='password'><br />
+        <input type='button' value='Submit' id='submit'>
+    </form>
+</body>
+</html>
\ No newline at end of file
index e8e9ad1..be3278d 100644 (file)
@@ -129,8 +129,9 @@ Utils.getDescriptorModelMeta = function() {
 }
 
 Utils.addAuthorizationStub = function(xhr) {
-    var Auth = window.sessionStorage.getItem("auth");
-    xhr.setRequestHeader('Authorization', 'Basic ' + Auth);
+    // NO-OP now that we are dealing with it on the server
+    // var Auth = window.sessionStorage.getItem("auth");
+    // xhr.setRequestHeader('Authorization', 'Basic ' + Auth);
 };
 
 Utils.getByteDataWithUnitPrefix = function(number, precision) {
@@ -208,10 +209,22 @@ Utils.clearAuthentication = function(callback) {
     window.sessionStorage.removeItem("auth");
     AuthActions.notAuthenticated();
     window.sessionStorage.setItem("locationRefHash", window.location.hash);
+    $.ajax({
+        url: '//' + window.location.hostname + ':' + window.location.port + '/session?api_server=' + API_SERVER,
+        type: 'DELETE',
+        success: function(data) {
+            console.log('User logged out');
+        },
+        error: function(data) {
+            console.log('Problem logging user out');
+        }
+    });
+
+
     if (callback) {
         callback();
     } else {
-        window.location.hash = Utils.loginHash;
+        window.location.replace(window.location.protocol + '//' + window.location.hostname + ':' + window.location.port + '/?api_server=' + API_SERVER);
     }
 }
 Utils.isNotAuthenticated = function(windowLocation, callback) {
index 8578562..60d22db 100644 (file)
@@ -12,6 +12,7 @@
   "dependencies": {
     "alt": "^0.18.3",
     "alt-container": "^1.0.2",
+    "base-64": "^0.1.0",
     "bluebird": "^3.4.1",
     "body-parser": "^1.14.2",
     "cors": "^2.7.1",
index d77a43a..82cbafb 100644 (file)
@@ -32,7 +32,7 @@ About.getVCS = function(req) {
     var requestHeaders = {};
     _.extend(requestHeaders,
       constants.HTTP_HEADERS.accept.data, {
-        'Authorization': req.get('Authorization')
+        'Authorization': req.session && req.session.authorization
       });
     request({
         url: utils.confdPort(api_server) + APIVersion + '/api/operational/vcs/info?deep',
@@ -64,7 +64,7 @@ About.getVersion = function(req) {
     var requestHeaders = {};
     _.extend(requestHeaders,
       constants.HTTP_HEADERS.accept.data, {
-        'Authorization': req.get('Authorization')
+        'Authorization': req.session && req.session.authorization
       });
     request({
         url: utils.confdPort(api_server) + APIVersion + '/api/operational/version?deep',
@@ -116,7 +116,7 @@ About.uptime = function(req) {
     var requestHeaders = {};
     _.extend(requestHeaders,
       constants.HTTP_HEADERS.accept.data, {
-        'Authorization': req.get('Authorization')
+        'Authorization': req.session && req.session.authorization
       });
     request({
         url: utils.confdPort(api_server) + APIVersion + '/api/operational/uptime/uptime',
index ec74f51..cf0e404 100644 (file)
@@ -93,7 +93,7 @@ function getAccount(req) {
         _.extend(
             requestHeaders,
             id ? constants.HTTP_HEADERS.accept.data : constants.HTTP_HEADERS.accept.collection, {
-                'Authorization': req.get('Authorization')
+                'Authorization': req.session && req.session.authorization
             }
         );
 
@@ -160,7 +160,7 @@ function updateAccount(req) {
         _.extend(requestHeaders,
             constants.HTTP_HEADERS.accept.data,
             constants.HTTP_HEADERS.content_type.data, {
-                'Authorization': req.get('Authorization')
+                'Authorization': req.session && req.session.authorization
             });
         request({
             url: url,
@@ -194,7 +194,7 @@ function deleteAccount(req) {
         _.extend(requestHeaders,
             constants.HTTP_HEADERS.accept.data,
             constants.HTTP_HEADERS.content_type.data, {
-                'Authorization': req.get('Authorization')
+                'Authorization': req.session && req.session.authorization
             });
         request({
             url: url,
@@ -238,7 +238,7 @@ function refreshAccountConnectionStatus (req) {
     var headers = _.extend({},
         constants.HTTP_HEADERS.accept.data,
         constants.HTTP_HEADERS.content_type.data, {
-            'Authorization': req.get('Authorization')
+            'Authorization': req.session && req.session.authorization
         }
     );
     return new Promise(function(resolve, reject) {
index 5475750..28f780c 100644 (file)
@@ -40,7 +40,7 @@ Cloud.get = function(req) {
       var requestHeaders = {};
       _.extend(requestHeaders,
         constants.HTTP_HEADERS.accept.collection, {
-          'Authorization': req.get('Authorization')
+          'Authorization': req.session && req.session.authorization
         });
 
       request({
@@ -77,7 +77,7 @@ Cloud.get = function(req) {
       var requestHeaders = {};
       _.extend(requestHeaders,
         constants.HTTP_HEADERS.accept.data, {
-          'Authorization': req.get('Authorization')
+          'Authorization': req.session && req.session.authorization
         });
 
       request({
@@ -128,7 +128,7 @@ Cloud.create = function(req) {
     _.extend(requestHeaders,
       constants.HTTP_HEADERS.accept.data,
       constants.HTTP_HEADERS.content_type.data, {
-        'Authorization': req.get('Authorization')
+        'Authorization': req.session && req.session.authorization
       });
 
     request({
@@ -167,7 +167,7 @@ Cloud.update = function(req) {
     _.extend(requestHeaders,
       constants.HTTP_HEADERS.accept.data,
       constants.HTTP_HEADERS.content_type.data, {
-        'Authorization': req.get('Authorization')
+        'Authorization': req.session && req.session.authorization
       });
 
     request({
@@ -209,7 +209,7 @@ Cloud.delete = function(req) {
     var requestHeaders = {};
     _.extend(requestHeaders,
       constants.HTTP_HEADERS.accept.data, {
-        'Authorization': req.get('Authorization')
+        'Authorization': req.session && req.session.authorization
       });
     request({
       url: utils.confdPort(api_server) + APIVersion + '/api/config/cloud/account/' + id,
@@ -237,7 +237,7 @@ Cloud.getResources = function(req) {
     var requestHeaders = {};
     _.extend(requestHeaders,
       constants.HTTP_HEADERS.accept.data, {
-        'Authorization': req.get('Authorization')
+        'Authorization': req.session && req.session.authorization
       });
 
     request({
@@ -280,7 +280,7 @@ Cloud.getPools = function(req) {
     var requestHeaders = {};
     _.extend(requestHeaders,
       constants.HTTP_HEADERS.accept.data, {
-        'Authorization': req.get('Authorization')
+        'Authorization': req.session && req.session.authorization
       });
 
     request({
index 8d1734b..e717c4e 100644 (file)
@@ -37,7 +37,7 @@ ConfigAgentAccount.get = function(req) {
             var requestHeaders = {};
             _.extend(requestHeaders,
                 constants.HTTP_HEADERS.accept.collection, {
-                    'Authorization': req.get('Authorization')
+                    'Authorization': req.session && req.session.authorization
                 });
 
             request({
@@ -77,7 +77,7 @@ ConfigAgentAccount.get = function(req) {
             var requestHeaders = {};
             _.extend(requestHeaders,
                 constants.HTTP_HEADERS.accept.data, {
-                    'Authorization': req.get('Authorization')
+                    'Authorization': req.session && req.session.authorization
                 });
 
             request({
@@ -130,7 +130,7 @@ ConfigAgentAccount.create = function(req) {
         _.extend(requestHeaders,
             constants.HTTP_HEADERS.accept.data,
             constants.HTTP_HEADERS.content_type.data, {
-                'Authorization': req.get('Authorization')
+                'Authorization': req.session && req.session.authorization
             });
 
         request({
@@ -169,7 +169,7 @@ ConfigAgentAccount.update = function(req) {
         _.extend(requestHeaders,
             constants.HTTP_HEADERS.accept.data,
             constants.HTTP_HEADERS.content_type.data, {
-                'Authorization': req.get('Authorization')
+                'Authorization': req.session && req.session.authorization
             });
 
         request({
@@ -211,7 +211,7 @@ ConfigAgentAccount.delete = function(req) {
         var requestHeaders = {};
         _.extend(requestHeaders,
             constants.HTTP_HEADERS.accept.data, {
-                'Authorization': req.get('Authorization')
+                'Authorization': req.session && req.session.authorization
             });
         request({
             url: utils.confdPort(api_server) + '/api/config/config-agent/account/' + id,
index 6757c28..a3ddf0b 100644 (file)
@@ -38,7 +38,7 @@ Sdn.get = function(req) {
       var requestHeaders = {};
       _.extend(requestHeaders,
         constants.HTTP_HEADERS.accept.collection, {
-          'Authorization': req.get('Authorization')
+          'Authorization': req.session && req.session.authorization
         });
       request({
           url: utils.confdPort(api_server) + '/api/operational/sdn/account?deep',
@@ -77,7 +77,7 @@ Sdn.get = function(req) {
       var requestHeaders = {};
       _.extend(requestHeaders,
         constants.HTTP_HEADERS.accept.data, {
-          'Authorization': req.get('Authorization')
+          'Authorization': req.session && req.session.authorization
         });
 
       request({
@@ -130,7 +130,7 @@ Sdn.create = function(req) {
     _.extend(requestHeaders,
       constants.HTTP_HEADERS.accept.data,
       constants.HTTP_HEADERS.content_type.data, {
-        'Authorization': req.get('Authorization')
+        'Authorization': req.session && req.session.authorization
       });
 
     request({
@@ -168,7 +168,7 @@ Sdn.update = function(req) {
     _.extend(requestHeaders,
       constants.HTTP_HEADERS.accept.data,
       constants.HTTP_HEADERS.content_type.data, {
-        'Authorization': req.get('Authorization')
+        'Authorization': req.session && req.session.authorization
       });
 
     request({
@@ -211,7 +211,7 @@ Sdn.delete = function(req) {
     var requestHeaders = {};
     _.extend(requestHeaders,
       constants.HTTP_HEADERS.accept.data, {
-        'Authorization': req.get('Authorization')
+        'Authorization': req.session && req.session.authorization
       });
 
     request({
index ebe5636..a4f9bd9 100644 (file)
@@ -40,7 +40,7 @@ Composer.get = function(req) {
                 uri: utils.confdPort(api_server) + APIVersion + '/api/config/nsd-catalog/nsd?deep',
                 method: 'GET',
                 headers: _.extend({}, constants.HTTP_HEADERS.accept.collection, {
-                    'Authorization': req.get('Authorization')
+                    'Authorization': req.session && req.session.authorization
                 }),
                 forever: constants.FOREVER_ON,
                 rejectUnauthorized: false,
@@ -50,7 +50,7 @@ Composer.get = function(req) {
                 uri: utils.confdPort(api_server) + APIVersion + '/api/config/vnfd-catalog/vnfd?deep',
                 method: 'GET',
                 headers: _.extend({}, constants.HTTP_HEADERS.accept.collection, {
-                    'Authorization': req.get('Authorization')
+                    'Authorization': req.session && req.session.authorization
                 }),
                 forever: constants.FOREVER_ON,
                 rejectUnauthorized: false,
@@ -60,7 +60,7 @@ Composer.get = function(req) {
                 uri: utils.confdPort(api_server) + APIVersion + '/api/operational/ns-instance-opdata?deep',
                 method: 'GET',
                 headers: _.extend({}, constants.HTTP_HEADERS.accept.data, {
-                    'Authorization': req.get('Authorization')
+                    'Authorization': req.session && req.session.authorization
                 }),
                 forever: constants.FOREVER_ON,
                 rejectUnauthorized: false,
@@ -73,7 +73,7 @@ Composer.get = function(req) {
             //   headers: _.extend({},
             //     constants.HTTP_HEADERS.accept.collection,
             //     {
-            //       'Authorization': req.get('Authorization')
+            //       'Authorization': req.session && req.session.authorization
             //     }),
             //   forever: constants.FOREVER_ON,
             // rejectUnauthorized: false,
@@ -173,7 +173,7 @@ Composer.delete = function(req) {
             uri: utils.confdPort(api_server) + APIVersion + '/api/config/' + catalogType + '-catalog/' + catalogType + '/' + id,
             method: 'DELETE',
             headers: _.extend({}, constants.HTTP_HEADERS.accept.data, {
-                'Authorization': req.get('Authorization')
+                'Authorization': req.session && req.session.authorization
             }),
             forever: constants.FOREVER_ON,
             rejectUnauthorized: false,
@@ -189,7 +189,7 @@ Composer.delete = function(req) {
 Composer.getVNFD = function(req) {
     var api_server = req.query['api_server'];
     var vnfdID = req.body.data;
-    var authorization = req.get('Authorization');
+    var authorization = req.session && req.session.authorization;
     var VNFDs = [];
     if (typeof(vnfdID) == "object" && vnfdID.constructor.name == "Array") {
         vnfdID.map(function(id) {
@@ -254,7 +254,7 @@ Composer.create = function(req) {
     return new Promise(function(resolve, reject) {
         var requestHeaders = {};
         _.extend(requestHeaders, constants.HTTP_HEADERS.accept.data, constants.HTTP_HEADERS.content_type.data, {
-            'Authorization': req.get('Authorization')
+            'Authorization': req.session && req.session.authorization
         });
         request({
             uri: utils.confdPort(api_server) + '/api/config/' + catalogType + '-catalog',
@@ -284,7 +284,7 @@ Composer.updateSave = function(req) {
     return new Promise(function(resolve, reject) {
         var requestHeaders = {};
         _.extend(requestHeaders, constants.HTTP_HEADERS.accept.data, constants.HTTP_HEADERS.content_type.data, {
-            'Authorization': req.get('Authorization')
+            'Authorization': req.session && req.session.authorization
         });
         request({
             uri: utils.confdPort(api_server) + APIVersion + '/api/config/' + catalogType + '-catalog' + '/' + catalogType + '/' + id,
@@ -325,7 +325,7 @@ Composer.update = function(req) {
                 uri: utils.confdPort(api_server) + '/api/operations/package-update',
                 method: 'POST',
                 headers: _.extend({}, constants.HTTP_HEADERS.accept.collection, {
-                    'Authorization': req.get('Authorization')
+                    'Authorization': req.session && req.session.authorization
                 }),
                 forever: constants.FOREVER_ON,
                 rejectUnauthorized: false,
@@ -377,7 +377,7 @@ Composer.upload = function(req) {
                 uri: utils.confdPort(api_server) + '/api/operations/package-create',
                 method: 'POST',
                 headers: _.extend({}, constants.HTTP_HEADERS.accept.collection, {
-                    'Authorization': req.get('Authorization')
+                    'Authorization': req.session && req.session.authorization
                 }),
                 forever: constants.FOREVER_ON,
                 rejectUnauthorized: false,
@@ -439,7 +439,7 @@ Composer.addFile = function(req) {
                 uri: utils.confdPort(api_server) + '/api/operations/package-file-add',
                 method: 'POST',
                 headers: _.extend({}, constants.HTTP_HEADERS.accept.collection, {
-                    'Authorization': req.get('Authorization')
+                    'Authorization': req.session && req.session.authorization
                 }),
                 forever: constants.FOREVER_ON,
                 rejectUnauthorized: false,
@@ -477,7 +477,7 @@ Composer.exportPackage = function(req) {
                 uri: utils.confdPort(api_server) + '/api/operations/package-export',
                 method: 'POST',
                 headers: _.extend({}, constants.HTTP_HEADERS.accept.collection, {
-                    'Authorization': req.get('Authorization')
+                    'Authorization': req.session && req.session.authorization
                 }),
                 forever: constants.FOREVER_ON,
                 rejectUnauthorized: false,
@@ -535,7 +535,7 @@ FileManager.get = function(req) {
                 uri: utils.confdPort(api_server) + '/api/operations/rw-pkg-mgmt:package-file-delete',
                 method: 'POST',
                 headers: _.extend({}, constants.HTTP_HEADERS.accept.collection, {
-                    'Authorization': req.get('Authorization')
+                    'Authorization': req.session && req.session.authorization
                 }),
                 json: payload,
                 forever: constants.FOREVER_ON,
@@ -557,7 +557,7 @@ FileManager.get = function(req) {
                 uri: utils.confdPort(api_server) + '/api/operations/rw-pkg-mgmt:package-file-add',
                 method: 'POST',
                 headers: _.extend({}, constants.HTTP_HEADERS.accept.collection, {
-                    'Authorization': req.get('Authorization')
+                    'Authorization': req.session && req.session.authorization
                 }),
                 json: payload,
                 forever: constants.FOREVER_ON,
@@ -579,7 +579,7 @@ FileManager.get = function(req) {
                 uri: utils.confdPort(api_server) + '/api/operations/get-package-endpoint',
                 method: 'POST',
                 headers: _.extend({}, constants.HTTP_HEADERS.accept.collection, {
-                    'Authorization': req.get('Authorization')
+                    'Authorization': req.session && req.session.authorization
                 }),
                 json: payload,
                 forever: constants.FOREVER_ON,
@@ -600,7 +600,7 @@ FileManager.get = function(req) {
                         uri: api_server + ':' + parsedEndpoint.port + parsedEndpoint.path,
                         method: 'GET',
                         headers: _.extend({}, constants.HTTP_HEADERS.accept.collection, {
-                            'Authorization': req.get('Authorization')
+                            'Authorization': req.session && req.session.authorization
                         }),
                         forever: constants.FOREVER_ON,
                         rejectUnauthorized: false,
@@ -631,7 +631,7 @@ FileManager.job = function(req) {
             url: uri + url + '?deep',
             method: 'GET',
             headers: _.extend({}, constants.HTTP_HEADERS.accept.data, {
-                'Authorization': req.get('Authorization')
+                'Authorization': req.session && req.session.authorization
             }),
             forever: constants.FOREVER_ON,
             rejectUnauthorized: false,
index cc9cca7..b38abde 100644 (file)
@@ -6,7 +6,7 @@ var constants = require('../../../framework/core/api_utils/constants.js');
 var fs = require('fs');
 var _ = require('lodash');
 
-PackageFileHandler = {};
+var PackageFileHandler = {};
 
 function deleteFile(filename) {
        setTimeout(function() {
@@ -18,7 +18,7 @@ function checkStatus(req, transactionId, isUpdate) {
        var upload_server = req.query['upload_server'];
        var headers = _.extend({},
         {
-            'Authorization': req.get('Authorization')
+            'Authorization': req.session && req.session.authorization
         }
     );
     var type = isUpdate ? 'update' : 'upload';
index 99fb1d7..5b2a334 100644 (file)
@@ -18,7 +18,7 @@ return new Promise(function(resolve, reject) {
         _.extend(
             requestHeaders,
             id ? constants.HTTP_HEADERS.accept.data : constants.HTTP_HEADERS.accept.collection, {
-                'Authorization': req.get('Authorization')
+                'Authorization': req.session && req.session.authorization
             }
         );
 
@@ -71,7 +71,7 @@ function updateAccount(req) {
         _.extend(requestHeaders,
             constants.HTTP_HEADERS.accept.data,
             constants.HTTP_HEADERS.content_type.data, {
-                'Authorization': req.get('Authorization')
+                'Authorization': req.session && req.session.authorization
             });
         request({
             url: url,
index 5d6e0ea..b02ae88 100644 (file)
@@ -33,7 +33,7 @@ crashDetails.get = function(req) {
     var requestHeaders = {};
     _.extend(requestHeaders,
       constants.HTTP_HEADERS.accept.data, {
-        'Authorization': req.get('Authorization')
+        'Authorization': req.session && req.session.authorization
       });
     request({
         url: utils.confdPort(api_server) + APIVersion +'/api/operational/crash?deep',
index 6fb0170..1ba038b 100644 (file)
@@ -55,7 +55,7 @@ RPC.executeNSServicePrimitive = function(req) {
         var headers = _.extend({},
             constants.HTTP_HEADERS.accept.data,
             constants.HTTP_HEADERS.content_type.data, {
-                'Authorization': req.get('Authorization')
+                'Authorization': req.session && req.session.authorization
             }
         );
         request({
@@ -88,7 +88,7 @@ RPC.getNSServicePrimitiveValues = function(req) {
         var headers = _.extend({},
             constants.HTTP_HEADERS.accept.data,
             constants.HTTP_HEADERS.content_type.data, {
-                'Authorization': req.get('Authorization')
+                'Authorization': req.session && req.session.authorization
             }
         );
         request({
@@ -136,7 +136,7 @@ RPC.refreshAccountConnectionStatus = function(req) {
     var headers = _.extend({},
         constants.HTTP_HEADERS.accept.data,
         constants.HTTP_HEADERS.content_type.data, {
-            'Authorization': req.get('Authorization')
+            'Authorization': req.session && req.session.authorization
         }
     );
     return new Promise(function(resolve, reject) {
@@ -174,7 +174,7 @@ Catalog.get = function(req) {
                 uri: utils.confdPort(api_server) + APIVersion + '/api/config/nsd-catalog/nsd?deep',
                 method: 'GET',
                 headers: _.extend({}, constants.HTTP_HEADERS.accept.collection, {
-                    'Authorization': req.get('Authorization')
+                    'Authorization': req.session && req.session.authorization
                 }),
                 forever: constants.FOREVER_ON,
                 rejectUnauthorized: false,
@@ -184,7 +184,7 @@ Catalog.get = function(req) {
                 uri: utils.confdPort(api_server) + APIVersion + '/api/config/vnfd-catalog/vnfd?deep',
                 method: 'GET',
                 headers: _.extend({}, constants.HTTP_HEADERS.accept.collection, {
-                    'Authorization': req.get('Authorization')
+                    'Authorization': req.session && req.session.authorization
                 }),
                 forever: constants.FOREVER_ON,
                 rejectUnauthorized: false,
@@ -194,7 +194,7 @@ Catalog.get = function(req) {
                 uri: utils.confdPort(api_server) + APIVersion + '/api/operational/ns-instance-opdata?deep',
                 method: 'GET',
                 headers: _.extend({}, constants.HTTP_HEADERS.accept.data, {
-                    'Authorization': req.get('Authorization')
+                    'Authorization': req.session && req.session.authorization
                 }),
                 forever: constants.FOREVER_ON,
                 rejectUnauthorized: false,
@@ -207,7 +207,7 @@ Catalog.get = function(req) {
             //   headers: _.extend({},
             //     constants.HTTP_HEADERS.accept.collection,
             //     {
-            //       'Authorization': req.get('Authorization')
+            //       'Authorization': req.session && req.session.authorization
             //     }),
             //   forever: constants.FOREVER_ON,
             // rejectUnauthorized: false,
@@ -318,7 +318,7 @@ Catalog.delete = function(req) {
             uri: utils.confdPort(api_server) + APIVersion + '/api/config/' + catalogType + '-catalog/' + catalogType + '/' + id,
             method: 'DELETE',
             headers: _.extend({}, constants.HTTP_HEADERS.accept.data, {
-                'Authorization': req.get('Authorization')
+                'Authorization': req.session && req.session.authorization
             }),
             forever: constants.FOREVER_ON,
             rejectUnauthorized: false,
@@ -334,7 +334,7 @@ Catalog.delete = function(req) {
 Catalog.getVNFD = function(req) {
     var api_server = req.query['api_server'];
     var vnfdID = req.body.data;
-    var authorization = req.get('Authorization');
+    var authorization = req.session && req.session.authorization;
     var VNFDs = [];
     if (typeof(vnfdID) == "object" && vnfdID.constructor.name == "Array") {
         vnfdID.map(function(id) {
@@ -399,7 +399,7 @@ Catalog.create = function(req) {
     return new Promise(function(resolve, reject) {
         var requestHeaders = {};
         _.extend(requestHeaders, constants.HTTP_HEADERS.accept.data, constants.HTTP_HEADERS.content_type.data, {
-            'Authorization': req.get('Authorization')
+            'Authorization': req.session && req.session.authorization
         });
         request({
             uri: utils.confdPort(api_server) + APIVersion + '/api/config/' + catalogType + '-catalog',
@@ -429,7 +429,7 @@ Catalog.update = function(req) {
     return new Promise(function(resolve, reject) {
         var requestHeaders = {};
         _.extend(requestHeaders, constants.HTTP_HEADERS.accept.data, constants.HTTP_HEADERS.content_type.data, {
-            'Authorization': req.get('Authorization')
+            'Authorization': req.session && req.session.authorization
         });
         request({
             uri: utils.confdPort(api_server) + APIVersion + '/api/config/' + catalogType + '-catalog' + '/' + catalogType + '/' + id,
@@ -513,7 +513,7 @@ NSR.get = function(req) {
             uri: utils.confdPort(api_server) + APIVersion + '/api/config/nsd-catalog/nsd?deep',
             method: 'GET',
             headers: _.extend({}, constants.HTTP_HEADERS.accept.collection, {
-                'Authorization': req.get('Authorization')
+                'Authorization': req.session && req.session.authorization
             }),
             forever: constants.FOREVER_ON,
             rejectUnauthorized: false,
@@ -536,7 +536,7 @@ NSR.get = function(req) {
             uri: utils.confdPort(api_server) + APIVersion + '/api/operational/ns-instance-config/nsr' + (id ? '/' + id : '') + '?deep',
             method: 'GET',
             headers: _.extend({}, id ? constants.HTTP_HEADERS.accept.data : constants.HTTP_HEADERS.accept.collection, {
-                'Authorization': req.get('Authorization')
+                'Authorization': req.session && req.session.authorization
             }),
             forever: constants.FOREVER_ON,
             rejectUnauthorized: false,
@@ -560,7 +560,7 @@ NSR.get = function(req) {
             uri: utils.confdPort(api_server) + APIVersion + '/api/operational/ns-instance-opdata/nsr' + (id ? '/' + id : '') + '?deep',
             method: 'GET',
             headers: _.extend({}, id ? constants.HTTP_HEADERS.accept.data : constants.HTTP_HEADERS.accept.collection, {
-                'Authorization': req.get('Authorization')
+                'Authorization': req.session && req.session.authorization
             }),
             forever: constants.FOREVER_ON,
             rejectUnauthorized: false,
@@ -860,7 +860,7 @@ NSR.create = function(req) {
     return new Promise(function(resolve, reject) {
         var requestHeaders = {};
         _.extend(requestHeaders, constants.HTTP_HEADERS.accept.data, constants.HTTP_HEADERS.content_type.data, {
-            'Authorization': req.get('Authorization')
+            'Authorization': req.session && req.session.authorization
         });
         request({
             uri: utils.confdPort(api_server) + APIVersion + '/api/config/ns-instance-config',
@@ -904,7 +904,7 @@ NSR.delete = function(req) {
     return new Promise(function(resolve, reject) {
         var requestHeaders = {};
         _.extend(requestHeaders, constants.HTTP_HEADERS.accept.data, {
-            'Authorization': req.get('Authorization')
+            'Authorization': req.session && req.session.authorization
         });
         request({
             uri: utils.confdPort(api_server) + APIVersion + '/api/config/ns-instance-config/nsr/' + id,
@@ -1000,7 +1000,7 @@ NSR.setStatus = function(req) {
         }
         var requestHeaders = {};
         _.extend(requestHeaders, constants.HTTP_HEADERS.accept.data, constants.HTTP_HEADERS.content_type.data, {
-            'Authorization': req.get('Authorization')
+            'Authorization': req.session && req.session.authorization
         });
         request({
             uri: utils.confdPort(api_server) + APIVersion + '/api/config/ns-instance-config/nsr/' + id + '/admin-status/',
@@ -1053,7 +1053,7 @@ NSR.createScalingGroupInstance = function(req) {
             constants.HTTP_HEADERS.accept.data,
             constants.HTTP_HEADERS.content_type.data,
             {
-                'Authorization': req.get('Authorization')
+                'Authorization': req.session && req.session.authorization
             }
         );
 
@@ -1102,7 +1102,7 @@ NSR.deleteScalingGroupInstance = function(req) {
             constants.HTTP_HEADERS.accept.data,
             constants.HTTP_HEADERS.content_type.data,
             {
-                'Authorization': req.get('Authorization')
+                'Authorization': req.session && req.session.authorization
             }
         );
 
@@ -1146,7 +1146,7 @@ NSR.nsd.vld.get = function(req) {
         _.extend(requestHeaders,
             vld_id ? constants.HTTP_HEADERS.accept.data : constants.HTTP_HEADERS.accept.collection,
             {
-                'Authorization': req.get('Authorization')
+                'Authorization': req.session && req.session.authorization
             }
         );
 
@@ -1191,7 +1191,7 @@ NSR.nsd.vld.create = function(req) {
     return new Promise(function(resolve, reject) {
         var requestHeaders = {};
         _.extend(requestHeaders, constants.HTTP_HEADERS.accept.data, constants.HTTP_HEADERS.content_type.data, {
-            'Authorization': req.get('Authorization')
+            'Authorization': req.session && req.session.authorization
         });
         request({
             uri: utils.confdPort(api_server) + '/api/config/ns-instance-config/nsr/' + nsr_id + '/nsd/vld' + (vld_id ? '/' + vld_id : ''),
@@ -1233,7 +1233,7 @@ NSR.nsd.vld.delete = function(req) {
         _.extend(requestHeaders,
             constants.HTTP_HEADERS.accept.data,
             {
-                'Authorization': req.get('Authorization')
+                'Authorization': req.session && req.session.authorization
             }
         );
 
@@ -1260,7 +1260,7 @@ VNFR.get = function(req) {
     var uri = utils.confdPort(api_server);
     uri += APIVersion + '/api/operational/vnfr-catalog/vnfr' + (id ? '/' + id : '') + '?deep';
     var headers = _.extend({}, id ? constants.HTTP_HEADERS.accept.data : constants.HTTP_HEADERS.accept.collection, {
-        'Authorization': req.get('Authorization')
+        'Authorization': req.session && req.session.authorization
     });
     return new Promise(function(resolve, reject) {
         request({
@@ -1335,7 +1335,7 @@ VNFR.getByNSR = function(req) {
     delete reqClone.params.id;
     uri += APIVersion + '/api/operational/ns-instance-opdata/nsr/' + id + '?deep';
     var headers = _.extend({}, id ? constants.HTTP_HEADERS.accept.data : constants.HTTP_HEADERS.accept.collection, {
-        'Authorization': req.get('Authorization')
+        'Authorization': req.session && req.session.authorization
     });
     return new Promise(function(resolve, reject) {
         if (VNFR.cachedNSR[id]) {
@@ -1382,7 +1382,7 @@ VLR.get = function(req) {
     var uri = utils.confdPort(api_server);
     uri += APIVersion + '/api/operational/vlr-catalog/vlr' + (id ? '/' + id : '') + '?deep';
     var headers = _.extend({}, id ? constants.HTTP_HEADERS.accept.data : constants.HTTP_HEADERS.accept.collection, {
-        'Authorization': req.get('Authorization')
+        'Authorization': req.session && req.session.authorization
     });
     return new Promise(function(resolve, reject) {
         request({
@@ -1413,7 +1413,7 @@ RIFT.api = function(req) {
             url: uri + url + '?deep',
             method: 'GET',
             headers: _.extend({}, constants.HTTP_HEADERS.accept.data, {
-                'Authorization': req.get('Authorization')
+                'Authorization': req.session && req.session.authorization
             }),
             forever: constants.FOREVER_ON,
             rejectUnauthorized: false,
@@ -1442,7 +1442,7 @@ ComputeTopology.get = function(req) {
                 method: 'GET',
                 headers: _.extend({},
                     constants.HTTP_HEADERS.accept.data, {
-                        'Authorization': req.get('Authorization')
+                        'Authorization': req.session && req.session.authorization
                     }),
                 forever: constants.FOREVER_ON,
                 rejectUnauthorized: false,
@@ -1490,7 +1490,7 @@ ComputeTopology.get = function(req) {
                                 uri: utils.confdPort(api_server) + APIVersion + '/api/operational/vnfr-catalog/vnfr/' + vnfrId + '?deep',
                                 method: 'GET',
                                 headers: _.extend({}, constants.HTTP_HEADERS.accept.data, {
-                                    'Authorization': req.get('Authorization')
+                                    'Authorization': req.session && req.session.authorization
                                 }),
                                 forever: constants.FOREVER_ON,
                                 rejectUnauthorized: false,
@@ -1581,7 +1581,7 @@ NetworkTopology.get = function(req) {
     var uri = utils.confdPort(api_server);
     uri += APIVersion + '/api/operational/network?deep';
     var headers = _.extend({}, constants.HTTP_HEADERS.accept.data, {
-        'Authorization': req.get('Authorization')
+        'Authorization': req.session && req.session.authorization
     });
     return new Promise(function(resolve, reject) {
         request({
@@ -1612,7 +1612,7 @@ VDUR.get = function(req) {
     var uri = utils.confdPort(api_server);
     uri += APIVersion + '/api/operational/vnfr-catalog/vnfr/' + vnfrID + '/vdur/' + vdurID + '?deep';
     var headers = _.extend({}, constants.HTTP_HEADERS.accept.data, {
-        'Authorization': req.get('Authorization')
+        'Authorization': req.session && req.session.authorization
     });
     return new Promise(function(resolve, reject) {
         request({
@@ -1639,7 +1639,7 @@ VDUR.consoleUrl.get = function(req) {
     var uri = utils.confdPort(api_server);
     uri += APIVersion + '/api/operational/vnfr-console/vnfr/' + vnfrID + '/vdur/' + vdurID + '/console-url' + '?deep';
     var headers = _.extend({}, constants.HTTP_HEADERS.accept.data, {
-        'Authorization': req.get('Authorization')
+        'Authorization': req.session && req.session.authorization
     });
     return new Promise(function(resolve, reject) {
         request({
@@ -1666,7 +1666,7 @@ CloudAccount.get = function(req) {
     var uri = utils.confdPort(api_server);
     uri += APIVersion + '/api/operational/cloud/account?deep';
     var headers = _.extend({}, constants.HTTP_HEADERS.accept.collection, {
-        'Authorization': req.get('Authorization')
+        'Authorization': req.session && req.session.authorization
     });
     return new Promise(function(resolve, reject) {
         request({
@@ -1703,7 +1703,7 @@ ConfigAgentAccount.get = function(req) {
             var requestHeaders = {};
             _.extend(requestHeaders,
                 constants.HTTP_HEADERS.accept.collection, {
-                    'Authorization': req.get('Authorization')
+                    'Authorization': req.session && req.session.authorization
                 });
 
             request({
@@ -1743,7 +1743,7 @@ ConfigAgentAccount.get = function(req) {
             var requestHeaders = {};
             _.extend(requestHeaders,
                 constants.HTTP_HEADERS.accept.data, {
-                    'Authorization': req.get('Authorization')
+                    'Authorization': req.session && req.session.authorization
                 });
 
             request({
@@ -1796,7 +1796,7 @@ ConfigAgentAccount.create = function(req) {
         _.extend(requestHeaders,
             constants.HTTP_HEADERS.accept.data,
             constants.HTTP_HEADERS.content_type.data, {
-                'Authorization': req.get('Authorization')
+                'Authorization': req.session && req.session.authorization
             });
 
         request({
@@ -1835,7 +1835,7 @@ ConfigAgentAccount.update = function(req) {
         _.extend(requestHeaders,
             constants.HTTP_HEADERS.accept.data,
             constants.HTTP_HEADERS.content_type.data, {
-                'Authorization': req.get('Authorization')
+                'Authorization': req.session && req.session.authorization
             });
 
         request({
@@ -1877,7 +1877,7 @@ ConfigAgentAccount.delete = function(req) {
         var requestHeaders = {};
         _.extend(requestHeaders,
             constants.HTTP_HEADERS.accept.data, {
-                'Authorization': req.get('Authorization')
+                'Authorization': req.session && req.session.authorization
             });
         request({
             url: utils.confdPort(api_server) + APIVersion + '/api/config/config-agent/account/' + id,
@@ -1903,7 +1903,7 @@ DataCenters.get = function(req) {
         var requestHeaders = {};
         _.extend(requestHeaders,
             constants.HTTP_HEADERS.accept.data, {
-                'Authorization': req.get('Authorization')
+                'Authorization': req.session && req.session.authorization
             });
         request({
             url: utils.confdPort(api_server) + APIVersion + '/api/operational/datacenters?deep',
@@ -1944,7 +1944,7 @@ SSHkey.get  = function(req) {
         var requestHeaders = {};
         _.extend(requestHeaders,
             constants.HTTP_HEADERS.accept.data, {
-                'Authorization': req.get('Authorization')
+                'Authorization': req.session && req.session.authorization
             });
         request({
             url: utils.confdPort(api_server) + APIVersion + '/api/config/key-pair?deep',
@@ -1984,7 +1984,7 @@ SSHkey.delete = function(req) {
             uri: utils.confdPort(api_server) + APIVersion + '/api/config/key-pair/' + id,
             method: 'DELETE',
             headers: _.extend({}, constants.HTTP_HEADERS.accept.data, {
-                'Authorization': req.get('Authorization')
+                'Authorization': req.session && req.session.authorization
             }),
             forever: constants.FOREVER_ON,
             rejectUnauthorized: false,
@@ -2005,7 +2005,7 @@ SSHkey.post = function(req) {
             uri: utils.confdPort(api_server) + APIVersion + '/api/config/key-pair/',
             method: 'POST',
             headers: _.extend({}, constants.HTTP_HEADERS.accept.data, {
-                'Authorization': req.get('Authorization')
+                'Authorization': req.session && req.session.authorization
             }),
             json: data,
             forever: constants.FOREVER_ON,
@@ -2028,7 +2028,7 @@ SSHkey.put = function(req) {
             uri: utils.confdPort(api_server) + APIVersion + '/api/config/key-pair/',
             method: 'PUT',
             headers: _.extend({}, constants.HTTP_HEADERS.accept.data, {
-                'Authorization': req.get('Authorization')
+                'Authorization': req.session && req.session.authorization
             }),
             json: data,
             forever: constants.FOREVER_ON,
index 06c27d8..08103d8 100644 (file)
@@ -43,7 +43,7 @@ var Test = {};
 function buildGetRequestOptions(req, endpoint) {
   var headers = _.extend({},
     constants.HTTP_HEADERS.accept.data, {
-    'Authorization': req.get('Authorization')
+    'Authorization': req.session && req.session.authorization
   });
   var api_server = req.query["api_server"];
   var requestOptions = {
@@ -60,7 +60,7 @@ function buildPutRequestOptions(req, endpoint, jsonData) {
   var headers = _.extend({},
     constants.HTTP_HEADERS.accept.data,
     constants.HTTP_HEADERS.content_type.data, {
-    'Authorization': req.get('Authorization')
+    'Authorization': req.session && req.session.authorization
   });
   var api_server = req.query["api_server"];
   var requestOptions = {
@@ -79,7 +79,7 @@ function buildDeleteRequestOptions(req, endpoint) {
   var headers = _.extend({},
     constants.HTTP_HEADERS.accept.data,
     constants.HTTP_HEADERS.content_type.data, {
-    'Authorization': req.get('Authorization')
+    'Authorization': req.session && req.session.authorization
   });
   var api_server = req.query["api_server"];
   var requestOptions = {
@@ -447,7 +447,7 @@ SysLogViewer.get = function(req) {
       headers: _.extend({},
         constants.HTTP_HEADERS.accept.data,
         {
-          'Authorization': req.get('Authorization')
+          'Authorization': req.session && req.session.authorization
         }),
       forever: foreverOn,
       rejectUnauthorized: false
index 2e2b8dc..301b1eb 100644 (file)
@@ -40,7 +40,8 @@ Support.severities = function() {
  * Class to convert RESTConf data to logging plugin
  */
 
-
+var LoggingConfigDecoder = {};
+var LoggingConfigEncoder = {};
 
 LoggingConfigDecoder = function(debugMode) {
   this.debugMode = debugMode || false
index 3fd904d..4c5adcf 100644 (file)
@@ -105,6 +105,9 @@ if (cluster.isMaster && clusteredLaunch) {
 
        var app = express();
 
+       app.set('views', __dirname + '/framework/core/views');
+       app.engine('html', require('ejs').renderFile);
+
        app.use(session({
          secret: 'ritio rocks',
          resave: true,
@@ -137,6 +140,7 @@ if (cluster.isMaster && clusteredLaunch) {
        var configurationAPI = require('./framework/core/modules/api/configuration');
        var userManagement_routes = require('./framework/core/modules/routes/userManagement');
        var projectManagement_routes = require('./framework/core/modules/routes/projectManagement');
+       var session_routes = require('./framework/core/modules/routes/sessions');
        /**
         * Processing when a plugin is added or modified
         * @param {string} plugin_name - Name of the plugin
@@ -158,6 +162,15 @@ if (cluster.isMaster && clusteredLaunch) {
 
        }
 
+       /**
+        * Serve jquery
+        */
+       app.use('/jquery', express.static('./node_modules/jquery/dist/jquery.min.js'));
+       /**
+        * Serve images
+        */
+       app.use('/img', express.static('./framework/style/img'));
+
        /**
         * Start listening on a port
         * @param {string} port - Port to listen on
@@ -222,6 +235,9 @@ if (cluster.isMaster && clusteredLaunch) {
                //Configure project management route(s)
                app.use(projectManagement_routes);
 
+               //Configure session route(s)
+               app.use(session_routes);
+
                // app.get('/testme', function(req, res) {
                //      res.sendFile(__dirname + '/index.html');
                // });