2016-10-28 12:27:35 +00:00
|
|
|
<?php
|
2017-11-17 01:23:18 +00:00
|
|
|
/** @license MIT
|
|
|
|
* Copyright 2017 J. King, Dustin Wilson et al.
|
|
|
|
* See LICENSE and AUTHORS files for details */
|
|
|
|
|
2016-10-28 12:27:35 +00:00
|
|
|
declare(strict_types=1);
|
2017-03-28 04:12:12 +00:00
|
|
|
namespace JKingWeb\Arsse\User;
|
2016-10-28 12:27:35 +00:00
|
|
|
|
2017-08-29 14:50:31 +00:00
|
|
|
interface Driver {
|
|
|
|
public function __construct();
|
2020-11-09 23:14:03 +00:00
|
|
|
|
|
|
|
/** Returns a human-friendly name for the driver (for display in installer, for example) */
|
2017-08-29 14:50:31 +00:00
|
|
|
public static function driverName(): string;
|
2020-11-09 23:14:03 +00:00
|
|
|
|
|
|
|
/** Authenticates a user against their name and password */
|
2017-08-29 14:50:31 +00:00
|
|
|
public function auth(string $user, string $password): bool;
|
2020-11-09 23:14:03 +00:00
|
|
|
|
|
|
|
/** Adds a new user and returns their password
|
|
|
|
*
|
|
|
|
* When given no password the implementation may return null; the user
|
|
|
|
* manager will then generate a random password and try again with that
|
|
|
|
* password. Alternatively the implementation may generate its own
|
|
|
|
* password if desired
|
|
|
|
*
|
|
|
|
* @param string $user The username to create
|
|
|
|
* @param string|null $password The cleartext password to assign to the user, or null to generate a random password
|
|
|
|
*/
|
|
|
|
public function userAdd(string $user, string $password = null): ?string;
|
|
|
|
|
|
|
|
/** Removes a user */
|
2017-08-29 14:50:31 +00:00
|
|
|
public function userRemove(string $user): bool;
|
2020-11-09 23:14:03 +00:00
|
|
|
|
|
|
|
/** Lists all users */
|
2018-10-28 14:59:17 +00:00
|
|
|
public function userList(): array;
|
2020-11-09 23:14:03 +00:00
|
|
|
|
|
|
|
/** sets a user's password
|
|
|
|
*
|
|
|
|
* When given no password the implementation may return null; the user
|
|
|
|
* manager will then generate a random password and try again with that
|
|
|
|
* password. Alternatively the implementation may generate its own
|
|
|
|
* password if desired
|
|
|
|
*
|
|
|
|
* @param string $user The user for whom to change the password
|
|
|
|
* @param string|null $password The cleartext password to assign to the user, or null to generate a random password
|
|
|
|
* @param string|null $oldPassword The user's previous password, if known
|
|
|
|
*/
|
|
|
|
public function userPasswordSet(string $user, ?string $newPassword, string $oldPassword = null);
|
|
|
|
|
|
|
|
/** removes a user's password; this makes authentication fail unconditionally
|
|
|
|
*
|
|
|
|
* @param string $user The user for whom to change the password
|
|
|
|
* @param string|null $oldPassword The user's previous password, if known
|
|
|
|
*/
|
2019-03-24 18:42:23 +00:00
|
|
|
public function userPasswordUnset(string $user, string $oldPassword = null): bool;
|
2017-08-29 14:50:31 +00:00
|
|
|
}
|