summaryrefslogtreecommitdiff
path: root/src/store/modules/AccessControl
diff options
context:
space:
mode:
Diffstat (limited to 'src/store/modules/AccessControl')
-rw-r--r--src/store/modules/AccessControl/LdapStore.js64
-rw-r--r--src/store/modules/AccessControl/LocalUserMangementStore.js64
-rw-r--r--src/store/modules/AccessControl/SslCertificatesStore.js54
3 files changed, 92 insertions, 90 deletions
diff --git a/src/store/modules/AccessControl/LdapStore.js b/src/store/modules/AccessControl/LdapStore.js
index 780de38e..722384c1 100644
--- a/src/store/modules/AccessControl/LdapStore.js
+++ b/src/store/modules/AccessControl/LdapStore.js
@@ -13,7 +13,7 @@ const LdapStore = {
baseDn: null,
userAttribute: null,
groupsAttribute: null,
- roleGroups: []
+ roleGroups: [],
},
activeDirectory: {
serviceEnabled: null,
@@ -22,14 +22,14 @@ const LdapStore = {
baseDn: null,
userAttribute: null,
groupsAttribute: null,
- roleGroups: []
- }
+ roleGroups: [],
+ },
},
getters: {
- isServiceEnabled: state => state.isServiceEnabled,
- ldap: state => state.ldap,
- activeDirectory: state => state.activeDirectory,
- isActiveDirectoryEnabled: state => {
+ isServiceEnabled: (state) => state.isServiceEnabled,
+ ldap: (state) => state.ldap,
+ activeDirectory: (state) => state.activeDirectory,
+ isActiveDirectoryEnabled: (state) => {
return state.activeDirectory.serviceEnabled;
},
enabledRoleGroups: (state, getters) => {
@@ -37,7 +37,7 @@ const LdapStore = {
? 'activeDirectory'
: 'ldap';
return state[serviceType].roleGroups;
- }
+ },
},
mutations: {
setServiceEnabled: (state, serviceEnabled) =>
@@ -49,7 +49,7 @@ const LdapStore = {
ServiceAddresses,
Authentication = {},
LDAPService: { SearchSettings = {} } = {},
- RemoteRoleMapping = []
+ RemoteRoleMapping = [],
}
) => {
state.ldap.serviceAddress = ServiceAddresses[0];
@@ -67,7 +67,7 @@ const LdapStore = {
ServiceAddresses,
Authentication = {},
LDAPService: { SearchSettings = {} } = {},
- RemoteRoleMapping = []
+ RemoteRoleMapping = [],
}
) => {
state.activeDirectory.serviceEnabled = ServiceEnabled;
@@ -77,7 +77,7 @@ const LdapStore = {
state.activeDirectory.userAttribute = SearchSettings.UsernameAttribute;
state.activeDirectory.groupsAttribute = SearchSettings.GroupsAttribute;
state.activeDirectory.roleGroups = RemoteRoleMapping;
- }
+ },
},
actions: {
async getAccountSettings({ commit }) {
@@ -91,21 +91,21 @@ const LdapStore = {
commit('setLdapProperties', LDAP);
commit('setActiveDirectoryProperties', ActiveDirectory);
})
- .catch(error => console.log(error));
+ .catch((error) => console.log(error));
},
async saveLdapSettings({ state, dispatch }, properties) {
const data = { LDAP: properties };
if (state.activeDirectory.serviceEnabled) {
// Disable Active Directory service if enabled
await api.patch('/redfish/v1/AccountService', {
- ActiveDirectory: { ServiceEnabled: false }
+ ActiveDirectory: { ServiceEnabled: false },
});
}
return await api
.patch('/redfish/v1/AccountService', data)
.then(() => dispatch('getAccountSettings'))
.then(() => i18n.t('pageLdap.toast.successSaveLdapSettings'))
- .catch(error => {
+ .catch((error) => {
console.log(error);
throw new Error(i18n.t('pageLdap.toast.errorSaveLdapSettings'));
});
@@ -115,14 +115,14 @@ const LdapStore = {
if (state.ldap.serviceEnabled) {
// Disable LDAP service if enabled
await api.patch('/redfish/v1/AccountService', {
- LDAP: { ServiceEnabled: false }
+ LDAP: { ServiceEnabled: false },
});
}
return await api
.patch('/redfish/v1/AccountService', data)
.then(() => dispatch('getAccountSettings'))
.then(() => i18n.t('pageLdap.toast.successSaveActiveDirectorySettings'))
- .catch(error => {
+ .catch((error) => {
console.log(error);
throw new Error(
i18n.t('pageLdap.toast.errorSaveActiveDirectorySettings')
@@ -139,7 +139,7 @@ const LdapStore = {
bindPassword,
baseDn,
userIdAttribute,
- groupIdAttribute
+ groupIdAttribute,
}
) {
const data = {
@@ -147,13 +147,13 @@ const LdapStore = {
ServiceAddresses: [serviceAddress],
Authentication: {
Username: bindDn,
- Password: bindPassword
+ Password: bindPassword,
},
LDAPService: {
SearchSettings: {
- BaseDistinguishedNames: [baseDn]
- }
- }
+ BaseDistinguishedNames: [baseDn],
+ },
+ },
};
if (groupIdAttribute)
data.LDAPService.SearchSettings.GroupsAttribute = groupIdAttribute;
@@ -177,8 +177,8 @@ const LdapStore = {
...enabledRoleGroups,
{
LocalRole: groupPrivilege,
- RemoteGroup: groupName
- }
+ RemoteGroup: groupName,
+ },
];
if (isActiveDirectoryEnabled) {
data.ActiveDirectory = { RemoteRoleMapping };
@@ -190,10 +190,10 @@ const LdapStore = {
.then(() => dispatch('getAccountSettings'))
.then(() =>
i18n.t('pageLdap.toast.successAddRoleGroup', {
- groupName
+ groupName,
})
)
- .catch(error => {
+ .catch((error) => {
console.log(error);
throw new Error(i18n.t('pageLdap.toast.errorAddRoleGroup'));
});
@@ -202,11 +202,11 @@ const LdapStore = {
const data = {};
const enabledRoleGroups = getters['enabledRoleGroups'];
const isActiveDirectoryEnabled = getters['isActiveDirectoryEnabled'];
- const RemoteRoleMapping = enabledRoleGroups.map(group => {
+ const RemoteRoleMapping = enabledRoleGroups.map((group) => {
if (group.RemoteGroup === groupName) {
return {
RemoteGroup: groupName,
- LocalRole: groupPrivilege
+ LocalRole: groupPrivilege,
};
} else {
return {};
@@ -223,7 +223,7 @@ const LdapStore = {
.then(() =>
i18n.t('pageLdap.toast.successSaveRoleGroup', { groupName })
)
- .catch(error => {
+ .catch((error) => {
console.log(error);
throw new Error(i18n.t('pageLdap.toast.errorSaveRoleGroup'));
});
@@ -232,7 +232,7 @@ const LdapStore = {
const data = {};
const enabledRoleGroups = getters['enabledRoleGroups'];
const isActiveDirectoryEnabled = getters['isActiveDirectoryEnabled'];
- const RemoteRoleMapping = enabledRoleGroups.map(group => {
+ const RemoteRoleMapping = enabledRoleGroups.map((group) => {
if (find(roleGroups, { groupName: group.RemoteGroup })) {
return null;
} else {
@@ -250,14 +250,14 @@ const LdapStore = {
.then(() =>
i18n.tc('pageLdap.toast.successDeleteRoleGroup', roleGroups.length)
)
- .catch(error => {
+ .catch((error) => {
console.log(error);
throw new Error(
i18n.tc('pageLdap.toast.errorDeleteRoleGroup', roleGroups.length)
);
});
- }
- }
+ },
+ },
};
export default LdapStore;
diff --git a/src/store/modules/AccessControl/LocalUserMangementStore.js b/src/store/modules/AccessControl/LocalUserMangementStore.js
index e9de3cc1..6bc6ec5d 100644
--- a/src/store/modules/AccessControl/LocalUserMangementStore.js
+++ b/src/store/modules/AccessControl/LocalUserMangementStore.js
@@ -9,7 +9,7 @@ const LocalUserManagementStore = {
accountLockoutDuration: null,
accountLockoutThreshold: null,
accountMinPasswordLength: null,
- accountMaxPasswordLength: null
+ accountMaxPasswordLength: null,
},
getters: {
allUsers(state) {
@@ -21,15 +21,15 @@ const LocalUserManagementStore = {
accountSettings(state) {
return {
lockoutDuration: state.accountLockoutDuration,
- lockoutThreshold: state.accountLockoutThreshold
+ lockoutThreshold: state.accountLockoutThreshold,
};
},
accountPasswordRequirements(state) {
return {
minLength: state.accountMinPasswordLength,
- maxLength: state.accountMaxPasswordLength
+ maxLength: state.accountMaxPasswordLength,
};
- }
+ },
},
mutations: {
setUsers(state, allUsers) {
@@ -49,19 +49,21 @@ const LocalUserManagementStore = {
},
setAccountMaxPasswordLength(state, maxPasswordLength) {
state.accountMaxPasswordLength = maxPasswordLength;
- }
+ },
},
actions: {
async getUsers({ commit }) {
return await api
.get('/redfish/v1/AccountService/Accounts')
- .then(response => response.data.Members.map(user => user['@odata.id']))
- .then(userIds => api.all(userIds.map(user => api.get(user))))
- .then(users => {
- const userData = users.map(user => user.data);
+ .then((response) =>
+ response.data.Members.map((user) => user['@odata.id'])
+ )
+ .then((userIds) => api.all(userIds.map((user) => api.get(user))))
+ .then((users) => {
+ const userData = users.map((user) => user.data);
commit('setUsers', userData);
})
- .catch(error => {
+ .catch((error) => {
console.log(error);
const message = i18n.t(
'pageLocalUserManagement.toast.errorLoadUsers'
@@ -78,7 +80,7 @@ const LocalUserManagementStore = {
commit('setAccountMinPasswordLength', data.MinPasswordLength);
commit('setAccountMaxPasswordLength', data.MaxPasswordLength);
})
- .catch(error => {
+ .catch((error) => {
console.log(error);
const message = i18n.t(
'pageLocalUserManagement.toast.errorLoadAccountSettings'
@@ -90,29 +92,29 @@ const LocalUserManagementStore = {
api
.get('/redfish/v1/AccountService/Roles')
.then(({ data: { Members = [] } = {} }) => {
- const roles = Members.map(role => {
+ const roles = Members.map((role) => {
return role['@odata.id'].split('/').pop();
});
commit('setAccountRoles', roles);
})
- .catch(error => console.log(error));
+ .catch((error) => console.log(error));
},
async createUser({ dispatch }, { username, password, privilege, status }) {
const data = {
UserName: username,
Password: password,
RoleId: privilege,
- Enabled: status
+ Enabled: status,
};
return await api
.post('/redfish/v1/AccountService/Accounts', data)
.then(() => dispatch('getUsers'))
.then(() =>
i18n.t('pageLocalUserManagement.toast.successCreateUser', {
- username
+ username,
})
)
- .catch(error => {
+ .catch((error) => {
console.log(error);
const message = i18n.t(
'pageLocalUserManagement.toast.errorCreateUser',
@@ -136,10 +138,10 @@ const LocalUserManagementStore = {
.then(() => dispatch('getUsers'))
.then(() =>
i18n.t('pageLocalUserManagement.toast.successUpdateUser', {
- username: originalUsername
+ username: originalUsername,
})
)
- .catch(error => {
+ .catch((error) => {
console.log(error);
const message = i18n.t(
'pageLocalUserManagement.toast.errorUpdateUser',
@@ -154,10 +156,10 @@ const LocalUserManagementStore = {
.then(() => dispatch('getUsers'))
.then(() =>
i18n.t('pageLocalUserManagement.toast.successDeleteUser', {
- username
+ username,
})
)
- .catch(error => {
+ .catch((error) => {
console.log(error);
const message = i18n.t(
'pageLocalUserManagement.toast.errorDeleteUser',
@@ -170,14 +172,14 @@ const LocalUserManagementStore = {
const promises = users.map(({ username }) => {
return api
.delete(`/redfish/v1/AccountService/Accounts/${username}`)
- .catch(error => {
+ .catch((error) => {
console.log(error);
return error;
});
});
return await api
.all(promises)
- .then(response => {
+ .then((response) => {
dispatch('getUsers');
return response;
})
@@ -208,19 +210,19 @@ const LocalUserManagementStore = {
},
async enableUsers({ dispatch }, users) {
const data = {
- Enabled: true
+ Enabled: true,
};
const promises = users.map(({ username }) => {
return api
.patch(`/redfish/v1/AccountService/Accounts/${username}`, data)
- .catch(error => {
+ .catch((error) => {
console.log(error);
return error;
});
});
return await api
.all(promises)
- .then(response => {
+ .then((response) => {
dispatch('getUsers');
return response;
})
@@ -251,19 +253,19 @@ const LocalUserManagementStore = {
},
async disableUsers({ dispatch }, users) {
const data = {
- Enabled: false
+ Enabled: false,
};
const promises = users.map(({ username }) => {
return api
.patch(`/redfish/v1/AccountService/Accounts/${username}`, data)
- .catch(error => {
+ .catch((error) => {
console.log(error);
return error;
});
});
return await api
.all(promises)
- .then(response => {
+ .then((response) => {
dispatch('getUsers');
return response;
})
@@ -309,15 +311,15 @@ const LocalUserManagementStore = {
//GET new settings to update view
.then(() => dispatch('getAccountSettings'))
.then(() => i18n.t('pageLocalUserManagement.toast.successSaveSettings'))
- .catch(error => {
+ .catch((error) => {
console.log(error);
const message = i18n.t(
'pageLocalUserManagement.toast.errorSaveSettings'
);
throw new Error(message);
});
- }
- }
+ },
+ },
};
export default LocalUserManagementStore;
diff --git a/src/store/modules/AccessControl/SslCertificatesStore.js b/src/store/modules/AccessControl/SslCertificatesStore.js
index 73a74b23..752c2124 100644
--- a/src/store/modules/AccessControl/SslCertificatesStore.js
+++ b/src/store/modules/AccessControl/SslCertificatesStore.js
@@ -5,12 +5,12 @@ export const CERTIFICATE_TYPES = [
{
type: 'HTTPS Certificate',
location: '/redfish/v1/Managers/bmc/NetworkProtocol/HTTPS/Certificates/',
- label: i18n.t('pageSslCertificates.httpsCertificate')
+ label: i18n.t('pageSslCertificates.httpsCertificate'),
},
{
type: 'LDAP Certificate',
location: '/redfish/v1/AccountService/LDAP/Certificates/',
- label: i18n.t('pageSslCertificates.ldapCertificate')
+ label: i18n.t('pageSslCertificates.ldapCertificate'),
},
{
type: 'TrustStore Certificate',
@@ -18,13 +18,13 @@ export const CERTIFICATE_TYPES = [
// Web UI will show 'CA Certificate' instead of
// 'TrustStore Certificate' after user testing revealed
// the term 'TrustStore Certificate' wasn't recognized/was unfamilar
- label: i18n.t('pageSslCertificates.caCertificate')
- }
+ label: i18n.t('pageSslCertificates.caCertificate'),
+ },
];
const getCertificateProp = (type, prop) => {
const certificate = CERTIFICATE_TYPES.find(
- certificate => certificate.type === type
+ (certificate) => certificate.type === type
);
return certificate ? certificate[prop] : null;
};
@@ -33,11 +33,11 @@ const SslCertificatesStore = {
namespaced: true,
state: {
allCertificates: [],
- availableUploadTypes: []
+ availableUploadTypes: [],
},
getters: {
- allCertificates: state => state.allCertificates,
- availableUploadTypes: state => state.availableUploadTypes
+ allCertificates: (state) => state.allCertificates,
+ availableUploadTypes: (state) => state.availableUploadTypes,
},
mutations: {
setCertificates(state, certificates) {
@@ -45,17 +45,17 @@ const SslCertificatesStore = {
},
setAvailableUploadTypes(state, availableUploadTypes) {
state.availableUploadTypes = availableUploadTypes;
- }
+ },
},
actions: {
async getCertificates({ commit }) {
return await api
.get('/redfish/v1/CertificateService/CertificateLocations')
.then(({ data: { Links: { Certificates } } }) =>
- Certificates.map(certificate => certificate['@odata.id'])
+ Certificates.map((certificate) => certificate['@odata.id'])
)
- .then(certificateLocations => {
- const promises = certificateLocations.map(location =>
+ .then((certificateLocations) => {
+ const promises = certificateLocations.map((location) =>
api.get(location)
);
api.all(promises).then(
@@ -66,7 +66,7 @@ const SslCertificatesStore = {
ValidNotAfter,
ValidNotBefore,
Issuer = {},
- Subject = {}
+ Subject = {},
} = data;
return {
type: Name,
@@ -75,13 +75,13 @@ const SslCertificatesStore = {
issuedBy: Issuer.CommonName,
issuedTo: Subject.CommonName,
validFrom: new Date(ValidNotBefore),
- validUntil: new Date(ValidNotAfter)
+ validUntil: new Date(ValidNotAfter),
};
});
const availableUploadTypes = CERTIFICATE_TYPES.filter(
({ type }) =>
!certificates
- .map(certificate => certificate.type)
+ .map((certificate) => certificate.type)
.includes(type)
);
@@ -94,15 +94,15 @@ const SslCertificatesStore = {
async addNewCertificate({ dispatch }, { file, type }) {
return await api
.post(getCertificateProp(type, 'location'), file, {
- headers: { 'Content-Type': 'application/x-pem-file' }
+ headers: { 'Content-Type': 'application/x-pem-file' },
})
.then(() => dispatch('getCertificates'))
.then(() =>
i18n.t('pageSslCertificates.toast.successAddCertificate', {
- certificate: getCertificateProp(type, 'label')
+ certificate: getCertificateProp(type, 'label'),
})
)
- .catch(error => {
+ .catch((error) => {
console.log(error);
throw new Error(
i18n.t('pageSslCertificates.toast.errorAddCertificate')
@@ -126,10 +126,10 @@ const SslCertificatesStore = {
.then(() => dispatch('getCertificates'))
.then(() =>
i18n.t('pageSslCertificates.toast.successReplaceCertificate', {
- certificate: getCertificateProp(type, 'label')
+ certificate: getCertificateProp(type, 'label'),
})
)
- .catch(error => {
+ .catch((error) => {
console.log(error);
throw new Error(
i18n.t('pageSslCertificates.toast.errorReplaceCertificate')
@@ -142,10 +142,10 @@ const SslCertificatesStore = {
.then(() => dispatch('getCertificates'))
.then(() =>
i18n.t('pageSslCertificates.toast.successDeleteCertificate', {
- certificate: getCertificateProp(type, 'label')
+ certificate: getCertificateProp(type, 'label'),
})
)
- .catch(error => {
+ .catch((error) => {
console.log(error);
throw new Error(
i18n.t('pageSslCertificates.toast.errorDeleteCertificate')
@@ -167,12 +167,12 @@ const SslCertificatesStore = {
challengePassword,
contactPerson,
emailAddress,
- alternateName
+ alternateName,
} = userData;
const data = {};
data.CertificateCollection = {
- '@odata.id': getCertificateProp(certificateType, 'location')
+ '@odata.id': getCertificateProp(certificateType, 'location'),
};
data.Country = country;
data.State = state;
@@ -196,9 +196,9 @@ const SslCertificatesStore = {
)
//TODO: Success response also throws error so
// can't accurately show legitimate error in UI
- .catch(error => console.log(error));
- }
- }
+ .catch((error) => console.log(error));
+ },
+ },
};
export default SslCertificatesStore;