From 8d06f92bda77338e7772a912ef3cde474f2a06ed Mon Sep 17 00:00:00 2001 From: KIRAN KASHALKAR Date: Fri, 28 Oct 2016 04:28:32 +0000 Subject: [PATCH] Revert "RIFT-14989: Login fixes for Accounts and RO Config pages" This reverts commit b78fbe20fd7d976b3e15abb2387b4e329a5ea918. Signed-off-by: KIRAN KASHALKAR --- skyquake/framework/core/api_utils/utils.js | 34 +------------- .../core/modules/routes/configuration.js | 47 ++----------------- skyquake/framework/utils/utils.js | 21 ++------- skyquake/plugins/accounts/api/accounts.js | 8 +--- .../plugins/accounts/src/account/account.jsx | 3 +- .../accounts/src/account/accountSource.js | 1 - .../accounts/src/account/accountStore.js | 21 +++++++-- .../config/src/dashboard/configStore.js | 2 +- .../config/src/dashboard/dashboard.jsx | 1 + 9 files changed, 34 insertions(+), 104 deletions(-) diff --git a/skyquake/framework/core/api_utils/utils.js b/skyquake/framework/core/api_utils/utils.js index bd99fe1a9..163769a98 100644 --- a/skyquake/framework/core/api_utils/utils.js +++ b/skyquake/framework/core/api_utils/utils.js @@ -1,5 +1,5 @@ /* - * + * * Copyright 2016 RIFT.IO Inc * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -217,34 +217,6 @@ var passThroughConstructor = function(app) { }); } - -var testAuthentication = function(app) { - app.get('/check-auth', function(req, res) { - console.log('testing auth') - var api_server = req.query["api_server"]; - var uri = confdPort(api_server) + '/api/config/'; - new Promise(function(resolve, reject) { - request({ - uri: uri, - method: 'GET', - headers: _.extend({}, CONSTANTS.HTTP_HEADERS.accept[type], { - 'Authorization': req.get('Authorization'), - forever: CONSTANTS.FOREVER_ON, - rejectUnauthorized: false, - }) - }, function(error, response, body) { - if (validateResponse('Passthrough: ' + url, error, response, body, resolve, reject)) { - resolve(JSON.parse(response.body)) - }; - }); - }).then(function(data) { - res.send(data); - }, function(error) { - res.send({'error': error, uri: uri}) - });; - }) -} - module.exports = { /** * Ensure confd port is on api_server variable. @@ -261,7 +233,5 @@ module.exports = { sendSuccessResponse: sendSuccessResponse, - passThroughConstructor: passThroughConstructor, - - testAuthentication: testAuthentication + passThroughConstructor: passThroughConstructor }; diff --git a/skyquake/framework/core/modules/routes/configuration.js b/skyquake/framework/core/modules/routes/configuration.js index b789ff043..3a686f094 100644 --- a/skyquake/framework/core/modules/routes/configuration.js +++ b/skyquake/framework/core/modules/routes/configuration.js @@ -1,6 +1,6 @@ /* - * + * * Copyright 2016 RIFT.IO Inc * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,7 +18,7 @@ */ /** - * Node configuration routes module. + * Node configuration routes module. * Provides a RESTful API to provide configuration * details such as api_server. * @module framework/core/modules/routes/configuration @@ -30,9 +30,6 @@ var bodyParser = require('body-parser'); var configurationAPI = require('../api/configuration'); 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()); @@ -51,43 +48,9 @@ Router.put('/server-configuration', cors(), function(req, res) { Router.get('/server-configuration', cors(), function(req, res) { configurationAPI.get(req).then(function(data) { utils.sendSuccessResponse(data, res); - }, function(error) { - utils.sendErrorResponse(error, res); - }); -}); - -Router.get('/check-auth', function(req, res) { - console.log('testing auth') - var api_server = req.query["api_server"]; - var uri = utils.confdPort(api_server) + '/api/config/'; - - checkAuth(uri, req).then(function(data) { - utils.sendSuccessResponse(data, res); - }, function(error) { - utils.sendErrorResponse(error, res); - }); + }, function(error) { + utils.sendErrorResponse(error, res); + }); }); -function checkAuth(uri, req){ - return new Promise(function(resolve, reject) { - request({ - uri: uri, - method: 'GET', - headers: _.extend({}, { - 'Authorization': req.get('Authorization'), - forever: CONSTANTS.FOREVER_ON, - rejectUnauthorized: false, - }) - }, function(error, response, body) { - console.log(arguments) - if( response.statusCode == 401) { - reject({statusCode: 401, error: response.body}); - } else { - resolve({statusCode:200, data:response.body}) - } - }); - }); -} - - module.exports = Router; diff --git a/skyquake/framework/utils/utils.js b/skyquake/framework/utils/utils.js index 3d84f4b5c..d08fe5f83 100644 --- a/skyquake/framework/utils/utils.js +++ b/skyquake/framework/utils/utils.js @@ -1,5 +1,5 @@ /* - * + * * Copyright 2016 RIFT.IO Inc * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -20,7 +20,7 @@ var AuthActions = require('../widgets/login/loginAuthActions.js'); var $ = require('jquery'); var rw = require('utils/rw.js'); var API_SERVER = rw.getSearchParams(window.location).api_server; -var NODE_PORT = 8000; +var NODE_PORT = 3000; var SockJS = require('sockjs-client'); var Utils = {}; @@ -188,20 +188,9 @@ Utils.setAuthentication = function(username, password, cb) { var AuthBase64 = btoa(username + ":" + password); window.sessionStorage.setItem("auth", AuthBase64); self.detectInactivity(); - $.ajax({ - url: '//' + window.location.hostname + ':' + NODE_PORT + '/check-auth?api_server=' + API_SERVER, - type: 'GET', - beforeSend: Utils.addAuthorizationStub, - success: function(data) { - //console.log("LoggingSource.getLoggingConfig success call. data=", data); - if (cb) { - cb(); - }; - }, - error: function(data) { - Utils.clearAuthentication(); - } - }); + if (cb) { + cb(); + } } Utils.clearAuthentication = function(callback) { var self = this; diff --git a/skyquake/plugins/accounts/api/accounts.js b/skyquake/plugins/accounts/api/accounts.js index 83e841e62..1b51c7bfe 100644 --- a/skyquake/plugins/accounts/api/accounts.js +++ b/skyquake/plugins/accounts/api/accounts.js @@ -1,5 +1,5 @@ /* - * + * * Copyright 2016 RIFT.IO Inc * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -42,9 +42,7 @@ Accounts.get = function(req) { type: req.params.type }) }); - }, function(reason) { - reject(reason); - }) + }) } else { getAll(req, resolve, reject); } @@ -68,8 +66,6 @@ Accounts.get = function(req) { statusCode: 200, data: ReturnData }); - }, function(reason) { - reject(reason); }) } } diff --git a/skyquake/plugins/accounts/src/account/account.jsx b/skyquake/plugins/accounts/src/account/account.jsx index 6797cb3e5..c40e62737 100644 --- a/skyquake/plugins/accounts/src/account/account.jsx +++ b/skyquake/plugins/accounts/src/account/account.jsx @@ -1,5 +1,5 @@ /* - * + * * Copyright 2016 RIFT.IO Inc * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -47,7 +47,6 @@ class Account extends React.Component { } } componentWillUnmount() { - this.props.store.closeSocket(); this.props.store.unlisten(this.storeListener); } setUp(props){ diff --git a/skyquake/plugins/accounts/src/account/accountSource.js b/skyquake/plugins/accounts/src/account/accountSource.js index c0fd36b3d..45067247a 100644 --- a/skyquake/plugins/accounts/src/account/accountSource.js +++ b/skyquake/plugins/accounts/src/account/accountSource.js @@ -34,7 +34,6 @@ module.exports = function(Alt) { return new Promise(function(resolve, reject) { //If socket connection already exists, eat the request. if(state.socket) { - console.log('connection already exists') return resolve(false); } $.ajax({ diff --git a/skyquake/plugins/accounts/src/account/accountStore.js b/skyquake/plugins/accounts/src/account/accountStore.js index a9a6d1e65..002a9e10c 100644 --- a/skyquake/plugins/accounts/src/account/accountStore.js +++ b/skyquake/plugins/accounts/src/account/accountStore.js @@ -18,7 +18,7 @@ import AccountActions from './accountActions.js'; import AccountSource from './accountSource.js'; -var Utils = require('utils/utils.js'); + var rw = require('utils/rw.js'); var altImage = rw.getSearchParams(window.location).alt_image; @@ -252,6 +252,7 @@ export default class AccountStore { openAccountSocketSuccess = (connection) => { let self = this; let ws = window.multiplexer.channel(connection); + if (!connection) return; this.setState({ socket: ws.ws, @@ -260,9 +261,6 @@ export default class AccountStore { ws.onmessage = (socket) => { try { var data = JSON.parse(socket.data); - Utils.checkAuthentication(data.statusCode, function() { - self.closeSocket(); - }); let SdnOptions = [{ label: 'Select an SDN Account', value: false @@ -409,3 +407,18 @@ export default class AccountStore { } } + +/** + *Cloud + * + * {"name":"eng2","account-type":"openstack","openstack":{"key":"lmaultsb","secret":"mypasswd","auth_url":"http://engstack.eng.riftio.com:5000/v3/","tenant":"lmaultsb","mgmt-network":"private"}} +Name +Path + + +SDN + + + * + * + */ diff --git a/skyquake/plugins/config/src/dashboard/configStore.js b/skyquake/plugins/config/src/dashboard/configStore.js index 54f3568e6..c5ba696cd 100644 --- a/skyquake/plugins/config/src/dashboard/configStore.js +++ b/skyquake/plugins/config/src/dashboard/configStore.js @@ -52,7 +52,7 @@ let AccountMeta = { } } -export default class ConfigStore { +export default class AccountStore { constructor() { this.account = {}; this.accountType = 'openmano'; diff --git a/skyquake/plugins/config/src/dashboard/dashboard.jsx b/skyquake/plugins/config/src/dashboard/dashboard.jsx index 99bff0681..b8a743fc4 100644 --- a/skyquake/plugins/config/src/dashboard/dashboard.jsx +++ b/skyquake/plugins/config/src/dashboard/dashboard.jsx @@ -123,6 +123,7 @@ class ConfigDashboard extends React.Component { }
+
-- 2.25.1