aboutsummaryrefslogtreecommitdiffstats
path: root/apps/settings/lib
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2022-02-08 21:31:32 +0100
committerCôme Chilliet <come.chilliet@nextcloud.com>2022-02-10 10:15:01 +0100
commitb28aa52b28e4aa007b67411c8470d9d974e70915 (patch)
treeda45abdd6860511cf421aa90287979e8e7285736 /apps/settings/lib
parentbcfe99cc62b18560acbcee04e7f32591600c5a80 (diff)
downloadnextcloud-server-b28aa52b28e4aa007b67411c8470d9d974e70915.tar.gz
nextcloud-server-b28aa52b28e4aa007b67411c8470d9d974e70915.zip
Setup warning for invalid LDAP user or group UUIDs.
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/settings/lib')
-rw-r--r--apps/settings/lib/Controller/CheckSetupController.php18
-rw-r--r--apps/settings/lib/SetupChecks/LdapInvalidUuids.php69
2 files changed, 85 insertions, 2 deletions
diff --git a/apps/settings/lib/Controller/CheckSetupController.php b/apps/settings/lib/Controller/CheckSetupController.php
index 3a8b9bfd4a5..11900fad45b 100644
--- a/apps/settings/lib/Controller/CheckSetupController.php
+++ b/apps/settings/lib/Controller/CheckSetupController.php
@@ -49,7 +49,6 @@ use DirectoryIterator;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\DBAL\TransactionIsolationLevel;
-use OCP\DB\Types;
use GuzzleHttp\Exception\ClientException;
use OC;
use OC\AppFramework\Http;
@@ -62,20 +61,24 @@ use OC\IntegrityCheck\Checker;
use OC\Lock\NoopLockingProvider;
use OC\MemoryInfo;
use OCA\Settings\SetupChecks\CheckUserCertificates;
+use OCA\Settings\SetupChecks\LdapInvalidUuids;
use OCA\Settings\SetupChecks\LegacySSEKeyFormat;
use OCA\Settings\SetupChecks\PhpDefaultCharset;
use OCA\Settings\SetupChecks\PhpOutputBuffering;
use OCA\Settings\SetupChecks\SupportedDatabase;
+use OCP\App\IAppManager;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\DataDisplayResponse;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\RedirectResponse;
+use OCP\DB\Types;
use OCP\Http\Client\IClientService;
use OCP\IConfig;
use OCP\IDateTimeFormatter;
use OCP\IDBConnection;
use OCP\IL10N;
use OCP\IRequest;
+use OCP\IServerContainer;
use OCP\ITempManager;
use OCP\IURLGenerator;
use OCP\Lock\ILockingProvider;
@@ -118,6 +121,10 @@ class CheckSetupController extends Controller {
private $tempManager;
/** @var IManager */
private $manager;
+ /** @var IAppManager */
+ private $appManager;
+ /** @var IServerContainer */
+ private $serverContainer;
public function __construct($AppName,
IRequest $request,
@@ -136,7 +143,10 @@ class CheckSetupController extends Controller {
IniGetWrapper $iniGetWrapper,
IDBConnection $connection,
ITempManager $tempManager,
- IManager $manager) {
+ IManager $manager,
+ IAppManager $appManager,
+ IServerContainer $serverContainer
+ ) {
parent::__construct($AppName, $request);
$this->config = $config;
$this->clientService = $clientService;
@@ -154,6 +164,8 @@ class CheckSetupController extends Controller {
$this->connection = $connection;
$this->tempManager = $tempManager;
$this->manager = $manager;
+ $this->appManager = $appManager;
+ $this->serverContainer = $serverContainer;
}
/**
@@ -817,6 +829,7 @@ Raw output
$legacySSEKeyFormat = new LegacySSEKeyFormat($this->l10n, $this->config, $this->urlGenerator);
$checkUserCertificates = new CheckUserCertificates($this->l10n, $this->config, $this->urlGenerator);
$supportedDatabases = new SupportedDatabase($this->l10n, $this->connection);
+ $ldapInvalidUuids = new LdapInvalidUuids($this->appManager, $this->l10n, $this->serverContainer);
return new DataResponse(
[
@@ -865,6 +878,7 @@ Raw output
'isDefaultPhoneRegionSet' => $this->config->getSystemValueString('default_phone_region', '') !== '',
SupportedDatabase::class => ['pass' => $supportedDatabases->run(), 'description' => $supportedDatabases->description(), 'severity' => $supportedDatabases->severity()],
'temporaryDirectoryWritable' => $this->isTemporaryDirectoryWritable(),
+ LdapInvalidUuids::class => ['pass' => $ldapInvalidUuids->run(), 'description' => $ldapInvalidUuids->description(), 'severity' => $ldapInvalidUuids->severity()],
]
);
}
diff --git a/apps/settings/lib/SetupChecks/LdapInvalidUuids.php b/apps/settings/lib/SetupChecks/LdapInvalidUuids.php
new file mode 100644
index 00000000000..11b0105cada
--- /dev/null
+++ b/apps/settings/lib/SetupChecks/LdapInvalidUuids.php
@@ -0,0 +1,69 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @copyright Copyright (c) 2022 Arthur Schiwon <blizzz@arthur-schiwon.de>
+ *
+ * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Settings\SetupChecks;
+
+use OCA\User_LDAP\Mapping\GroupMapping;
+use OCA\User_LDAP\Mapping\UserMapping;
+use OCP\App\IAppManager;
+use OCP\IL10N;
+use OCP\IServerContainer;
+
+class LdapInvalidUuids {
+
+ /** @var IAppManager */
+ private $appManager;
+ /** @var IL10N */
+ private $l10n;
+ /** @var IServerContainer */
+ private $server;
+
+ public function __construct(IAppManager $appManager, IL10N $l10n, IServerContainer $server) {
+ $this->appManager = $appManager;
+ $this->l10n = $l10n;
+ $this->server = $server;
+ }
+
+ public function description(): string {
+ return $this->l10n->t('Invalid UUIDs of LDAP users or groups have been found. Please review your "Override UUID detection" settings in the Expert part of the LDAP configuration and use "occ ldap:update-uuid" to update them.');
+ }
+
+ public function severity(): string {
+ return 'warning';
+ }
+
+ public function run(): bool {
+ if (!$this->appManager->isEnabledForUser('user_ldap')) {
+ return true;
+ }
+ /** @var UserMapping $userMapping */
+ $userMapping = $this->server->get(UserMapping::class);
+ /** @var GroupMapping $groupMapping */
+ $groupMapping = $this->server->get(GroupMapping::class);
+ return count($userMapping->getList(0, 1, true)) === 0
+ && count($groupMapping->getList(0, 1, true)) === 0;
+ }
+}