|
6 | 6 | <template> |
7 | 7 | <NcSettingsSection :name="t('end_to_end_encryption', 'End-to-end encryption')" |
8 | 8 | :description="encryptionState"> |
9 | | - <NcButton :disabled="!hasKey || shouldDisplayWarning" |
| 9 | + <NcButton v-if="!shouldDisplayE2EEInBrowserWarning && userConfig['e2eeInBrowserEnabled'] === false" |
| 10 | + class="margin-bottom" |
| 11 | + :disabled="!hasKey" |
| 12 | + type="secondary" |
| 13 | + @click="shouldDisplayE2EEInBrowserWarning = true"> |
| 14 | + {{ t('end_to_end_encryption', 'Enable E2EE navigation in browser') }} |
| 15 | + </NcButton> |
| 16 | + <NcNoteCard v-else |
| 17 | + class="notecard" |
| 18 | + type="warning" |
| 19 | + :show-alert="true" |
| 20 | + :heading="t('end_to_end_encryption', 'Enabling E2EE in the browser can weaken security')"> |
| 21 | + <NcButton v-if="userConfig['e2eeInBrowserEnabled'] === false" |
| 22 | + class="close-button" |
| 23 | + :aria-label="t('end_to_end_encryption', 'Close')" |
| 24 | + type="tertiary-no-background" |
| 25 | + @click="shouldDisplayE2EEInBrowserWarning = false"> |
| 26 | + <template #icon> |
| 27 | + <IconClose :size="20" /> |
| 28 | + </template> |
| 29 | + </NcButton> |
| 30 | + |
| 31 | + {{ t('end_to_end_encryption', 'The server could serve malicious source code to extract the secret that protects your files.') }} |
| 32 | + |
| 33 | + <NcCheckboxRadioSwitch :disabled="!hasKey" |
| 34 | + data-cy-e2ee-settings-setting="e2ee_in_browser_enabled" |
| 35 | + :checked="userConfig.e2eeInBrowserEnabled" |
| 36 | + class="margin-bottom" |
| 37 | + type="switch" |
| 38 | + @update:checked="value => setConfig('e2eeInBrowserEnabled', value)"> |
| 39 | + {{ t('end_to_end_encryption', 'Enable E2EE navigation in browser') }} |
| 40 | + </NcCheckboxRadioSwitch> |
| 41 | + </NcNoteCard> |
| 42 | + |
| 43 | + <NcButton v-if="!shouldDisplayWarning" |
| 44 | + :disabled="!hasKey" |
10 | 45 | :type="(hasKey && !shouldDisplayWarning) ? 'error' : 'secondary'" |
11 | 46 | @click="startResetProcess()"> |
12 | 47 | {{ t('end_to_end_encryption', 'Reset end-to-end encryption') }} |
13 | 48 | </NcButton> |
| 49 | + <NcNoteCard v-else |
| 50 | + class="notecard" |
| 51 | + type="warning" |
| 52 | + :show-alert="true" |
| 53 | + :heading="t('end_to_end_encryption', 'Please read carefully before resetting your end-to-end encryption keys')"> |
| 54 | + <NcButton class="close-button" |
| 55 | + :aria-label="t('end_to_end_encryption', 'Close')" |
| 56 | + type="tertiary-no-background" |
| 57 | + @click="shouldDisplayWarning = false"> |
| 58 | + <template #icon> |
| 59 | + <IconClose :size="20" /> |
| 60 | + </template> |
| 61 | + </NcButton> |
14 | 62 |
|
15 | | - <div v-if="shouldDisplayWarning && hasKey" class="notecard warning" role="alert"> |
16 | | - <p><strong>{{ t('end_to_end_encryption', 'Please read carefully before resetting your end-to-end encryption keys') }}</strong></p> |
17 | 63 | <ul> |
18 | 64 | <li>{{ t('end_to_end_encryption', 'Once your end-to-end encryption keys are reset, all files stored in your encrypted folder will be inaccessible.') }}</li> |
19 | 65 | <li>{{ t('end_to_end_encryption', 'You should only reset your end-to-end encryption keys if you lost your secure key words (mnemonic).') }}</li> |
|
28 | 74 | <NcButton type="error" @click="showDialog"> |
29 | 75 | {{ t('end_to_end_encryption', "Confirm and reset end-to-end encryption") }} |
30 | 76 | </NcButton> |
31 | | - </div> |
| 77 | + </NcNoteCard> |
32 | 78 | </NcSettingsSection> |
33 | 79 | </template> |
34 | 80 |
|
35 | | -<script> |
| 81 | +<script lang="ts"> |
| 82 | +import { defineComponent } from 'vue' |
| 83 | +import IconClose from 'vue-material-design-icons/Close.vue' |
| 84 | +
|
36 | 85 | import axios from '@nextcloud/axios' |
| 86 | +import { translate as t } from '@nextcloud/l10n' |
37 | 87 | import NcSettingsSection from '@nextcloud/vue/dist/Components/NcSettingsSection.js' |
38 | 88 | import NcCheckboxRadioSwitch from '@nextcloud/vue/dist/Components/NcCheckboxRadioSwitch.js' |
39 | 89 | import NcButton from '@nextcloud/vue/dist/Components/NcButton.js' |
| 90 | +import NcNoteCard from '@nextcloud/vue/dist/Components/NcNoteCard.js' |
40 | 91 | import { loadState } from '@nextcloud/initial-state' |
41 | 92 | import { showError, showSuccess, DialogBuilder } from '@nextcloud/dialogs' |
42 | | -import { generateOcsUrl } from '@nextcloud/router' |
| 93 | +import { generateOcsUrl, generateUrl } from '@nextcloud/router' |
43 | 94 |
|
44 | 95 | import logger from '../services/logger.js' |
45 | 96 |
|
46 | | -export default { |
| 97 | +export default defineComponent({ |
47 | 98 | name: 'SecuritySection', |
48 | 99 | components: { |
49 | 100 | NcSettingsSection, |
50 | 101 | NcButton, |
51 | 102 | NcCheckboxRadioSwitch, |
| 103 | + NcNoteCard, |
| 104 | + IconClose, |
52 | 105 | }, |
53 | 106 |
|
54 | 107 | data() { |
55 | 108 | return { |
56 | 109 | hasKey: loadState('end_to_end_encryption', 'hasKey'), |
57 | 110 | shouldDisplayWarning: false, |
58 | 111 | deleteEncryptedFiles: false, |
| 112 | + shouldDisplayE2EEInBrowserWarning: false, |
| 113 | + userConfig: loadState('end_to_end_encryption', 'userConfig', { e2eeInBrowserEnabled: false }), |
59 | 114 | } |
60 | 115 | }, |
61 | 116 |
|
@@ -178,23 +233,27 @@ export default { |
178 | 233 | } |
179 | 234 | return true |
180 | 235 | }, |
| 236 | +
|
| 237 | + async setConfig(key: string, value: string) { |
| 238 | + await axios.put(generateUrl('apps/end_to_end_encryption/api/v1/config/{key}', { key }), { |
| 239 | + value: (typeof value === 'string') ? value : JSON.stringify(value), |
| 240 | + }) |
| 241 | + this.userConfig[key] = value |
| 242 | + }, |
| 243 | +
|
| 244 | + t, |
181 | 245 | }, |
182 | | -} |
| 246 | +}) |
183 | 247 | </script> |
184 | 248 |
|
185 | 249 | <style lang="scss" scoped> |
186 | 250 | .notecard { |
187 | | - color: var(--color-text-light) !important; |
188 | | - background-color: var(--note-background) !important; |
189 | | - border: 1px solid var(--color-border); |
190 | | - border-left: 4px solid var(--note-theme); |
191 | | - border-radius: var(--border-radius); |
192 | | - box-shadow: rgba(43, 42, 51, 0.05) 0 1px 2px 0; |
193 | | - margin: 1rem 0; |
194 | | - padding: 1rem !important; |
195 | | - &.warning { |
196 | | - --note-background: rgba(var(--color-warning-rgb), 0.2); |
197 | | - --note-theme: var(--color-warning); |
| 251 | + position: relative; |
| 252 | +
|
| 253 | + .close-button { |
| 254 | + position: absolute; |
| 255 | + top: 0; |
| 256 | + right: 0; |
198 | 257 | } |
199 | 258 | } |
200 | 259 |
|
|
0 commit comments