aboutsummaryrefslogtreecommitdiffstats
path: root/lib/public/User/Backend
diff options
context:
space:
mode:
Diffstat (limited to 'lib/public/User/Backend')
-rw-r--r--lib/public/User/Backend/ABackend.php56
-rw-r--r--lib/public/User/Backend/ICheckPasswordBackend.php23
-rw-r--r--lib/public/User/Backend/ICountMappedUsersBackend.php22
-rw-r--r--lib/public/User/Backend/ICountUsersBackend.php22
-rw-r--r--lib/public/User/Backend/ICreateUserBackend.php23
-rw-r--r--lib/public/User/Backend/ICustomLogout.php26
-rw-r--r--lib/public/User/Backend/IGetDisplayNameBackend.php22
-rw-r--r--lib/public/User/Backend/IGetHomeBackend.php22
-rw-r--r--lib/public/User/Backend/IGetRealUIDBackend.php27
-rw-r--r--lib/public/User/Backend/ILimitAwareCountUsersBackend.php23
-rw-r--r--lib/public/User/Backend/IPasswordConfirmationBackend.php19
-rw-r--r--lib/public/User/Backend/IPasswordHashBackend.php30
-rw-r--r--lib/public/User/Backend/IProvideAvatarBackend.php22
-rw-r--r--lib/public/User/Backend/IProvideEnabledStateBackend.php40
-rw-r--r--lib/public/User/Backend/ISearchKnownUsersBackend.php24
-rw-r--r--lib/public/User/Backend/ISetDisplayNameBackend.php26
-rw-r--r--lib/public/User/Backend/ISetPasswordBackend.php23
17 files changed, 450 insertions, 0 deletions
diff --git a/lib/public/User/Backend/ABackend.php b/lib/public/User/Backend/ABackend.php
new file mode 100644
index 00000000000..2fca83e3be8
--- /dev/null
+++ b/lib/public/User/Backend/ABackend.php
@@ -0,0 +1,56 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\User\Backend;
+
+use OC\User\Backend;
+use OCP\IUserBackend;
+use OCP\UserInterface;
+
+/**
+ * @since 14.0.0
+ */
+abstract class ABackend implements IUserBackend, UserInterface {
+ /**
+ * @deprecated 14.0.0
+ * @since 14.0.0
+ *
+ * @param int $actions The action to check for
+ * @return bool
+ */
+ public function implementsActions($actions): bool {
+ $implements = 0;
+
+ if ($this instanceof ICreateUserBackend) {
+ $implements |= Backend::CREATE_USER;
+ }
+ if ($this instanceof ISetPasswordBackend) {
+ $implements |= Backend::SET_PASSWORD;
+ }
+ if ($this instanceof ICheckPasswordBackend) {
+ $implements |= Backend::CHECK_PASSWORD;
+ }
+ if ($this instanceof IGetHomeBackend) {
+ $implements |= Backend::GET_HOME;
+ }
+ if ($this instanceof IGetDisplayNameBackend) {
+ $implements |= Backend::GET_DISPLAYNAME;
+ }
+ if ($this instanceof ISetDisplayNameBackend) {
+ $implements |= Backend::SET_DISPLAYNAME;
+ }
+ if ($this instanceof IProvideAvatarBackend) {
+ $implements |= Backend::PROVIDE_AVATAR;
+ }
+ if ($this instanceof ICountUsersBackend) {
+ $implements |= Backend::COUNT_USERS;
+ }
+
+ return (bool)($actions & $implements);
+ }
+}
diff --git a/lib/public/User/Backend/ICheckPasswordBackend.php b/lib/public/User/Backend/ICheckPasswordBackend.php
new file mode 100644
index 00000000000..db5d7d08cb5
--- /dev/null
+++ b/lib/public/User/Backend/ICheckPasswordBackend.php
@@ -0,0 +1,23 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\User\Backend;
+
+/**
+ * @since 14.0.0
+ */
+interface ICheckPasswordBackend {
+ /**
+ * @since 14.0.0
+ *
+ * @param string $loginName The loginname
+ * @param string $password The password
+ * @return string|false The uid on success false on failure
+ */
+ public function checkPassword(string $loginName, string $password);
+}
diff --git a/lib/public/User/Backend/ICountMappedUsersBackend.php b/lib/public/User/Backend/ICountMappedUsersBackend.php
new file mode 100644
index 00000000000..39f84f74f4a
--- /dev/null
+++ b/lib/public/User/Backend/ICountMappedUsersBackend.php
@@ -0,0 +1,22 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+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;
+}
diff --git a/lib/public/User/Backend/ICountUsersBackend.php b/lib/public/User/Backend/ICountUsersBackend.php
new file mode 100644
index 00000000000..194cf465cbe
--- /dev/null
+++ b/lib/public/User/Backend/ICountUsersBackend.php
@@ -0,0 +1,22 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\User\Backend;
+
+/**
+ * @since 14.0.0
+ * @deprecated 31.0.0 use and implement ILimitAwareCountUsersBackend instead.
+ */
+interface ICountUsersBackend {
+ /**
+ * @since 14.0.0
+ *
+ * @return int|false The number of users on success false on failure
+ */
+ public function countUsers();
+}
diff --git a/lib/public/User/Backend/ICreateUserBackend.php b/lib/public/User/Backend/ICreateUserBackend.php
new file mode 100644
index 00000000000..f273c6d7f8b
--- /dev/null
+++ b/lib/public/User/Backend/ICreateUserBackend.php
@@ -0,0 +1,23 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\User\Backend;
+
+/**
+ * @since 14.0.0
+ */
+interface ICreateUserBackend {
+ /**
+ * @since 14.0.0
+ *
+ * @param string $uid The username of the user to create
+ * @param string $password The password of the new user
+ * @return bool
+ */
+ public function createUser(string $uid, string $password): bool;
+}
diff --git a/lib/public/User/Backend/ICustomLogout.php b/lib/public/User/Backend/ICustomLogout.php
new file mode 100644
index 00000000000..6d0f03387ce
--- /dev/null
+++ b/lib/public/User/Backend/ICustomLogout.php
@@ -0,0 +1,26 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\User\Backend;
+
+/**
+ * @since 20.0.0
+ *
+ * Allow backends to signal that they handle logout. For example
+ * SSO providers that also have a SSO logout url
+ */
+interface ICustomLogout {
+ /**
+ * @since 20.0.0
+ *
+ * The url to redirect to for logout
+ *
+ * @return string
+ */
+ public function getLogoutUrl(): string;
+}
diff --git a/lib/public/User/Backend/IGetDisplayNameBackend.php b/lib/public/User/Backend/IGetDisplayNameBackend.php
new file mode 100644
index 00000000000..a9c92b8b146
--- /dev/null
+++ b/lib/public/User/Backend/IGetDisplayNameBackend.php
@@ -0,0 +1,22 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\User\Backend;
+
+/**
+ * @since 14.0.0
+ */
+interface IGetDisplayNameBackend {
+ /**
+ * @since 14.0.0
+ *
+ * @param string $uid user ID of the user
+ * @return string display name
+ */
+ public function getDisplayName($uid): string;
+}
diff --git a/lib/public/User/Backend/IGetHomeBackend.php b/lib/public/User/Backend/IGetHomeBackend.php
new file mode 100644
index 00000000000..f280f4c9370
--- /dev/null
+++ b/lib/public/User/Backend/IGetHomeBackend.php
@@ -0,0 +1,22 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\User\Backend;
+
+/**
+ * @since 14.0.0
+ */
+interface IGetHomeBackend {
+ /**
+ * @since 14.0.0
+ *
+ * @param string $uid the username
+ * @return string|bool Datadir on success false on failure
+ */
+ public function getHome(string $uid);
+}
diff --git a/lib/public/User/Backend/IGetRealUIDBackend.php b/lib/public/User/Backend/IGetRealUIDBackend.php
new file mode 100644
index 00000000000..8041043f7d5
--- /dev/null
+++ b/lib/public/User/Backend/IGetRealUIDBackend.php
@@ -0,0 +1,27 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\User\Backend;
+
+/**
+ * @since 17.0.0
+ */
+interface IGetRealUIDBackend {
+ /**
+ * Some backends accept different UIDs than what is the internal UID to be used.
+ * For example the database backend accepts different cased UIDs in all the functions
+ * but the internal UID that is to be used should be correctly cased.
+ *
+ * This little function makes sure that the used UID will be correct when using the user object
+ *
+ * @since 17.0.0
+ * @param string $uid
+ * @return string
+ */
+ public function getRealUID(string $uid): string;
+}
diff --git a/lib/public/User/Backend/ILimitAwareCountUsersBackend.php b/lib/public/User/Backend/ILimitAwareCountUsersBackend.php
new file mode 100644
index 00000000000..a59c0bd8e04
--- /dev/null
+++ b/lib/public/User/Backend/ILimitAwareCountUsersBackend.php
@@ -0,0 +1,23 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace OCP\User\Backend;
+
+/**
+ * @since 31.0.0
+ */
+interface ILimitAwareCountUsersBackend extends ICountUsersBackend {
+ /**
+ * @since 31.0.0
+ *
+ * @param int $limit Limit to stop counting users if there are more than $limit. 0 to disable limiting.
+ * @return int|false The number of users (may be limited to $limit) on success false on failure
+ */
+ public function countUsers(int $limit = 0): int|false;
+}
diff --git a/lib/public/User/Backend/IPasswordConfirmationBackend.php b/lib/public/User/Backend/IPasswordConfirmationBackend.php
new file mode 100644
index 00000000000..856f65ada00
--- /dev/null
+++ b/lib/public/User/Backend/IPasswordConfirmationBackend.php
@@ -0,0 +1,19 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\User\Backend;
+
+/**
+ * @since 15.0.0
+ */
+interface IPasswordConfirmationBackend {
+ /**
+ * @since 15.0.0
+ */
+ public function canConfirmPassword(string $uid): bool;
+}
diff --git a/lib/public/User/Backend/IPasswordHashBackend.php b/lib/public/User/Backend/IPasswordHashBackend.php
new file mode 100644
index 00000000000..2525b4e45ea
--- /dev/null
+++ b/lib/public/User/Backend/IPasswordHashBackend.php
@@ -0,0 +1,30 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace OCP\User\Backend;
+
+use InvalidArgumentException;
+
+/**
+ * @since 30.0.0
+ */
+interface IPasswordHashBackend {
+ /**
+ * @return ?string the password hash hashed by `\OCP\Security\IHasher::hash()`
+ * @since 30.0.0
+ */
+ public function getPasswordHash(string $userId): ?string;
+
+ /**
+ * @param string $passwordHash the password hash hashed by `\OCP\Security\IHasher::hash()`
+ * @throws InvalidArgumentException when `$passwordHash` is not a valid hash
+ * @since 30.0.0
+ */
+ public function setPasswordHash(string $userId, string $passwordHash): bool;
+}
diff --git a/lib/public/User/Backend/IProvideAvatarBackend.php b/lib/public/User/Backend/IProvideAvatarBackend.php
new file mode 100644
index 00000000000..6a694a4de95
--- /dev/null
+++ b/lib/public/User/Backend/IProvideAvatarBackend.php
@@ -0,0 +1,22 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\User\Backend;
+
+/**
+ * @since 14.0.0
+ */
+interface IProvideAvatarBackend {
+ /**
+ * @since 14.0.0
+ *
+ * @param string $uid
+ * @return bool
+ */
+ public function canChangeAvatar(string $uid): bool;
+}
diff --git a/lib/public/User/Backend/IProvideEnabledStateBackend.php b/lib/public/User/Backend/IProvideEnabledStateBackend.php
new file mode 100644
index 00000000000..5dcee366e53
--- /dev/null
+++ b/lib/public/User/Backend/IProvideEnabledStateBackend.php
@@ -0,0 +1,40 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace OCP\User\Backend;
+
+/**
+ * @since 28.0.0
+ */
+interface IProvideEnabledStateBackend {
+ /**
+ * @since 28.0.0
+ *
+ * @param callable():bool $queryDatabaseValue A callable to query the enabled state from database
+ */
+ public function isUserEnabled(string $uid, callable $queryDatabaseValue): bool;
+
+ /**
+ * @since 28.0.0
+ *
+ * @param callable():bool $queryDatabaseValue A callable to query the enabled state from database
+ * @param callable(bool):void $setDatabaseValue A callable to set the enabled state in the database.
+ */
+ public function setUserEnabled(string $uid, bool $enabled, callable $queryDatabaseValue, callable $setDatabaseValue): bool;
+
+ /**
+ * Get the list of disabled users, to merge with the ones disabled in database
+ *
+ * @since 28.0.0
+ * @since 30.0.0 $search parameter added
+ *
+ * @return string[]
+ */
+ public function getDisabledUserList(?int $limit = null, int $offset = 0, string $search = ''): array;
+}
diff --git a/lib/public/User/Backend/ISearchKnownUsersBackend.php b/lib/public/User/Backend/ISearchKnownUsersBackend.php
new file mode 100644
index 00000000000..4b3eef6005f
--- /dev/null
+++ b/lib/public/User/Backend/ISearchKnownUsersBackend.php
@@ -0,0 +1,24 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\User\Backend;
+
+/**
+ * @since 21.0.1
+ */
+interface ISearchKnownUsersBackend {
+ /**
+ * @param string $searcher
+ * @param string $pattern
+ * @param int|null $limit
+ * @param int|null $offset
+ * @return array
+ * @since 21.0.1
+ */
+ public function searchKnownUsersByDisplayName(string $searcher, string $pattern, ?int $limit = null, ?int $offset = null): array;
+}
diff --git a/lib/public/User/Backend/ISetDisplayNameBackend.php b/lib/public/User/Backend/ISetDisplayNameBackend.php
new file mode 100644
index 00000000000..617f1735021
--- /dev/null
+++ b/lib/public/User/Backend/ISetDisplayNameBackend.php
@@ -0,0 +1,26 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\User\Backend;
+
+/**
+ * @since 14.0.0
+ */
+interface ISetDisplayNameBackend {
+ /**
+ * @since 14.0.0
+ *
+ * @param string $uid The username
+ * @param string $displayName The new display name
+ * @return bool
+ *
+ * @since 25.0.0 Throw InvalidArgumentException
+ * @throws \InvalidArgumentException
+ */
+ public function setDisplayName(string $uid, string $displayName): bool;
+}
diff --git a/lib/public/User/Backend/ISetPasswordBackend.php b/lib/public/User/Backend/ISetPasswordBackend.php
new file mode 100644
index 00000000000..571349df58f
--- /dev/null
+++ b/lib/public/User/Backend/ISetPasswordBackend.php
@@ -0,0 +1,23 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\User\Backend;
+
+/**
+ * @since 14.0.0
+ */
+interface ISetPasswordBackend {
+ /**
+ * @since 14.0.0
+ *
+ * @param string $uid The username
+ * @param string $password The new password
+ * @return bool
+ */
+ public function setPassword(string $uid, string $password): bool;
+}