encryption: do not allow password and hint to be the same

This commit is contained in:
Girish Ramakrishnan
2025-10-07 16:49:57 +02:00
parent 55091cfe8d
commit 02ba2fe59b
2 changed files with 4 additions and 2 deletions
@@ -379,11 +379,11 @@ defineExpose({
<fieldset :disabled="busy">
<input style="display: none;" type="submit"/>
<div class="warning-label">{{ $t('backups.configureBackupStorage.encryptionDescription') }}</div>
<div class="error-label" v-if="formError.generic">{{ formError.generic }}</div>
<FormGroup>
<label for="encryptionPassswordInput">{{ $t('backups.configureBackupStorage.encryptionPassword') }} <sup><a href="https://docs.cloudron.io/backups/#encryption" class="help" target="_blank"><i class="fa fa-question-circle"></i></a></sup></label>
<PasswordInput id="encryptionPassswordInput" v-model="encryptionPassword" :placeholder="$t('backups.configureBackupStorage.encryptionPasswordPlaceholder')" required />
<div class="warning-label">{{ $t('backups.configureBackupStorage.encryptionDescription') }}</div>
<div class="error-label" v-if="formError.password">{{ formError.password }}</div>
</FormGroup>
<FormGroup>
+3 -1
View File
@@ -304,6 +304,7 @@ async function setEncryption(backupSite, data, auditSource) {
if (data.encryptionPassword) {
const encryptionPasswordError = validateEncryptionPassword(data.encryptionPassword);
if (encryptionPasswordError) throw encryptionPasswordError;
if (data.encryptionPassword === data.encryptionPasswordHint) throw new BoxError(BoxError.BAD_FIELD, 'password hint cannot be the same as password');
encryption = hush.generateEncryptionKeysSync(data.encryptionPassword);
encryption.encryptedFilenames = !!data.encryptedFilenames;
encryption.encryptionPasswordHint = data.encryptionPasswordHint || '';
@@ -519,7 +520,7 @@ async function add(data, auditSource) {
const limits = data.limits || null,
encryptionPassword = data.encryptionPassword || null,
encryptedFilenames = data.encryptedFilenames || false,
encryptionPasswordHint = data.encryptionPasswordHint || null;
encryptionPasswordHint = data.encryptionPasswordHint || '';
const formatError = backupFormats.validateFormat(format);
if (formatError) throw formatError;
@@ -534,6 +535,7 @@ async function add(data, auditSource) {
if (encryptionPassword) {
const encryptionPasswordError = validateEncryptionPassword(encryptionPassword);
if (encryptionPasswordError) throw encryptionPasswordError;
if (data.encryptionPassword === data.encryptionPasswordHint) throw new BoxError(BoxError.BAD_FIELD, 'Password hint cannot be the same as password');
encryption = hush.generateEncryptionKeysSync(encryptionPassword);
encryption.encryptedFilenames = !!encryptedFilenames;
encryption.encryptionPasswordHint = encryptionPasswordHint;