diff options
author | Pytal <24800714+Pytal@users.noreply.github.com> | 2024-07-09 08:00:01 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-09 08:00:01 -0700 |
commit | 3a97dbf248b3e581b5782a638743958eb6f2a640 (patch) | |
tree | 83d6d8da3f595d5d6b99b827ef3b19dbbb17b01d /lib/public | |
parent | 025a7849b487351d0240d89833b3ab825897097d (diff) | |
parent | c390ae94ff21c553fadc6645ca311eb42a46195f (diff) | |
download | nextcloud-server-3a97dbf248b3e581b5782a638743958eb6f2a640.tar.gz nextcloud-server-3a97dbf248b3e581b5782a638743958eb6f2a640.zip |
Merge pull request #46123 from nextcloud/feat/user-password-hash
feat: Allow getting/setting the password hash of a user
Diffstat (limited to 'lib/public')
-rw-r--r-- | lib/public/IUser.php | 17 | ||||
-rw-r--r-- | lib/public/User/Backend/IPasswordHashBackend.php | 30 |
2 files changed, 47 insertions, 0 deletions
diff --git a/lib/public/IUser.php b/lib/public/IUser.php index 2ed2d0d87b2..4ba9a89f064 100644 --- a/lib/public/IUser.php +++ b/lib/public/IUser.php @@ -77,6 +77,23 @@ interface IUser { public function setPassword($password, $recoveryPassword = null); /** + * Get the password hash of the user + * + * @return ?string the password hash hashed by `\OCP\Security\IHasher::hash()` + * @since 30.0.0 + */ + public function getPasswordHash(): ?string; + + /** + * Set the password hash of the user + * + * @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 $passwordHash): bool; + + /** * get the users home folder to mount * * @return string 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; +} |