mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
This commit switches the default signature algorithm to ecdsa-p256-sha256 instead of Ed25519. This allows us to make sodium optional again, and we only pull it in to use it for verifying incomming signatures. If sodium is not installed, we throw on Ed25519 signatures instead. At least it is easy for most people to make their Nextcloud install fully RFC compliant by installing sodium. I also renamed all the Ed25519 function names to be more precis, using Jwks for the JSON Web Keys, and RFC9421 for the http-signature code, where it is needed to distinguish from draft-cavage signatures. Signed-off-by: Micke Nordin <kano@sunet.se>
106 lines
2.9 KiB
PHP
106 lines
2.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
namespace OCA\Settings\SetupChecks;
|
|
|
|
use OCP\IL10N;
|
|
use OCP\IURLGenerator;
|
|
use OCP\SetupCheck\ISetupCheck;
|
|
use OCP\SetupCheck\SetupResult;
|
|
|
|
class PhpModules implements ISetupCheck {
|
|
protected const REQUIRED_MODULES = [
|
|
'ctype',
|
|
'curl',
|
|
'dom',
|
|
'fileinfo',
|
|
'gd',
|
|
'mbstring',
|
|
'openssl',
|
|
'posix',
|
|
'session',
|
|
'xml',
|
|
'xmlreader',
|
|
'xmlwriter',
|
|
'zip',
|
|
'zlib',
|
|
];
|
|
protected const RECOMMENDED_MODULES = [
|
|
'apcu',
|
|
'exif',
|
|
'gmp',
|
|
'intl',
|
|
'sodium',
|
|
'sysvsem',
|
|
];
|
|
|
|
public function __construct(
|
|
private IL10N $l10n,
|
|
private IURLGenerator $urlGenerator,
|
|
) {
|
|
}
|
|
|
|
#[\Override]
|
|
public function getName(): string {
|
|
return $this->l10n->t('PHP modules');
|
|
}
|
|
|
|
#[\Override]
|
|
public function getCategory(): string {
|
|
return 'php';
|
|
}
|
|
|
|
protected function getRecommendedModuleDescription(string $module): string {
|
|
return match($module) {
|
|
'intl' => $this->l10n->t('increases language translation performance and fixes sorting of non-ASCII characters'),
|
|
'sodium' => $this->l10n->t('for Argon2 for password hashing and Ed25519 signature verification for RFC 9421 http message signatures'),
|
|
'gmp' => $this->l10n->t('required for SFTP storage and recommended for WebAuthn performance'),
|
|
'exif' => $this->l10n->t('for picture rotation in server and metadata extraction in the Photos app'),
|
|
default => '',
|
|
};
|
|
}
|
|
|
|
#[\Override]
|
|
public function run(): SetupResult {
|
|
$missingRecommendedModules = $this->getMissingModules(self::RECOMMENDED_MODULES);
|
|
$missingRequiredModules = $this->getMissingModules(self::REQUIRED_MODULES);
|
|
if (!empty($missingRequiredModules)) {
|
|
return SetupResult::error(
|
|
$this->l10n->t('This instance is missing some required PHP modules. It is required to install them: %s.', implode(', ', $missingRequiredModules)),
|
|
$this->urlGenerator->linkToDocs('admin-php-modules')
|
|
);
|
|
} elseif (!empty($missingRecommendedModules)) {
|
|
$moduleList = implode(
|
|
"\n",
|
|
array_map(
|
|
fn (string $module) => '- ' . $module . ' ' . $this->getRecommendedModuleDescription($module),
|
|
$missingRecommendedModules
|
|
)
|
|
);
|
|
return SetupResult::info(
|
|
$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),
|
|
$this->urlGenerator->linkToDocs('admin-php-modules')
|
|
);
|
|
} else {
|
|
return SetupResult::success();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Checks for potential PHP modules that would improve the instance
|
|
*
|
|
* @param string[] $modules modules to test
|
|
* @return string[] A list of PHP modules which are missing
|
|
*/
|
|
protected function getMissingModules(array $modules): array {
|
|
return array_values(array_filter(
|
|
$modules,
|
|
fn (string $module) => !extension_loaded($module),
|
|
));
|
|
}
|
|
}
|