xref: /openbmc/webui-vue/src/views/SecurityAndAccess/Policies/Policies.vue (revision 24b377db47a05f742b1f3db77606f6bae845f637)
1b440616cSSandeepa Singh<template>
2b440616cSSandeepa Singh  <b-container fluid="xl">
3b440616cSSandeepa Singh    <page-title />
4b440616cSSandeepa Singh    <b-row>
5b440616cSSandeepa Singh      <b-col md="8">
6e020d581SMichalX Szopinski        <b-row v-if="!modifySSHPolicyDisabled" class="setting-section">
7b440616cSSandeepa Singh          <b-col class="d-flex align-items-center justify-content-between">
8b440616cSSandeepa Singh            <dl class="mr-3 w-75">
9b440616cSSandeepa Singh              <dt>{{ $t('pagePolicies.ssh') }}</dt>
10b440616cSSandeepa Singh              <dd>
11b440616cSSandeepa Singh                {{ $t('pagePolicies.sshDescription') }}
12b440616cSSandeepa Singh              </dd>
13b440616cSSandeepa Singh            </dl>
14b440616cSSandeepa Singh            <b-form-checkbox
15b440616cSSandeepa Singh              id="sshSwitch"
16b440616cSSandeepa Singh              v-model="sshProtocolState"
17b440616cSSandeepa Singh              data-test-id="policies-toggle-bmcShell"
18b440616cSSandeepa Singh              switch
19b440616cSSandeepa Singh              @change="changeSshProtocolState"
20b440616cSSandeepa Singh            >
21b440616cSSandeepa Singh              <span class="sr-only">
22b440616cSSandeepa Singh                {{ $t('pagePolicies.ssh') }}
23b440616cSSandeepa Singh              </span>
24b440616cSSandeepa Singh              <span v-if="sshProtocolState">
25b440616cSSandeepa Singh                {{ $t('global.status.enabled') }}
26b440616cSSandeepa Singh              </span>
27b440616cSSandeepa Singh              <span v-else>{{ $t('global.status.disabled') }}</span>
28b440616cSSandeepa Singh            </b-form-checkbox>
29b440616cSSandeepa Singh          </b-col>
30b440616cSSandeepa Singh        </b-row>
31b440616cSSandeepa Singh        <b-row class="setting-section">
32b440616cSSandeepa Singh          <b-col class="d-flex align-items-center justify-content-between">
33b440616cSSandeepa Singh            <dl class="mt-3 mr-3 w-75">
34b440616cSSandeepa Singh              <dt>{{ $t('pagePolicies.ipmi') }}</dt>
35b440616cSSandeepa Singh              <dd>
36b440616cSSandeepa Singh                {{ $t('pagePolicies.ipmiDescription') }}
37b440616cSSandeepa Singh              </dd>
38b440616cSSandeepa Singh            </dl>
39b440616cSSandeepa Singh            <b-form-checkbox
40b440616cSSandeepa Singh              id="ipmiSwitch"
41b440616cSSandeepa Singh              v-model="ipmiProtocolState"
42b440616cSSandeepa Singh              data-test-id="polices-toggle-networkIpmi"
43b440616cSSandeepa Singh              switch
44b440616cSSandeepa Singh              @change="changeIpmiProtocolState"
45b440616cSSandeepa Singh            >
46b440616cSSandeepa Singh              <span class="sr-only">
47b440616cSSandeepa Singh                {{ $t('pagePolicies.ipmi') }}
48b440616cSSandeepa Singh              </span>
49b440616cSSandeepa Singh              <span v-if="ipmiProtocolState">
50b440616cSSandeepa Singh                {{ $t('global.status.enabled') }}
51b440616cSSandeepa Singh              </span>
52b440616cSSandeepa Singh              <span v-else>{{ $t('global.status.disabled') }}</span>
53b440616cSSandeepa Singh            </b-form-checkbox>
54b440616cSSandeepa Singh          </b-col>
55b440616cSSandeepa Singh        </b-row>
56aee27141SNikhil Ashoka        <b-row class="setting-section">
57aee27141SNikhil Ashoka          <b-col class="d-flex align-items-center justify-content-between">
58aee27141SNikhil Ashoka            <dl class="mt-3 mr-3 w-75">
59aee27141SNikhil Ashoka              <dt>{{ $t('pagePolicies.vtpm') }}</dt>
60aee27141SNikhil Ashoka              <dd>
61aee27141SNikhil Ashoka                {{ $t('pagePolicies.vtpmDescription') }}
62aee27141SNikhil Ashoka              </dd>
63aee27141SNikhil Ashoka            </dl>
64aee27141SNikhil Ashoka            <b-form-checkbox
65aee27141SNikhil Ashoka              id="vtpmSwitch"
66aee27141SNikhil Ashoka              v-model="vtpmState"
67aee27141SNikhil Ashoka              data-test-id="policies-toggle-vtpm"
68aee27141SNikhil Ashoka              switch
69aee27141SNikhil Ashoka              @change="changeVtpmState"
70aee27141SNikhil Ashoka            >
71aee27141SNikhil Ashoka              <span class="sr-only">
72aee27141SNikhil Ashoka                {{ $t('pagePolicies.vtpm') }}
73aee27141SNikhil Ashoka              </span>
74aee27141SNikhil Ashoka              <span v-if="vtpmState">
75aee27141SNikhil Ashoka                {{ $t('global.status.enabled') }}
76aee27141SNikhil Ashoka              </span>
77aee27141SNikhil Ashoka              <span v-else>{{ $t('global.status.disabled') }}</span>
78aee27141SNikhil Ashoka            </b-form-checkbox>
79aee27141SNikhil Ashoka          </b-col>
80aee27141SNikhil Ashoka        </b-row>
81aee27141SNikhil Ashoka        <b-row class="setting-section">
82aee27141SNikhil Ashoka          <b-col class="d-flex align-items-center justify-content-between">
83aee27141SNikhil Ashoka            <dl class="mt-3 mr-3 w-75">
84aee27141SNikhil Ashoka              <dt>{{ $t('pagePolicies.rtad') }}</dt>
85aee27141SNikhil Ashoka              <dd>
86aee27141SNikhil Ashoka                {{ $t('pagePolicies.rtadDescription') }}
87aee27141SNikhil Ashoka              </dd>
88aee27141SNikhil Ashoka            </dl>
89aee27141SNikhil Ashoka            <b-form-checkbox
90aee27141SNikhil Ashoka              id="rtadSwitch"
91aee27141SNikhil Ashoka              v-model="rtadState"
92aee27141SNikhil Ashoka              data-test-id="policies-toggle-rtad"
93aee27141SNikhil Ashoka              switch
94aee27141SNikhil Ashoka              @change="changeRtadState"
95aee27141SNikhil Ashoka            >
96aee27141SNikhil Ashoka              <span class="sr-only">
97aee27141SNikhil Ashoka                {{ $t('pagePolicies.rtad') }}
98aee27141SNikhil Ashoka              </span>
99aee27141SNikhil Ashoka              <span v-if="rtadState">
100aee27141SNikhil Ashoka                {{ $t('global.status.enabled') }}
101aee27141SNikhil Ashoka              </span>
102aee27141SNikhil Ashoka              <span v-else>{{ $t('global.status.disabled') }}</span>
103aee27141SNikhil Ashoka            </b-form-checkbox>
104aee27141SNikhil Ashoka          </b-col>
105aee27141SNikhil Ashoka        </b-row>
1062dabfc1bSkirankumarb07        <b-row class="setting-section">
1072dabfc1bSkirankumarb07          <b-col class="d-flex align-items-center justify-content-between">
1082dabfc1bSkirankumarb07            <dl class="mt-3 mr-3 w-75">
1092dabfc1bSkirankumarb07              <dt>{{ $t('pagePolicies.webSessionTimeOut') }}</dt>
1102dabfc1bSkirankumarb07              <dd>
1112dabfc1bSkirankumarb07                {{ $t('pagePolicies.webSessionTimeOutDescription') }}
1122dabfc1bSkirankumarb07              </dd>
1132dabfc1bSkirankumarb07            </dl>
1142dabfc1bSkirankumarb07          </b-col>
1152dabfc1bSkirankumarb07          <b-col lg="3" class="session-timeout">
1162dabfc1bSkirankumarb07            <b-form-select
1172dabfc1bSkirankumarb07              id="session-timeout-options"
1182dabfc1bSkirankumarb07              v-model="sessionTimeoutState"
1192dabfc1bSkirankumarb07              :options="sessionTimeOutOptions"
1202dabfc1bSkirankumarb07              @change="saveSessionTimeoutValue"
1212dabfc1bSkirankumarb07            >
1222dabfc1bSkirankumarb07              <template #first>
1232dabfc1bSkirankumarb07                <b-form-select-option :value="null" disabled>
1242dabfc1bSkirankumarb07                  {{ $t('global.form.selectAnOption') }}
1252dabfc1bSkirankumarb07                </b-form-select-option>
1262dabfc1bSkirankumarb07              </template>
1272dabfc1bSkirankumarb07            </b-form-select>
1282dabfc1bSkirankumarb07          </b-col>
1292dabfc1bSkirankumarb07        </b-row>
130b440616cSSandeepa Singh      </b-col>
131b440616cSSandeepa Singh    </b-row>
132b440616cSSandeepa Singh  </b-container>
133b440616cSSandeepa Singh</template>
134b440616cSSandeepa Singh
135b440616cSSandeepa Singh<script>
136b440616cSSandeepa Singhimport PageTitle from '@/components/Global/PageTitle';
137b440616cSSandeepa Singh
138b440616cSSandeepa Singhimport LoadingBarMixin from '@/components/Mixins/LoadingBarMixin';
139b440616cSSandeepa Singhimport BVToastMixin from '@/components/Mixins/BVToastMixin';
140*de23ea23SSurya Vimport { useI18n } from 'vue-i18n';
141*de23ea23SSurya Vimport i18n from '@/i18n';
142b440616cSSandeepa Singh
143b440616cSSandeepa Singhexport default {
144b440616cSSandeepa Singh  name: 'Policies',
145aee27141SNikhil Ashoka  components: { PageTitle },
146b440616cSSandeepa Singh  mixins: [LoadingBarMixin, BVToastMixin],
147b440616cSSandeepa Singh  beforeRouteLeave(to, from, next) {
148b440616cSSandeepa Singh    this.hideLoader();
149b440616cSSandeepa Singh    next();
150b440616cSSandeepa Singh  },
151e020d581SMichalX Szopinski  data() {
152e020d581SMichalX Szopinski    return {
153*de23ea23SSurya V      $t: useI18n().t,
154e020d581SMichalX Szopinski      modifySSHPolicyDisabled:
155e020d581SMichalX Szopinski        process.env.VUE_APP_MODIFY_SSH_POLICY_DISABLED === 'true',
1562dabfc1bSkirankumarb07      sessionTimeOutOptions: [
157*de23ea23SSurya V        { value: 1800, text: i18n.global.t('pagePolicies.options.30minutes') },
158*de23ea23SSurya V        { value: 3600, text: i18n.global.t('pagePolicies.options.1hour') },
159*de23ea23SSurya V        { value: 7200, text: i18n.global.t('pagePolicies.options.2hours') },
160*de23ea23SSurya V        { value: 14400, text: i18n.global.t('pagePolicies.options.4hours') },
161*de23ea23SSurya V        { value: 28800, text: i18n.global.t('pagePolicies.options.8hours') },
162*de23ea23SSurya V        { value: 86400, text: i18n.global.t('pagePolicies.options.1day') },
1632dabfc1bSkirankumarb07      ],
164e020d581SMichalX Szopinski    };
165e020d581SMichalX Szopinski  },
166b440616cSSandeepa Singh  computed: {
167b440616cSSandeepa Singh    sshProtocolState: {
168b440616cSSandeepa Singh      get() {
169b440616cSSandeepa Singh        return this.$store.getters['policies/sshProtocolEnabled'];
170b440616cSSandeepa Singh      },
171b440616cSSandeepa Singh      set(newValue) {
172b440616cSSandeepa Singh        return newValue;
173b440616cSSandeepa Singh      },
174b440616cSSandeepa Singh    },
175b440616cSSandeepa Singh    ipmiProtocolState: {
176b440616cSSandeepa Singh      get() {
177b440616cSSandeepa Singh        return this.$store.getters['policies/ipmiProtocolEnabled'];
178b440616cSSandeepa Singh      },
179b440616cSSandeepa Singh      set(newValue) {
180b440616cSSandeepa Singh        return newValue;
181b440616cSSandeepa Singh      },
182b440616cSSandeepa Singh    },
183aee27141SNikhil Ashoka    rtadState: {
184aee27141SNikhil Ashoka      get() {
185aee27141SNikhil Ashoka        if (this.$store.getters['policies/rtadEnabled'] === 'Enabled') {
186aee27141SNikhil Ashoka          return true;
187aee27141SNikhil Ashoka        } else {
188aee27141SNikhil Ashoka          return false;
189aee27141SNikhil Ashoka        }
190aee27141SNikhil Ashoka      },
191aee27141SNikhil Ashoka      set(newValue) {
192aee27141SNikhil Ashoka        return newValue;
193aee27141SNikhil Ashoka      },
194aee27141SNikhil Ashoka    },
195aee27141SNikhil Ashoka    vtpmState: {
196aee27141SNikhil Ashoka      get() {
197aee27141SNikhil Ashoka        if (this.$store.getters['policies/vtpmEnabled'] === 'Enabled') {
198aee27141SNikhil Ashoka          return true;
199aee27141SNikhil Ashoka        } else {
200aee27141SNikhil Ashoka          return false;
201aee27141SNikhil Ashoka        }
202aee27141SNikhil Ashoka      },
203aee27141SNikhil Ashoka      set(newValue) {
204aee27141SNikhil Ashoka        return newValue;
205aee27141SNikhil Ashoka      },
206aee27141SNikhil Ashoka    },
2072dabfc1bSkirankumarb07    sessionTimeoutState: {
2082dabfc1bSkirankumarb07      get() {
2092dabfc1bSkirankumarb07        return this.$store.getters['policies/getSessionTimeoutValue'];
2102dabfc1bSkirankumarb07      },
2112dabfc1bSkirankumarb07      set(newValue) {
2122dabfc1bSkirankumarb07        return newValue;
2132dabfc1bSkirankumarb07      },
2142dabfc1bSkirankumarb07    },
215b440616cSSandeepa Singh  },
216b440616cSSandeepa Singh  created() {
217b440616cSSandeepa Singh    this.startLoader();
218aee27141SNikhil Ashoka    Promise.all([
219aee27141SNikhil Ashoka      this.$store.dispatch('policies/getBiosStatus'),
220aee27141SNikhil Ashoka      this.$store.dispatch('policies/getNetworkProtocolStatus'),
2212dabfc1bSkirankumarb07      this.$store.dispatch('policies/getSessionTimeout'),
222aee27141SNikhil Ashoka    ]).finally(() => this.endLoader());
223b440616cSSandeepa Singh  },
224b440616cSSandeepa Singh  methods: {
225b440616cSSandeepa Singh    changeIpmiProtocolState(state) {
226b440616cSSandeepa Singh      this.$store
227b440616cSSandeepa Singh        .dispatch('policies/saveIpmiProtocolState', state)
228b440616cSSandeepa Singh        .then((message) => this.successToast(message))
229b440616cSSandeepa Singh        .catch(({ message }) => this.errorToast(message));
230b440616cSSandeepa Singh    },
231b440616cSSandeepa Singh    changeSshProtocolState(state) {
232b440616cSSandeepa Singh      this.$store
233b440616cSSandeepa Singh        .dispatch('policies/saveSshProtocolState', state)
234b440616cSSandeepa Singh        .then((message) => this.successToast(message))
235b440616cSSandeepa Singh        .catch(({ message }) => this.errorToast(message));
236b440616cSSandeepa Singh    },
237aee27141SNikhil Ashoka    changeRtadState(state) {
238aee27141SNikhil Ashoka      this.$store
239aee27141SNikhil Ashoka        .dispatch('policies/saveRtadState', state ? 'Enabled' : 'Disabled')
240aee27141SNikhil Ashoka        .then((message) => this.successToast(message))
241aee27141SNikhil Ashoka        .catch(({ message }) => this.errorToast(message));
242aee27141SNikhil Ashoka    },
243aee27141SNikhil Ashoka    changeVtpmState(state) {
244aee27141SNikhil Ashoka      this.$store
245aee27141SNikhil Ashoka        .dispatch('policies/saveVtpmState', state ? 'Enabled' : 'Disabled')
246aee27141SNikhil Ashoka        .then((message) => this.successToast(message))
247aee27141SNikhil Ashoka        .catch(({ message }) => this.errorToast(message));
248aee27141SNikhil Ashoka    },
2492dabfc1bSkirankumarb07    saveSessionTimeoutValue(sessionTimeoutState) {
2502dabfc1bSkirankumarb07      this.$store
2512dabfc1bSkirankumarb07        .dispatch('policies/saveSessionTimeoutValue', sessionTimeoutState)
2522dabfc1bSkirankumarb07        .then((message) => this.successToast(message))
2532dabfc1bSkirankumarb07        .catch(({ message }) => this.errorToast(message));
2542dabfc1bSkirankumarb07    },
255b440616cSSandeepa Singh  },
256b440616cSSandeepa Singh};
257b440616cSSandeepa Singh</script>
258b440616cSSandeepa Singh
259b440616cSSandeepa Singh<style lang="scss" scoped>
260b440616cSSandeepa Singh.setting-section {
261b440616cSSandeepa Singh  border-bottom: 1px solid gray('300');
262b440616cSSandeepa Singh}
2632dabfc1bSkirankumarb07.session-timeout {
2642dabfc1bSkirankumarb07  align-self: center;
2652dabfc1bSkirankumarb07}
266b440616cSSandeepa Singh</style>
267