Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions lib/Connector/Sabre/PropFindPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,31 @@ public function setE2EEProperties(PropFind $propFind, \Sabre\DAV\INode $node) {
});

$propFind->handle(self::E2EE_METADATA_PROPERTYNAME, function () use ($node) {
if ($this->isE2EEnabledPath($node)) {
if (!$this->isE2EEnabledPath($node)) {
return null;
}

try {
return $this->metaDataStorage->getMetaData(
$this->userSession->getUser()->getUID(),
$node->getId(),
);
} catch (\Throwable $e) {
// Missing metadata must not break PROPFIND (avoid 500)
return null;
}
});

$propFind->handle(self::E2EE_METADATA_SIGNATURE_PROPERTYNAME, function () use ($node) {
if ($this->isE2EEnabledPath($node)) {
if (!$this->isE2EEnabledPath($node)) {
return null;
}

try {
return $this->metaDataStorage->readSignature($node->getId());
} catch (\Throwable $e) {
// Missing signature/metadata must not break PROPFIND (avoid 500)
return null;
}
});
}
Expand Down
5 changes: 5 additions & 0 deletions lib/Controller/ConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ public function setUserConfig(string $key, string $value): JSONResponse {
return new JSONResponse([], Http::STATUS_PRECONDITION_FAILED);
}

// force disable e2eeInBrowserEnabled
if ($key === 'e2eeInBrowserEnabled') {
$value = 'false';
}

$this->config->setUserValue($this->userId, Application::APP_ID, $key, $value);
return new JSONResponse([], Http::STATUS_OK);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Listener/LoadAdditionalListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function handle(Event $event): void {
$this->initialState->provideInitialState(
'userConfig',
[
'e2eeInBrowserEnabled' => $this->config->getUserValue($this->userId, 'end_to_end_encryption', 'e2eeInBrowserEnabled', 'false') === 'true',
'e2eeInBrowserEnabled' => false,
]
);

Expand Down
15 changes: 11 additions & 4 deletions lib/MetaDataStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,18 @@ public function getMetaData(string $userId, int $id): string {
}

$folderName = $this->getFolderNameForFileId($id);
$folder = $this->appData->getFolder($folderName);

return $folder
->getFile($this->metaDataFileName)
->getContent();
try {
$folder = $this->appData->getFolder($folderName);
} catch (NotFoundException $e) {
throw new MissingMetaDataException('Meta-data folder missing');
}

try {
return $folder->getFile($this->metaDataFileName)->getContent();
} catch (NotFoundException $e) {
throw new MissingMetaDataException('Meta-data file missing');
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Settings/Personal.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function getForm(): TemplateResponse {
$this->initialState->provideInitialState(
'userConfig',
[
'e2eeInBrowserEnabled' => $this->config->getUserValue($this->userId, 'end_to_end_encryption', 'e2eeInBrowserEnabled', 'false') === 'true',
'e2eeInBrowserEnabled' => false,
]
);

Expand Down
2 changes: 1 addition & 1 deletion src/components/MnemonicPromptDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function submit() {

const buttons = computed(() => [
{
label: t('end_to_en_encryption', 'Submit'),
label: t('end_to_end_encryption', 'Submit'),
nativeType: 'submit',
type: 'primary',
disabled: !isFormValid.value,
Expand Down
63 changes: 32 additions & 31 deletions src/components/SecuritySection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,41 @@
<template>
<NcSettingsSection :name="t('end_to_end_encryption', 'End-to-end encryption')"
:description="encryptionState">
<NcButton v-if="!shouldDisplayE2EEInBrowserWarning && userConfig['e2eeInBrowserEnabled'] === false"
class="margin-bottom"
:disabled="!hasKey"
type="secondary"
@click="shouldDisplayE2EEInBrowserWarning = true">
{{ t('end_to_end_encryption', 'Enable E2EE navigation in browser') }}
</NcButton>
<NcNoteCard v-else
class="notecard"
type="warning"
:show-alert="true"
:heading="t('end_to_end_encryption', 'Enabling E2EE in the browser can weaken security')">
<NcButton v-if="userConfig['e2eeInBrowserEnabled'] === false"
class="close-button"
:aria-label="t('end_to_end_encryption', 'Close')"
type="tertiary-no-background"
@click="shouldDisplayE2EEInBrowserWarning = false">
<template #icon>
<IconClose :size="20" />
</template>
</NcButton>

{{ t('end_to_end_encryption', 'The server could serve malicious source code to extract the secret that protects your files.') }}

<NcCheckboxRadioSwitch :disabled="!hasKey"
data-cy-e2ee-settings-setting="e2ee_in_browser_enabled"
:checked="userConfig.e2eeInBrowserEnabled"
<template v-if="false">
<NcButton v-if="!shouldDisplayE2EEInBrowserWarning && userConfig['e2eeInBrowserEnabled'] === false"
class="margin-bottom"
type="switch"
@update:checked="value => setConfig('e2eeInBrowserEnabled', value)">
:disabled="!hasKey"
type="secondary"
@click="shouldDisplayE2EEInBrowserWarning = true">
{{ t('end_to_end_encryption', 'Enable E2EE navigation in browser') }}
</NcCheckboxRadioSwitch>
</NcNoteCard>
</NcButton>
<NcNoteCard v-else
class="notecard"
type="warning"
:show-alert="true"
:heading="t('end_to_end_encryption', 'Enabling E2EE in the browser can weaken security')">
<NcButton v-if="userConfig['e2eeInBrowserEnabled'] === false"
class="close-button"
:aria-label="t('end_to_end_encryption', 'Close')"
type="tertiary-no-background"
@click="shouldDisplayE2EEInBrowserWarning = false">
<template #icon>
<IconClose :size="20" />
</template>
</NcButton>

{{ t('end_to_end_encryption', 'The server could serve malicious source code to extract the secret that protects your files.') }}

<NcCheckboxRadioSwitch :disabled="!hasKey"
data-cy-e2ee-settings-setting="e2ee_in_browser_enabled"
:checked="userConfig.e2eeInBrowserEnabled"
class="margin-bottom"
type="switch"
@update:checked="value => setConfig('e2eeInBrowserEnabled', value)">
{{ t('end_to_end_encryption', 'Enable E2EE navigation in browser') }}
</NcCheckboxRadioSwitch>
</NcNoteCard>
</template>
<NcButton v-if="!shouldDisplayWarning"
:disabled="!hasKey"
:type="(hasKey && !shouldDisplayWarning) ? 'error' : 'secondary'"
Expand Down