1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
<!--
- SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
- SPDX-License-Identifier: AGPL-3.0-or-later
-->
<template>
<NcSettingsSection :name="t('settings', 'Server-side encryption')"
:description="t('settings', 'Server-side encryption makes it possible to encrypt files which are uploaded to this server. This comes with limitations like a performance penalty, so enable this only if needed.')"
:doc-url="encryptionAdminDoc">
<NcCheckboxRadioSwitch :checked="encryptionEnabled || shouldDisplayWarning"
:disabled="encryptionEnabled"
type="switch"
@update:checked="displayWarning">
{{ t('settings', 'Enable server-side encryption') }}
</NcCheckboxRadioSwitch>
<div v-if="shouldDisplayWarning && !encryptionEnabled" class="notecard warning" role="alert">
<p>{{ t('settings', 'Please read carefully before activating server-side encryption:') }}</p>
<ul>
<li>{{ t('settings', 'Once encryption is enabled, all files uploaded to the server from that point forward will be encrypted at rest on the server. It will only be possible to disable encryption at a later date if the active encryption module supports that function, and all pre-conditions (e.g. setting a recover key) are met.') }}</li>
<li>{{ t('settings', 'Encryption alone does not guarantee security of the system. Please see documentation for more information about how the encryption app works, and the supported use cases.') }}</li>
<li>{{ t('settings', 'Be aware that encryption always increases the file size.') }}</li>
<li>{{ t('settings', 'It is always good to create regular backups of your data, in case of encryption make sure to backup the encryption keys along with your data.') }}</li>
</ul>
<p class="margin-bottom">
{{ t('settings', 'This is the final warning: Do you really want to enable encryption?') }}
</p>
<NcButton type="primary"
@click="enableEncryption()">
{{ t('settings', "Enable encryption") }}
</NcButton>
</div>
<div v-if="encryptionEnabled">
<div v-if="encryptionReady">
<p v-if="encryptionModules.length === 0">
{{ t('settings', 'No encryption module loaded, please enable an encryption module in the app menu.') }}
</p>
<template v-else>
<h3>{{ t('settings', 'Select default encryption module:') }}</h3>
<fieldset>
<NcCheckboxRadioSwitch v-for="(module, id) in encryptionModules"
:key="id"
:checked.sync="defaultCheckedModule"
:value="id"
type="radio"
name="default_encryption_module"
@update:checked="checkDefaultModule">
{{ module.displayName }}
</NcCheckboxRadioSwitch>
</fieldset>
</template>
</div>
<div v-else-if="externalBackendsEnabled">
{{
t(
'settings',
'You need to migrate your encryption keys from the old encryption (ownCloud <= 8.0) to the new one. Please enable the "Default encryption module" and run {command}',
{ command: '"occ encryption:migrate"' },
)
}}
</div>
</div>
</NcSettingsSection>
</template>
<script>
import { showError } from '@nextcloud/dialogs'
import { loadState } from '@nextcloud/initial-state'
import { generateOcsUrl } from '@nextcloud/router'
import { confirmPassword } from '@nextcloud/password-confirmation'
import axios from '@nextcloud/axios'
import NcCheckboxRadioSwitch from '@nextcloud/vue/dist/Components/NcCheckboxRadioSwitch.js'
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import NcSettingsSection from '@nextcloud/vue/dist/Components/NcSettingsSection.js'
import logger from '../logger'
import '@nextcloud/password-confirmation/dist/style.css'
export default {
name: 'Encryption',
components: {
NcCheckboxRadioSwitch,
NcSettingsSection,
NcButton,
},
data() {
const encryptionModules = loadState('settings', 'encryption-modules')
return {
encryptionReady: loadState('settings', 'encryption-ready'),
encryptionEnabled: loadState('settings', 'encryption-enabled'),
externalBackendsEnabled: loadState('settings', 'external-backends-enabled'),
encryptionAdminDoc: loadState('settings', 'encryption-admin-doc'),
encryptionModules,
shouldDisplayWarning: false,
migrating: false,
defaultCheckedModule: Object.entries(encryptionModules).find((module) => module[1].default)[0],
}
},
methods: {
displayWarning() {
if (!this.encryptionEnabled) {
this.shouldDisplayWarning = !this.shouldDisplayWarning
} else {
this.encryptionEnabled = false
this.shouldDisplayWarning = false
}
},
async update(key, value) {
await confirmPassword()
const url = generateOcsUrl('/apps/provisioning_api/api/v1/config/apps/{appId}/{key}', {
appId: 'core',
key,
})
try {
const { data } = await axios.post(url, {
value,
})
this.handleResponse({
status: data.ocs?.meta?.status,
})
} catch (e) {
this.handleResponse({
errorMessage: t('settings', 'Unable to update server side encryption config'),
error: e,
})
}
},
async checkDefaultModule() {
await this.update('default_encryption_module', this.defaultCheckedModule)
},
async enableEncryption() {
this.encryptionEnabled = true
await this.update('encryption_enabled', 'yes')
},
async handleResponse({ status, errorMessage, error }) {
if (status !== 'ok') {
showError(errorMessage)
logger.error(errorMessage, { error })
}
},
},
}
</script>
<style lang="scss" scoped>
.notecard.success {
--note-background: rgba(var(--color-success-rgb), 0.2);
--note-theme: var(--color-success);
}
.notecard.error {
--note-background: rgba(var(--color-error-rgb), 0.2);
--note-theme: var(--color-error);
}
.notecard.warning {
--note-background: rgba(var(--color-warning-rgb), 0.2);
--note-theme: var(--color-warning);
}
#body-settings .notecard {
color: var(--color-text-light);
background-color: var(--note-background);
border: 1px solid var(--color-border);
border-inline-start: 4px solid var(--note-theme);
border-radius: var(--border-radius);
box-shadow: rgba(43, 42, 51, 0.05) 0px 1px 2px 0px;
margin: 1rem 0;
margin-top: 1rem;
padding: 1rem;
}
li {
list-style-type: initial;
margin-inline-start: 1rem;
padding: 0.25rem 0;
}
.margin-bottom {
margin-bottom: 0.75rem;
}
</style>
|