Skip to content

Commit 5a7b145

Browse files
authored
Merge pull request #42829 from nextcloud/enh/migrate-webauthn-modules-setupcheck
2 parents 7f1b980 + c43144f commit 5a7b145

File tree

5 files changed

+21
-75
lines changed

5 files changed

+21
-75
lines changed

apps/settings/lib/Controller/CheckSetupController.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -202,16 +202,6 @@ private function isTemporaryDirectoryWritable(): bool {
202202
return false;
203203
}
204204

205-
protected function areWebauthnExtensionsEnabled(): bool {
206-
if (!extension_loaded('bcmath')) {
207-
return false;
208-
}
209-
if (!extension_loaded('gmp')) {
210-
return false;
211-
}
212-
return true;
213-
}
214-
215205
protected function isMysqlUsedWithoutUTF8MB4(): bool {
216206
return ($this->config->getSystemValue('dbtype', 'sqlite') === 'mysql') && ($this->config->getSystemValue('mysql.utf8mb4', false) === false);
217207
}
@@ -261,7 +251,6 @@ public function check() {
261251
[
262252
'isFairUseOfFreePushService' => $this->isFairUseOfFreePushService(),
263253
'reverseProxyDocs' => $this->urlGenerator->linkToDocs('admin-reverse-proxy'),
264-
'areWebauthnExtensionsEnabled' => $this->areWebauthnExtensionsEnabled(),
265254
'isMysqlUsedWithoutUTF8MB4' => $this->isMysqlUsedWithoutUTF8MB4(),
266255
'isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed' => $this->isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed(),
267256
'reverseProxyGeneratedURL' => $this->urlGenerator->getAbsoluteURL('index.php'),

apps/settings/lib/SetupChecks/PhpModules.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ class PhpModules implements ISetupCheck {
4949
'zlib',
5050
];
5151
protected const RECOMMENDED_MODULES = [
52+
'bcmath',
5253
'exif',
54+
'gmp',
5355
'intl',
5456
'sodium',
5557
'sysvsem',
@@ -69,6 +71,17 @@ public function getCategory(): string {
6971
return 'php';
7072
}
7173

74+
protected function getRecommendedModuleDescription(string $module): string {
75+
return match($module) {
76+
'intl' => $this->l10n->t('increases language translation performance and fixes sorting of non-ASCII characters'),
77+
'sodium' => $this->l10n->t('for Argon2 for password hashing'),
78+
'bcmath' => $this->l10n->t('for WebAuthn passwordless login'),
79+
'gmp' => $this->l10n->t('for WebAuthn passwordless login, and SFTP storage'),
80+
'exif' => $this->l10n->t('for picture rotation in server and metadata extraction in the Photos app'),
81+
default => '',
82+
};
83+
}
84+
7285
public function run(): SetupResult {
7386
$missingRecommendedModules = $this->getMissingModules(self::RECOMMENDED_MODULES);
7487
$missingRequiredModules = $this->getMissingModules(self::REQUIRED_MODULES);
@@ -78,8 +91,15 @@ public function run(): SetupResult {
7891
$this->urlGenerator->linkToDocs('admin-php-modules')
7992
);
8093
} elseif (!empty($missingRecommendedModules)) {
94+
$moduleList = implode(
95+
"\n",
96+
array_map(
97+
fn (string $module) => '- '.$module.' '.$this->getRecommendedModuleDescription($module),
98+
$missingRecommendedModules
99+
)
100+
);
81101
return SetupResult::info(
82-
$this->l10n->t('This instance is missing some recommended PHP modules. For improved performance and better compatibility it is highly recommended to install them: %s.', implode(', ', $missingRecommendedModules)),
102+
$this->l10n->t("This instance is missing some recommended PHP modules. For improved performance and better compatibility it is highly recommended to install them:\n%s", $moduleList),
83103
$this->urlGenerator->linkToDocs('admin-php-modules')
84104
);
85105
} else {

apps/settings/tests/Controller/CheckSetupControllerTest.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ protected function setUp(): void {
118118
'getCurlVersion',
119119
'isPhpOutdated',
120120
'isPHPMailerUsed',
121-
'areWebauthnExtensionsEnabled',
122121
'isMysqlUsedWithoutUTF8MB4',
123122
'isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed',
124123
])->getMock();
@@ -143,11 +142,6 @@ public function testCheck() {
143142
$this->request->expects($this->never())
144143
->method('getHeader');
145144

146-
$this->checkSetupController
147-
->expects($this->once())
148-
->method('areWebauthnExtensionsEnabled')
149-
->willReturn(false);
150-
151145
$this->checkSetupController
152146
->expects($this->once())
153147
->method('isMysqlUsedWithoutUTF8MB4')
@@ -192,7 +186,6 @@ public function testCheck() {
192186
$expected = new DataResponse(
193187
[
194188
'reverseProxyDocs' => 'reverse-proxy-doc-link',
195-
'areWebauthnExtensionsEnabled' => false,
196189
'isMysqlUsedWithoutUTF8MB4' => false,
197190
'isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed' => true,
198191
'reverseProxyGeneratedURL' => 'https://server/index.php',

core/js/setupchecks.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -188,15 +188,6 @@
188188
type: OC.SetupChecks.MESSAGE_TYPE_ERROR
189189
});
190190
}
191-
if (!data.areWebauthnExtensionsEnabled) {
192-
messages.push({
193-
msg: t(
194-
'core',
195-
'The PHP modules "gmp" and/or "bcmath" are not enabled. If you use WebAuthn passwordless authentication, these modules are required.'
196-
),
197-
type: OC.SetupChecks.MESSAGE_TYPE_INFO
198-
})
199-
}
200191

201192
if (data.isMysqlUsedWithoutUTF8MB4) {
202193
messages.push({

core/js/tests/specs/setupchecksSpec.js

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,6 @@ describe('OC.SetupChecks tests', function() {
224224
},
225225
JSON.stringify({
226226
isFairUseOfFreePushService: true,
227-
areWebauthnExtensionsEnabled: true,
228227
isMysqlUsedWithoutUTF8MB4: false,
229228
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
230229
reverseProxyGeneratedURL: 'https://server',
@@ -262,7 +261,6 @@ describe('OC.SetupChecks tests', function() {
262261
},
263262
JSON.stringify({
264263
isFairUseOfFreePushService: true,
265-
areWebauthnExtensionsEnabled: true,
266264
isMysqlUsedWithoutUTF8MB4: false,
267265
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
268266
reverseProxyGeneratedURL: 'https://server',
@@ -300,7 +298,6 @@ describe('OC.SetupChecks tests', function() {
300298
},
301299
JSON.stringify({
302300
isFairUseOfFreePushService: true,
303-
areWebauthnExtensionsEnabled: true,
304301
isMysqlUsedWithoutUTF8MB4: false,
305302
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
306303
reverseProxyGeneratedURL: 'https://server',
@@ -339,7 +336,6 @@ describe('OC.SetupChecks tests', function() {
339336
JSON.stringify({
340337
isFairUseOfFreePushService: true,
341338
reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html',
342-
areWebauthnExtensionsEnabled: true,
343339
isMysqlUsedWithoutUTF8MB4: false,
344340
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
345341
reverseProxyGeneratedURL: 'https://server',
@@ -407,7 +403,6 @@ describe('OC.SetupChecks tests', function() {
407403
},
408404
JSON.stringify({
409405
isFairUseOfFreePushService: true,
410-
areWebauthnExtensionsEnabled: true,
411406
isMysqlUsedWithoutUTF8MB4: false,
412407
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
413408
reverseProxyGeneratedURL: 'https://server',
@@ -450,7 +445,6 @@ describe('OC.SetupChecks tests', function() {
450445
},
451446
JSON.stringify({
452447
isFairUseOfFreePushService: true,
453-
areWebauthnExtensionsEnabled: true,
454448
isMysqlUsedWithoutUTF8MB4: true,
455449
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
456450
reverseProxyGeneratedURL: 'https://server',
@@ -490,7 +484,6 @@ describe('OC.SetupChecks tests', function() {
490484
},
491485
JSON.stringify({
492486
isFairUseOfFreePushService: true,
493-
areWebauthnExtensionsEnabled: true,
494487
isMysqlUsedWithoutUTF8MB4: false,
495488
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
496489
reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html',
@@ -527,7 +520,6 @@ describe('OC.SetupChecks tests', function() {
527520
},
528521
JSON.stringify({
529522
isFairUseOfFreePushService: true,
530-
areWebauthnExtensionsEnabled: true,
531523
isMysqlUsedWithoutUTF8MB4: false,
532524
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
533525
reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html',
@@ -561,7 +553,6 @@ describe('OC.SetupChecks tests', function() {
561553
},
562554
JSON.stringify({
563555
isFairUseOfFreePushService: true,
564-
areWebauthnExtensionsEnabled: true,
565556
isMysqlUsedWithoutUTF8MB4: false,
566557
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: false,
567558
reverseProxyGeneratedURL: 'https://server',
@@ -587,42 +578,6 @@ describe('OC.SetupChecks tests', function() {
587578
});
588579
});
589580

590-
it('should return an error if gmp or bcmath are not enabled', function(done) {
591-
var async = OC.SetupChecks.checkSetup();
592-
593-
suite.server.requests[0].respond(
594-
200,
595-
{
596-
'Content-Type': 'application/json',
597-
},
598-
JSON.stringify({
599-
isFairUseOfFreePushService: true,
600-
areWebauthnExtensionsEnabled: false,
601-
isMysqlUsedWithoutUTF8MB4: false,
602-
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
603-
reverseProxyGeneratedURL: 'https://server',
604-
temporaryDirectoryWritable: true,
605-
generic: {
606-
network: {
607-
"Internet connectivity": {
608-
severity: "success",
609-
description: null,
610-
linkToDoc: null
611-
}
612-
},
613-
},
614-
})
615-
);
616-
617-
async.done(function( data, s, x ){
618-
expect(data).toEqual([{
619-
msg: 'The PHP modules "gmp" and/or "bcmath" are not enabled. If you use WebAuthn passwordless authentication, these modules are required.',
620-
type: OC.SetupChecks.MESSAGE_TYPE_INFO
621-
}]);
622-
done();
623-
});
624-
});
625-
626581
it('should return an info if there is no default phone region', function(done) {
627582
var async = OC.SetupChecks.checkSetup();
628583

@@ -633,7 +588,6 @@ describe('OC.SetupChecks tests', function() {
633588
},
634589
JSON.stringify({
635590
isFairUseOfFreePushService: true,
636-
areWebauthnExtensionsEnabled: true,
637591
isMysqlUsedWithoutUTF8MB4: false,
638592
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
639593
reverseProxyGeneratedURL: 'https://server',
@@ -676,7 +630,6 @@ describe('OC.SetupChecks tests', function() {
676630
},
677631
JSON.stringify({
678632
isFairUseOfFreePushService: true,
679-
areWebauthnExtensionsEnabled: true,
680633
isMysqlUsedWithoutUTF8MB4: false,
681634
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
682635
reverseProxyGeneratedURL: 'https://server',

0 commit comments

Comments
 (0)