2016-10-28 12:27:35 +00:00
< ? php
declare ( strict_types = 1 );
2017-03-28 04:12:12 +00:00
namespace JKingWeb\Arsse\User ;
2016-10-28 12:27:35 +00:00
Interface Driver {
2017-02-16 20:29:42 +00:00
const FUNC_NOT_IMPLEMENTED = 0 ;
const FUNC_INTERNAL = 1 ;
const FUNC_EXTERNAL = 2 ;
2017-02-11 16:36:17 +00:00
2017-02-18 00:22:50 +00:00
const RIGHTS_NONE = 0 ; // normal user
const RIGHTS_DOMAIN_MANAGER = 25 ; // able to act for any normal users on same domain; cannot elevate other users
const RIGHTS_DOMAIN_ADMIN = 50 ; // able to act for any users on same domain not above themselves; may elevate users on same domain to domain manager or domain admin
2017-02-23 04:22:45 +00:00
const RIGHTS_GLOBAL_MANAGER = 75 ; // able to act for any normal users on any domain; cannot elevate other users
2017-02-18 00:22:50 +00:00
const RIGHTS_GLOBAL_ADMIN = 100 ; // is completely unrestricted
2017-02-11 16:36:17 +00:00
2017-02-18 00:22:50 +00:00
// returns an instance of a class implementing this interface. Implemented as a static method for consistency with database classes
2017-03-28 04:12:12 +00:00
function __construct ( \JKingWeb\Arsse\RuntimeData $data );
2017-02-18 00:22:50 +00:00
// returns a human-friendly name for the driver (for display in installer, for example)
2017-02-16 20:29:42 +00:00
static function driverName () : string ;
2017-02-18 00:22:50 +00:00
// returns an array (or single queried member of same) of methods defined by this interface and whether the class implements the internal function or a custom version
2017-02-16 20:29:42 +00:00
function driverFunctions ( string $function = null );
2017-02-18 00:22:50 +00:00
// authenticates a user against their name and password
2017-02-16 20:29:42 +00:00
function auth ( string $user , string $password ) : bool ;
2017-02-18 00:22:50 +00:00
// checks whether a user exists
2017-02-16 20:29:42 +00:00
function userExists ( string $user ) : bool ;
2017-02-18 00:22:50 +00:00
// adds a user
2017-02-20 22:04:13 +00:00
function userAdd ( string $user , string $password = null ) : string ;
2017-02-18 00:22:50 +00:00
// removes a user
2017-02-16 20:29:42 +00:00
function userRemove ( string $user ) : bool ;
2017-02-18 00:22:50 +00:00
// lists all users
2017-02-16 20:29:42 +00:00
function userList ( string $domain = null ) : array ;
2017-02-18 00:22:50 +00:00
// sets a user's password; if the driver does not require the old password, it may be ignored
2017-02-20 22:04:13 +00:00
function userPasswordSet ( string $user , string $newPassword = null , string $oldPassword = null ) : string ;
2017-02-18 00:22:50 +00:00
// gets user metadata (currently not useful)
2017-02-16 20:29:42 +00:00
function userPropertiesGet ( string $user ) : array ;
2017-02-18 00:22:50 +00:00
// sets user metadata (currently not useful)
2017-02-16 20:29:42 +00:00
function userPropertiesSet ( string $user , array $properties ) : array ;
2017-02-18 00:22:50 +00:00
// returns a user's access level according to RIGHTS_* constants (or some custom semantics, if using custom implementation of authorize())
2017-02-16 20:29:42 +00:00
function userRightsGet ( string $user ) : int ;
2017-02-18 00:22:50 +00:00
// sets a user's access level
2017-02-16 20:29:42 +00:00
function userRightsSet ( string $user , int $level ) : bool ;
2016-10-28 12:27:35 +00:00
}