Add session timeout in Policies page
This patchset will provide the option to configure the session timeout
for the WebUI. The functionality will provide the below timeout options
to configure.
1. 30 minutes
2. 1 hour
3. 2 hours
4. 4 hours
5. 8 hours
6. 1 Day
For the API, redfish is having the following resource.
URL - /redfish/v1/SessionService
Method
- GET (to get the configured timeout)
- PATCH (to configure the timeout value)
Property - { "SessionTimeout": 1800 }
When the user idles up until the configured session timeout, after that
any API call from this session will get 401 status and the web UI will
gets logged out.
Change-Id: Ic7c6b4817e560ca4ceb983dc5e2af51f3ae08cf5
Signed-off-by: Kirankumar Ballapalli <kirankumarb@ami.com>
diff --git a/src/locales/en-US.json b/src/locales/en-US.json
index d331993..ff98822 100644
--- a/src/locales/en-US.json
+++ b/src/locales/en-US.json
@@ -801,6 +801,7 @@
"errorSshEnabled": "Error enabling SSH security setting.",
"errorVtpmDisabled": "Error disabling VirtualTPM security setting.",
"errorVtpmEnabled": "Error enabling VirtualTPM security setting.",
+ "errorSessionTimeout": "Error configuring session timeout.",
"successIpmiDisabled": "Successfully disabled IPMI security setting.",
"successIpmiEnabled": "Successfully enabled IPMI security setting.",
"successRtadDisabled": "Successfully disabled RTAD security setting.",
@@ -808,10 +809,21 @@
"successSshDisabled": "Successfully disabled SSH security setting.",
"successSshEnabled": "Successfully enabled SSH security setting.",
"successVtpmDisabled": "Successfully disabled VirtualTPM security setting.",
- "successVtpmEnabled": "Successfully enabled VirtualTPM security setting."
+ "successVtpmEnabled": "Successfully enabled VirtualTPM security setting.",
+ "successSessionTimeout": "Successfully configured the session timeout."
+ },
+ "options": {
+ "30minutes": "30 Minutes",
+ "1hour": "1 Hour",
+ "2hours": "2 Hours",
+ "4hours": "4 Hours",
+ "8hours": "8 Hours",
+ "1day": "1 Day"
},
"vtpm": "VirtualTPM",
- "vtpmDescription": "Enabling vTPM makes a TPM available to the guest operating system."
+ "vtpmDescription": "Enabling vTPM makes a TPM available to the guest operating system.",
+ "webSessionTimeOut": "WEB Session Timeout",
+ "webSessionTimeOutDescription": "Change the Web session timeout in given options"
},
"pagePower": {
"description": "Set a power cap to keep power consumption at or below the specified value in watts",
diff --git a/src/locales/ru-RU.json b/src/locales/ru-RU.json
index 3ff0e6a..15e23a5 100644
--- a/src/locales/ru-RU.json
+++ b/src/locales/ru-RU.json
@@ -799,6 +799,7 @@
"errorSshEnabled": "Ошибка включения настроек безопасности SSH.",
"errorVtpmDisabled": "Ошибка отключения настроек безопасности VirtualTPM.",
"errorVtpmEnabled": "Ошибка включения настроек безопасности VirtualTPM.",
+ "errorSessionTimeout": "Ошибка настройки таймаута сессии.",
"successIpmiDisabled": "Успешное отключение настроек безопасности IPMI.",
"successIpmiEnabled": "Успешное включение настроек безопасности IPMI.",
"successRtadDisabled": "Успешное отключение настроек безопасности RTAD.",
@@ -806,10 +807,21 @@
"successSshDisabled": "Успешное отключение настроек безопасности SSH.",
"successSshEnabled": "Успешное включение настроек безопасности SSH.",
"successVtpmDisabled": "Успешное отключение настроек безопасности VirtualTPM.",
- "successVtpmEnabled": "Успешное включение настроек безопасности VirtualTPM."
+ "successVtpmEnabled": "Успешное включение настроек безопасности VirtualTPM.",
+ "successSessionTimeout": "Успешная настройка таймаута сессии."
+ },
+ "options": {
+ "30minutes": "30 минут",
+ "1hour": "1 час",
+ "2hours": "2 часа",
+ "4hours": "4 часа",
+ "8hours": "8 часов",
+ "1day": "1 день"
},
"vtpm": "VirtualTPM",
- "vtpmDescription": "Включение vTPM делает TPM доступным для гостевой операционной системы."
+ "vtpmDescription": "Включение vTPM делает TPM доступным для гостевой операционной системы.",
+ "webSessionTimeOut": "Таймаут интернет-сессии",
+ "webSessionTimeOutDescription": "Изменение таймаута интернет-сессии"
},
"pagePower": {
"description": "Задайте порог мощности, чтобы ограничить потребление питания не превышающее заданное значение в Ваттах",
diff --git a/src/store/modules/SecurityAndAccess/PoliciesStore.js b/src/store/modules/SecurityAndAccess/PoliciesStore.js
index 64bd336..e6bcfb9 100644
--- a/src/store/modules/SecurityAndAccess/PoliciesStore.js
+++ b/src/store/modules/SecurityAndAccess/PoliciesStore.js
@@ -8,12 +8,14 @@
ipmiProtocolEnabled: false,
rtadEnabled: 'Disabled',
vtpmEnabled: 'Disabled',
+ sessionTimeoutValue: null,
},
getters: {
sshProtocolEnabled: (state) => state.sshProtocolEnabled,
ipmiProtocolEnabled: (state) => state.ipmiProtocolEnabled,
rtadEnabled: (state) => state.rtadEnabled,
vtpmEnabled: (state) => state.vtpmEnabled,
+ getSessionTimeoutValue: (state) => state.sessionTimeoutValue,
},
mutations: {
setSshProtocolEnabled: (state, sshProtocolEnabled) =>
@@ -22,6 +24,9 @@
(state.ipmiProtocolEnabled = ipmiProtocolEnabled),
setRtadEnabled: (state, rtadEnabled) => (state.rtadEnabled = rtadEnabled),
setVtpmEnabled: (state, vtpmEnabled) => (state.vtpmEnabled = vtpmEnabled),
+ setSessionTimeoutValue(state, sessionTimeoutValue) {
+ state.sessionTimeoutValue = sessionTimeoutValue;
+ },
},
actions: {
async getNetworkProtocolStatus({ commit }) {
@@ -44,6 +49,15 @@
})
.catch((error) => console.log(error));
},
+ async getSessionTimeout({ commit }) {
+ return await api
+ .get('/redfish/v1/SessionService')
+ .then((response) => {
+ const sessionTimeoutValue = response.data.SessionTimeout;
+ commit('setSessionTimeoutValue', sessionTimeoutValue);
+ })
+ .catch((error) => console.log(error));
+ },
async saveIpmiProtocolState({ commit }, protocolEnabled) {
commit('setIpmiProtocolEnabled', protocolEnabled);
const ipmi = {
@@ -144,6 +158,21 @@
}
});
},
+ async saveSessionTimeoutValue({ dispatch }, sessionTimeoutNewValue) {
+ const sessionValue = {
+ SessionTimeout: sessionTimeoutNewValue,
+ };
+ return await api
+ .patch('/redfish/v1/SessionService', sessionValue)
+ .then(() => dispatch('getSessionTimeout'))
+ .then(() => {
+ return i18n.t('pagePolicies.toast.successSessionTimeout');
+ })
+ .catch((error) => {
+ console.log(error);
+ throw new Error(i18n.t('pagePolicies.toast.errorSessionTimeout'));
+ });
+ },
},
};
diff --git a/src/views/SecurityAndAccess/Policies/Policies.vue b/src/views/SecurityAndAccess/Policies/Policies.vue
index 1dc197c..3ebfee4 100644
--- a/src/views/SecurityAndAccess/Policies/Policies.vue
+++ b/src/views/SecurityAndAccess/Policies/Policies.vue
@@ -103,6 +103,30 @@
</b-form-checkbox>
</b-col>
</b-row>
+ <b-row class="setting-section">
+ <b-col class="d-flex align-items-center justify-content-between">
+ <dl class="mt-3 mr-3 w-75">
+ <dt>{{ $t('pagePolicies.webSessionTimeOut') }}</dt>
+ <dd>
+ {{ $t('pagePolicies.webSessionTimeOutDescription') }}
+ </dd>
+ </dl>
+ </b-col>
+ <b-col lg="3" class="session-timeout">
+ <b-form-select
+ id="session-timeout-options"
+ v-model="sessionTimeoutState"
+ :options="sessionTimeOutOptions"
+ @change="saveSessionTimeoutValue"
+ >
+ <template #first>
+ <b-form-select-option :value="null" disabled>
+ {{ $t('global.form.selectAnOption') }}
+ </b-form-select-option>
+ </template>
+ </b-form-select>
+ </b-col>
+ </b-row>
</b-col>
</b-row>
</b-container>
@@ -126,6 +150,14 @@
return {
modifySSHPolicyDisabled:
process.env.VUE_APP_MODIFY_SSH_POLICY_DISABLED === 'true',
+ sessionTimeOutOptions: [
+ { value: 1800, text: this.$t('pagePolicies.options.30minutes') },
+ { value: 3600, text: this.$t('pagePolicies.options.1hour') },
+ { value: 7200, text: this.$t('pagePolicies.options.2hours') },
+ { value: 14400, text: this.$t('pagePolicies.options.4hours') },
+ { value: 28800, text: this.$t('pagePolicies.options.8hours') },
+ { value: 86400, text: this.$t('pagePolicies.options.1day') },
+ ],
};
},
computed: {
@@ -169,12 +201,21 @@
return newValue;
},
},
+ sessionTimeoutState: {
+ get() {
+ return this.$store.getters['policies/getSessionTimeoutValue'];
+ },
+ set(newValue) {
+ return newValue;
+ },
+ },
},
created() {
this.startLoader();
Promise.all([
this.$store.dispatch('policies/getBiosStatus'),
this.$store.dispatch('policies/getNetworkProtocolStatus'),
+ this.$store.dispatch('policies/getSessionTimeout'),
]).finally(() => this.endLoader());
},
methods: {
@@ -202,6 +243,12 @@
.then((message) => this.successToast(message))
.catch(({ message }) => this.errorToast(message));
},
+ saveSessionTimeoutValue(sessionTimeoutState) {
+ this.$store
+ .dispatch('policies/saveSessionTimeoutValue', sessionTimeoutState)
+ .then((message) => this.successToast(message))
+ .catch(({ message }) => this.errorToast(message));
+ },
},
};
</script>
@@ -210,4 +257,7 @@
.setting-section {
border-bottom: 1px solid gray('300');
}
+.session-timeout {
+ align-self: center;
+}
</style>