diff options
author | Côme Chilliet <91878298+come-nc@users.noreply.github.com> | 2022-10-25 11:16:01 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-25 11:16:01 +0200 |
commit | 91392c08d6d69d74431588a9f38cbf15ef41c937 (patch) | |
tree | 7f7c6a7bc04e1dc5592582635abb91698dfd7dbc /lib | |
parent | e3aac7d573961933b185c87d9600580b21423a42 (diff) | |
parent | 8b7f6a80c306b7f6defba376ec713a94cbbbe1bf (diff) | |
download | nextcloud-server-91392c08d6d69d74431588a9f38cbf15ef41c937.tar.gz nextcloud-server-91392c08d6d69d74431588a9f38cbf15ef41c937.zip |
Merge pull request #34774 from nextcloud/fix/fair-use-ldap-fix
Expose mapped user count from LDAP and use that for user limit check
Diffstat (limited to 'lib')
-rw-r--r-- | lib/composer/composer/autoload_classmap.php | 1 | ||||
-rw-r--r-- | lib/composer/composer/autoload_static.php | 1 | ||||
-rw-r--r-- | lib/private/Support/Subscription/Registry.php | 8 | ||||
-rw-r--r-- | lib/public/User/Backend/ICountMappedUsersBackend.php | 39 |
4 files changed, 46 insertions, 3 deletions
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 31d682c13e0..a4468d54b90 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -597,6 +597,7 @@ return array( 'OCP\\UserStatus\\IUserStatus' => $baseDir . '/lib/public/UserStatus/IUserStatus.php', 'OCP\\User\\Backend\\ABackend' => $baseDir . '/lib/public/User/Backend/ABackend.php', 'OCP\\User\\Backend\\ICheckPasswordBackend' => $baseDir . '/lib/public/User/Backend/ICheckPasswordBackend.php', + 'OCP\\User\\Backend\\ICountMappedUsersBackend' => $baseDir . '/lib/public/User/Backend/ICountMappedUsersBackend.php', 'OCP\\User\\Backend\\ICountUsersBackend' => $baseDir . '/lib/public/User/Backend/ICountUsersBackend.php', 'OCP\\User\\Backend\\ICreateUserBackend' => $baseDir . '/lib/public/User/Backend/ICreateUserBackend.php', 'OCP\\User\\Backend\\ICustomLogout' => $baseDir . '/lib/public/User/Backend/ICustomLogout.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index bbd57cf1895..13da8f91274 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -630,6 +630,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OCP\\UserStatus\\IUserStatus' => __DIR__ . '/../../..' . '/lib/public/UserStatus/IUserStatus.php', 'OCP\\User\\Backend\\ABackend' => __DIR__ . '/../../..' . '/lib/public/User/Backend/ABackend.php', 'OCP\\User\\Backend\\ICheckPasswordBackend' => __DIR__ . '/../../..' . '/lib/public/User/Backend/ICheckPasswordBackend.php', + 'OCP\\User\\Backend\\ICountMappedUsersBackend' => __DIR__ . '/../../..' . '/lib/public/User/Backend/ICountMappedUsersBackend.php', 'OCP\\User\\Backend\\ICountUsersBackend' => __DIR__ . '/../../..' . '/lib/public/User/Backend/ICountUsersBackend.php', 'OCP\\User\\Backend\\ICreateUserBackend' => __DIR__ . '/../../..' . '/lib/public/User/Backend/ICreateUserBackend.php', 'OCP\\User\\Backend\\ICustomLogout' => __DIR__ . '/../../..' . '/lib/public/User/Backend/ICustomLogout.php', diff --git a/lib/private/Support/Subscription/Registry.php b/lib/private/Support/Subscription/Registry.php index 87070e7a0dc..7aafa539a0b 100644 --- a/lib/private/Support/Subscription/Registry.php +++ b/lib/private/Support/Subscription/Registry.php @@ -34,15 +34,15 @@ use OCP\IGroupManager; use OCP\IServerContainer; use OCP\IUserManager; use OCP\Notification\IManager; -use OCP\User\Backend\ICountUsersBackend; use OCP\Support\Subscription\Exception\AlreadyRegisteredException; use OCP\Support\Subscription\IRegistry; use OCP\Support\Subscription\ISubscription; use OCP\Support\Subscription\ISupportedApps; +use OCP\User\Backend\ICountMappedUsersBackend; +use OCP\User\Backend\ICountUsersBackend; use Psr\Log\LoggerInterface; class Registry implements IRegistry { - /** @var ISubscription */ private $subscription = null; @@ -189,7 +189,9 @@ class Registry implements IRegistry { $userCount = 0; $backends = $this->userManager->getBackends(); foreach ($backends as $backend) { - if ($backend->implementsActions(Backend::COUNT_USERS)) { + if ($backend instanceof ICountMappedUsersBackend) { + $userCount += $backend->countMappedUsers(); + } elseif ($backend->implementsActions(Backend::COUNT_USERS)) { /** @var ICountUsersBackend $backend */ $backendUsers = $backend->countUsers(); if ($backendUsers !== false) { diff --git a/lib/public/User/Backend/ICountMappedUsersBackend.php b/lib/public/User/Backend/ICountMappedUsersBackend.php new file mode 100644 index 00000000000..bf8770d484f --- /dev/null +++ b/lib/public/User/Backend/ICountMappedUsersBackend.php @@ -0,0 +1,39 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright Copyright (c) 2022 Côme Chilliet <come.chilliet@nextcloud.com> + * + * @author Côme Chilliet <come.chilliet@nextcloud.com> + * + * @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 <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\User\Backend; + +/** + * @since 24.0.7 + */ +interface ICountMappedUsersBackend { + /** + * @since 24.0.7 + * + * @return int The number of users already mapped to a Nextcloud account + */ + public function countMappedUsers(): int; +} |