From 8f030bac11637fcd0a005907b558d7accbff68bd Mon Sep 17 00:00:00 2001 From: Dixsie Wolmers Date: Mon, 7 Dec 2020 13:12:53 -0600 Subject: Add security settings page Adds ability to enable/disable: - SSH protocol - IPMI protocol Signed-off-by: Dixsie Wolmers Change-Id: I2430a46343dd8756ef75fcc3cb068df8d51dd415 --- src/store/index.js | 2 + .../modules/Configuration/SecuritySettingsStore.js | 95 ++++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 src/store/modules/Configuration/SecuritySettingsStore.js (limited to 'src/store') diff --git a/src/store/index.js b/src/store/index.js index e6153b1b..b4a77d82 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -21,6 +21,7 @@ import FanStore from './modules/Health/FanStore'; import ChassisStore from './modules/Health/ChassisStore'; import BmcStore from './modules/Health/BmcStore'; import ProcessorStore from './modules/Health/ProcessorStore'; +import SecuritySettingsStore from './modules/Configuration/SecuritySettingsStore'; import WebSocketPlugin from './plugins/WebSocketPlugin'; import DateTimeStore from './modules/Configuration/DateTimeSettingsStore'; @@ -55,6 +56,7 @@ export default new Vuex.Store({ bmc: BmcStore, processors: ProcessorStore, virtualMedia: VirtualMediaStore, + securitySettings: SecuritySettingsStore, }, plugins: [WebSocketPlugin], }); diff --git a/src/store/modules/Configuration/SecuritySettingsStore.js b/src/store/modules/Configuration/SecuritySettingsStore.js new file mode 100644 index 00000000..5a885425 --- /dev/null +++ b/src/store/modules/Configuration/SecuritySettingsStore.js @@ -0,0 +1,95 @@ +import api from '@/store/api'; +import i18n from '@/i18n'; + +const SecuritySettingsStore = { + namespaced: true, + state: { + sshProtocolEnabled: false, + ipmiProtocolEnabled: false, + }, + getters: { + sshProtocolEnabled: (state) => state.sshProtocolEnabled, + ipmiProtocolEnabled: (state) => state.ipmiProtocolEnabled, + }, + mutations: { + setSshProtocolEnabled: (state, sshProtocolEnabled) => + (state.sshProtocolEnabled = sshProtocolEnabled), + setIpmiProtocolEnabled: (state, ipmiProtocolEnabled) => + (state.ipmiProtocolEnabled = ipmiProtocolEnabled), + }, + actions: { + async getNetworkProtocolStatus({ commit }) { + return await api + .get('/redfish/v1/Managers/bmc/NetworkProtocol') + .then((response) => { + const sshProtocol = response.data.SSH.ProtocolEnabled; + const ipmiProtocol = response.data.IPMI.ProtocolEnabled; + commit('setSshProtocolEnabled', sshProtocol); + commit('setIpmiProtocolEnabled', ipmiProtocol); + }) + .catch((error) => console.log(error)); + }, + async saveIpmiProtocolState({ commit }, protocolEnabled) { + commit('setIpmiProtocolEnabled', protocolEnabled); + const ipmi = { + IPMI: { + ProtocolEnabled: protocolEnabled, + }, + }; + return await api + .patch('/redfish/v1/Managers/bmc/NetworkProtocol', ipmi) + .then(() => { + if (protocolEnabled) { + return i18n.t('pageSecuritySettings.toast.successIpmiEnabled'); + } else { + return i18n.t('pageSecuritySettings.toast.successIpmiDisabled'); + } + }) + .catch((error) => { + console.log(error); + commit('setIpmiProtocolEnabled', !protocolEnabled); + if (protocolEnabled) { + throw new Error( + i18n.t('pageSecuritySettings.toast.errorIpmiEnabled') + ); + } else { + throw new Error( + i18n.t('pageSecuritySettings.toast.errorIpmiDisabled') + ); + } + }); + }, + async saveSshProtocolState({ commit }, protocolEnabled) { + commit('setSshProtocolEnabled', protocolEnabled); + const ssh = { + SSH: { + ProtocolEnabled: protocolEnabled, + }, + }; + return await api + .patch('/redfish/v1/Managers/bmc/NetworkProtocol', ssh) + .then(() => { + if (protocolEnabled) { + return i18n.t('pageSecuritySettings.toast.successSshEnabled'); + } else { + return i18n.t('pageSecuritySettings.toast.successSshDisabled'); + } + }) + .catch((error) => { + console.log(error); + commit('setSshProtocolEnabled', !protocolEnabled); + if (protocolEnabled) { + throw new Error( + i18n.t('pageSecuritySettings.toast.errorSshEnabled') + ); + } else { + throw new Error( + i18n.t('pageSecuritySettings.toast.errorSshDisabled') + ); + } + }); + }, + }, +}; + +export default SecuritySettingsStore; -- cgit v1.2.3