PHP Class Horde_Auth_Sql, horde

The table structure for the Auth system needs to be created with the shipped migration scripts. See "horde-db-migrate-component --help" for details.
Author: Chuck Hagenbuch ([email protected])
Inheritance: extends Horde_Auth_Base
显示文件 Open project: horde/horde Class Usage Examples

Protected Properties

Property Type Description
$_capabilities array An array of capabilities, so that the driver can report which operations it supports and which it doesn't.
$_db Horde_Db_Adapter Handle for the current database connection.

Public Methods

Method Description
__construct ( array $params = [] ) Constructor
addUser ( string $userId, array $credentials ) Add a set of authentication credentials.
exists ( string $userId ) : boolean Checks if a userId exists in the system.
listUsers ( boolean $sort = false ) : array List all users in the system.
removeUser ( string $userId ) Delete a set of authentication credentials.
resetPassword ( string $userId ) : string Reset a user's password. Used for example when the user does not remember the existing password.
updateUser ( string $oldID, string $newID, array $credentials ) Update a set of authentication credentials.

Protected Methods

Method Description
_authenticate ( string $userId, array $credentials ) Find out if a set of login credentials are valid.
_comparePasswords ( string $encrypted, string $plaintext ) : boolean Compare an encrypted password to a plaintext string to see if they match.

Private Methods

Method Description
_calc_expiration ( string $type ) : integer Calculate a timestamp and return it along with the field name

Method Details

__construct() public method

Constructor
public __construct ( array $params = [] )
$params array Parameters: 'db' - (Horde_Db_Adapter) [REQUIRED] Database object.
'encryption' - (string) The encryption to use to store the password in
               the table (e.g. plain, crypt, md5-hex, md5-base64, smd5,
               sha, ssha, aprmd5).
               DEFAULT: 'md5-hex'
'hard_expiration_field' - (string) The name of the field containing a
                          date after which the account is no longer
                          valid and the user will not be able to log in
                          at all.
                          DEFAULT: none
'password_field' - (string) The name of the password field in the auth
                   table.
                   DEFAULT: 'user_pass'
'show_encryption' - (boolean) Whether or not to prepend the encryption
                    in the password field.
                    DEFAULT: false
'soft_expiration_field' - (string) The name of the field containing a
                          date after which the system will request the
                          user change his or her password.
                          DEFAULT: none
'table' - (string) The name of the SQL table to use in 'database'.
          DEFAULT: 'horde_users'
'username_field' - (string) The name of the username field in the auth
                   table.
                   DEFAULT: 'user_uid'

_authenticate() protected method

Find out if a set of login credentials are valid.
protected _authenticate ( string $userId, array $credentials )
$userId string The userId to check.
$credentials array The credentials to use.

_comparePasswords() protected method

Compare an encrypted password to a plaintext string to see if they match.
protected _comparePasswords ( string $encrypted, string $plaintext ) : boolean
$encrypted string The crypted password to compare against.
$plaintext string The plaintext password to verify.
return boolean True if matched, false otherwise.

addUser() public method

Add a set of authentication credentials.
public addUser ( string $userId, array $credentials )
$userId string The userId to add.
$credentials array The credentials to add.

exists() public method

Checks if a userId exists in the system.
public exists ( string $userId ) : boolean
$userId string User ID for which to check
return boolean Whether or not the userId already exists.

listUsers() public method

List all users in the system.
public listUsers ( boolean $sort = false ) : array
$sort boolean Sort the users?
return array The array of userIds.

removeUser() public method

Delete a set of authentication credentials.
public removeUser ( string $userId )
$userId string The userId to delete.

resetPassword() public method

Reset a user's password. Used for example when the user does not remember the existing password.
public resetPassword ( string $userId ) : string
$userId string The user id for which to reset the password.
return string The new password on success.

updateUser() public method

Update a set of authentication credentials.
public updateUser ( string $oldID, string $newID, array $credentials )
$oldID string The old userId.
$newID string The new userId.
$credentials array The new credentials

Property Details

$_capabilities protected_oe property

An array of capabilities, so that the driver can report which operations it supports and which it doesn't.
protected array $_capabilities
return array

$_db protected_oe property

Handle for the current database connection.
protected Horde_Db_Adapter $_db
return Horde_Db_Adapter