Skip to content

Commit 309c85d

Browse files
MorrisJobkerullzer
authored andcommitted
Add setup check that links to the migration documentation
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
1 parent f3f3ea1 commit 309c85d

File tree

5 files changed

+76
-2
lines changed

5 files changed

+76
-2
lines changed

apps/settings/composer/composer/autoload_classmap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
'OCA\\Settings\\Settings\\Personal\\Security\\TwoFactor' => $baseDir . '/../lib/Settings/Personal/Security/TwoFactor.php',
5555
'OCA\\Settings\\Settings\\Personal\\Security\\WebAuthn' => $baseDir . '/../lib/Settings/Personal/Security/WebAuthn.php',
5656
'OCA\\Settings\\Settings\\Personal\\ServerDevNotice' => $baseDir . '/../lib/Settings/Personal/ServerDevNotice.php',
57+
'OCA\\Settings\\SetupChecks\\LegacySSEKeyFormat' => $baseDir . '/../lib/SetupChecks/LegacySSEKeyFormat.php',
5758
'OCA\\Settings\\SetupChecks\\PhpDefaultCharset' => $baseDir . '/../lib/SetupChecks/PhpDefaultCharset.php',
5859
'OCA\\Settings\\SetupChecks\\PhpOutputBuffering' => $baseDir . '/../lib/SetupChecks/PhpOutputBuffering.php',
5960
);

apps/settings/composer/composer/autoload_static.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class ComposerStaticInitSettings
6969
'OCA\\Settings\\Settings\\Personal\\Security\\TwoFactor' => __DIR__ . '/..' . '/../lib/Settings/Personal/Security/TwoFactor.php',
7070
'OCA\\Settings\\Settings\\Personal\\Security\\WebAuthn' => __DIR__ . '/..' . '/../lib/Settings/Personal/Security/WebAuthn.php',
7171
'OCA\\Settings\\Settings\\Personal\\ServerDevNotice' => __DIR__ . '/..' . '/../lib/Settings/Personal/ServerDevNotice.php',
72+
'OCA\\Settings\\SetupChecks\\LegacySSEKeyFormat' => __DIR__ . '/..' . '/../lib/SetupChecks/LegacySSEKeyFormat.php',
7273
'OCA\\Settings\\SetupChecks\\PhpDefaultCharset' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpDefaultCharset.php',
7374
'OCA\\Settings\\SetupChecks\\PhpOutputBuffering' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpOutputBuffering.php',
7475
);

apps/settings/lib/Controller/CheckSetupController.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
use OC\IntegrityCheck\Checker;
5454
use OC\Lock\NoopLockingProvider;
5555
use OC\MemoryInfo;
56+
use OCA\Settings\SetupChecks\LegacySSEKeyFormat;
5657
use OCA\Settings\SetupChecks\PhpDefaultCharset;
5758
use OCA\Settings\SetupChecks\PhpOutputBuffering;
5859
use OCP\AppFramework\Controller;
@@ -687,6 +688,7 @@ protected function isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed(): bool {
687688
public function check() {
688689
$phpDefaultCharset = new PhpDefaultCharset();
689690
$phpOutputBuffering = new PhpOutputBuffering();
691+
$legacySSEKeyFormat = new LegacySSEKeyFormat($this->l10n, $this->config, $this->urlGenerator);
690692
return new DataResponse(
691693
[
692694
'isGetenvServerWorking' => !empty(getenv('PATH')),
@@ -729,6 +731,7 @@ public function check() {
729731
'reverseProxyGeneratedURL' => $this->urlGenerator->getAbsoluteURL('index.php'),
730732
PhpDefaultCharset::class => ['pass' => $phpDefaultCharset->run(), 'description' => $phpDefaultCharset->description(), 'severity' => $phpDefaultCharset->severity()],
731733
PhpOutputBuffering::class => ['pass' => $phpOutputBuffering->run(), 'description' => $phpOutputBuffering->description(), 'severity' => $phpOutputBuffering->severity()],
734+
LegacySSEKeyFormat::class => ['pass' => $legacySSEKeyFormat->run(), 'description' => $legacySSEKeyFormat->description(), 'severity' => $legacySSEKeyFormat->severity(), 'linkToDocumentation' => $legacySSEKeyFormat->linkToDocumentation()],
732735
]
733736
);
734737
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* @copyright Copyright (c) 2020 Morris Jobke <hey@morrisjobke.de>
7+
*
8+
* @author DMorris Jobke <hey@morrisjobke.de>
9+
*
10+
* @license GNU AGPL version 3 or any later version
11+
*
12+
* This program is free software: you can redistribute it and/or modify
13+
* it under the terms of the GNU Affero General Public License as
14+
* published by the Free Software Foundation, either version 3 of the
15+
* License, or (at your option) any later version.
16+
*
17+
* This program is distributed in the hope that it will be useful,
18+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+
* GNU Affero General Public License for more details.
21+
*
22+
* You should have received a copy of the GNU Affero General Public License
23+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
24+
*
25+
* SPDX-License-Identifier: AGPL-3.0-or-later
26+
*/
27+
28+
namespace OCA\Settings\SetupChecks;
29+
30+
use OCP\IConfig;
31+
use OCP\IL10N;
32+
use OCP\IURLGenerator;
33+
34+
class LegacySSEKeyFormat {
35+
/** @var IL10N */
36+
private $l10n;
37+
/** @var IConfig */
38+
private $config;
39+
/** @var IURLGenerator */
40+
private $urlGenerator;
41+
42+
public function __construct(IL10N $l10n, IConfig $config, IURLGenerator $urlGenerator) {
43+
$this->l10n = $l10n;
44+
$this->config = $config;
45+
$this->urlGenerator = $urlGenerator;
46+
}
47+
48+
public function description(): string {
49+
return $this->l10n->t('The old server-side-encryption format is used. We recommend to migrate to the new format.');
50+
}
51+
52+
public function severity(): string {
53+
return 'warning';
54+
}
55+
56+
public function run(): bool {
57+
return $this->config->getSystemValueBool('encryption.legacy_format_support', false) === false;
58+
}
59+
60+
public function linkToDocumentation(): string {
61+
return $this->urlGenerator->linkToDocs('admin-sse-legacy-format');
62+
}
63+
}

core/js/setupchecks.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,7 @@
490490

491491
OC.SetupChecks.addGenericSetupCheck(data, 'OCA\\Settings\\SetupChecks\\PhpDefaultCharset', messages)
492492
OC.SetupChecks.addGenericSetupCheck(data, 'OCA\\Settings\\SetupChecks\\PhpOutputBuffering', messages)
493+
OC.SetupChecks.addGenericSetupCheck(data, 'OCA\\Settings\\SetupChecks\\LegacySSEKeyFormat', messages)
493494

494495
} else {
495496
messages.push({
@@ -509,7 +510,7 @@
509510
},
510511

511512
addGenericSetupCheck: function(data, check, messages) {
512-
var setupCheck = data[check] || { pass: true, description: '', severity: 'info'}
513+
var setupCheck = data[check] || { pass: true, description: '', severity: 'info', linkToDocumentation: null}
513514

514515
var type = OC.SetupChecks.MESSAGE_TYPE_INFO
515516
if (setupCheck.severity === 'warning') {
@@ -518,9 +519,14 @@
518519
type = OC.SetupChecks.MESSAGE_TYPE_ERROR
519520
}
520521

522+
var message = setupCheck.description;
523+
if (setupCheck.linkToDocumentation) {
524+
message += ' ' + t('core', 'For more details see the <a target="_blank" rel="noreferrer noopener" href="{docLink}">documentation</a>.', {docLink: setupCheck.linkToDocumentation});
525+
}
526+
521527
if (!setupCheck.pass) {
522528
messages.push({
523-
msg: setupCheck.description,
529+
msg: message,
524530
type: type,
525531
})
526532
}

0 commit comments

Comments
 (0)