summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamian Celico <damianx.celico@intel.com>2022-06-27 17:43:21 +0300
committerDamian Celico <damianx.celico@intel.com>2022-09-26 18:19:54 +0300
commit31fb2b96a58492c3214197685787f42f305a42ad (patch)
treeac0f3d472aa34099cc568b0c213576f75c204bf7
parentd9566225f1c25b1892c332e0f3a16c1b5e4ba714 (diff)
downloadwebui-vue-31fb2b96a58492c3214197685787f42f305a42ad.tar.xz
Check certificate file extension
Checking the file extension type of uploaded certificates to redfish. Sends the file only if the file type is correct, otherwise shows error. Signed-off-by: Damian Celico <damianx.celico@intel.com> Change-Id: Idfc790bc8967333aed66c5c128334af4231dbea3
-rw-r--r--src/locales/en-US.json3
-rw-r--r--src/views/SecurityAndAccess/Certificates/Certificates.vue30
2 files changed, 25 insertions, 8 deletions
diff --git a/src/locales/en-US.json b/src/locales/en-US.json
index e43167c6..3fd2deda 100644
--- a/src/locales/en-US.json
+++ b/src/locales/en-US.json
@@ -866,7 +866,8 @@
"certificateExpiredMessage": "%{certificate} has expired. Consider replacing it with a new certificate.",
"certificateExpiringMessage": "%{certificate} is expiring soon. Consider replacing it with a new certificate.",
"certificatesExpiredMessage": "Some certificates have expired. Consider replacing them with new certificates.",
- "certificatesExpiringMessage": "Some certificates are expiring soon. Consider replacing them with new certificates."
+ "certificatesExpiringMessage": "Some certificates are expiring soon. Consider replacing them with new certificates.",
+ "incorrectCertificateFileType": "File is not a correct certificate type"
},
"modal": {
"alternateName": "Alternate name",
diff --git a/src/views/SecurityAndAccess/Certificates/Certificates.vue b/src/views/SecurityAndAccess/Certificates/Certificates.vue
index 0113b80a..677d19d9 100644
--- a/src/views/SecurityAndAccess/Certificates/Certificates.vue
+++ b/src/views/SecurityAndAccess/Certificates/Certificates.vue
@@ -29,6 +29,12 @@
}}
</template>
</alert>
+ <!-- Wrong file type banner -->
+ <alert :show="fileTypeCorrect === false" variant="danger">
+ <template v-if="fileTypeCorrect === false">
+ {{ $t('pageCertificates.alert.incorrectCertificateFileType') }}
+ </template>
+ </alert>
</b-col>
</b-row>
<b-row>
@@ -136,6 +142,7 @@ export default {
return {
isBusy: true,
modalCertificate: null,
+ fileTypeCorrect: undefined,
fields: [
{
key: 'certificate',
@@ -258,19 +265,24 @@ export default {
onModalOk({ addNew, file, type, location }) {
if (addNew) {
// Upload a new certificate
- this.addNewCertificate(file, type);
+ this.fileTypeCorrect = this.getIsFileTypeCorrect(file);
+ if (this.fileTypeCorrect) {
+ this.addNewCertificate(file, type);
+ }
} else {
// Replace an existing certificate
this.replaceCertificate(file, type, location);
}
},
addNewCertificate(file, type) {
- this.startLoader();
- this.$store
- .dispatch('certificates/addNewCertificate', { file, type })
- .then((success) => this.successToast(success))
- .catch(({ message }) => this.errorToast(message))
- .finally(() => this.endLoader());
+ if (this.fileTypeCorrect === true) {
+ this.startLoader();
+ this.$store
+ .dispatch('certificates/addNewCertificate', { file, type })
+ .then((success) => this.successToast(success))
+ .catch(({ message }) => this.errorToast(message))
+ .finally(() => this.endLoader());
+ }
},
replaceCertificate(file, type, location) {
this.startLoader();
@@ -317,6 +329,10 @@ export default {
return 'warning';
}
},
+ getIsFileTypeCorrect(file) {
+ const fileTypeExtension = file.name.split('.').pop();
+ return fileTypeExtension === 'pem';
+ },
},
};
</script>