PHP Class Horde_Auth_Base, horde

Author: Chuck Hagenbuch ([email protected])
Author: Michael Slusarz ([email protected])
ファイルを表示 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.
$_credentials array The credentials currently being authenticated.
$_error array Authentication error information.
$_history_api Horde_History History object.
$_lock_api Horde_Lock Lock object.
$_logger Horde_Log_Logger Logger object.
$_params array Hash containing parameters needed for the drivers.

Public Methods

Method Description
__construct ( array $params = [] ) Constructor.
addUser ( string $userId, array $credentials ) Adds a set of authentication credentials.
authenticate ( string $userId, array $credentials, boolean $login = true ) : boolean Finds out if a set of login credentials are valid, and if requested, mark the user as logged in in the current session.
exists ( string $userId ) : boolean Checks if $userId exists in the system.
getCredential ( mixed $name = null ) : mixed Returns internal credential value(s).
getError ( boolean $msg = false ) : mixed Returns the error type or message for an invalid authentication.
getParam ( string $param ) : string Returns the named parameter for the current auth driver.
hasCapability ( string $capability ) : boolean Queries the current driver to find out if it supports the given capability.
isLocked ( string $userId, boolean $show_details = false ) : boolean | array Returns whether a user is currently locked.
listUsers ( boolean $sort = false ) : mixed Lists all users in the system.
lockUser ( string $userId, integer $time ) Locks a user indefinitely or for a specified time.
removeUser ( string $userId ) Deletes 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.
searchUsers ( string $search ) : array Searches the users for a substring.
setCredential ( string $type, mixed $value ) Sets an internal credential value.
setError ( string $type, string $msg = null ) Sets the error message for an invalid authentication.
transparent ( ) : boolean Automatic authentication.
unlockUser ( string $userId, boolean $resetBadLogins = false ) Unlocks a user and optionally resets the bad login count.
updateUser ( string $oldID, string $newID, array $credentials ) Updates a set of authentication credentials.
validateAuth ( ) : boolean Checks for triggers that may invalidate the current auth.

Protected Methods

Method Description
_authenticate ( string $userId, array $credentials ) Authentication stub.
_badLogin ( string $userId ) Handles a bad login.
_resetBadLogins ( string $userId ) Resets the bad login counter.
_sort ( array $users, boolean $sort ) : array Basic sort implementation.

Method Details

__construct() public method

Constructor.
public __construct ( array $params = [] )
$params array Optional parameters: - default_user: (string) The default user. - logger: (Horde_Log_Logger, optional) A logger object. - lock_api: (Horde_Lock, optional) A locking object. - history_api: (Horde_History, optional) A history object. - login_block_count: (integer, optional) How many failed logins trigger autoblocking? 0 disables the feature. - login_block_time: (integer, options) How many minutes should autoblocking last? 0 means no expiration.

_authenticate() abstract protected method

On failure, Horde_Auth_Exception should pass a message string (if any) in the message field, and the Horde_Auth::REASON_* constant in the code field (defaults to Horde_Auth::REASON_MESSAGE).
abstract protected _authenticate ( string $userId, array $credentials )
$userId string The userID to check.
$credentials array An array of login credentials.

_badLogin() protected method

Handles a bad login.
protected _badLogin ( string $userId )
$userId string The user with a bad login.

_resetBadLogins() protected method

Resets the bad login counter.
protected _resetBadLogins ( string $userId )
$userId string The user to reset.

_sort() protected method

If the backend has listUsers and doesn't have a native sorting option, fall back to this method.
protected _sort ( array $users, boolean $sort ) : array
$users array An array of usernames.
$sort boolean Whether to sort or not.
return array the users, sorted or not

addUser() public method

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

authenticate() public method

Finds out if a set of login credentials are valid, and if requested, mark the user as logged in in the current session.
public authenticate ( string $userId, array $credentials, boolean $login = true ) : boolean
$userId string The userId to check.
$credentials array The credentials to check.
$login boolean Whether to log the user in. If false, we'll only test the credentials and won't modify the current session. Defaults to true.
return boolean Whether or not the credentials are valid.

exists() public method

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

getCredential() public method

Returns internal credential value(s).
public getCredential ( mixed $name = null ) : mixed
$name mixed The credential value to get. If null, will return the entire credential list. Valid names: - 'change': (boolean) Do credentials need to be changed? - 'credentials': (array) The credentials needed to authenticate. - 'expire': (integer) UNIX timestamp of the credential expiration date. - 'userId': (string) The user ID.
return mixed The credential information, or null if the credential doesn't exist.

getError() public method

Returns the error type or message for an invalid authentication.
public getError ( boolean $msg = false ) : mixed
$msg boolean If true, returns the message string (if set).
return mixed Error type, error message (if $msg is true) or false if entry doesn't exist.

getParam() public method

Returns the named parameter for the current auth driver.
public getParam ( string $param ) : string
$param string The parameter to fetch.
return string The parameter's value, or null if it doesn't exist.

hasCapability() public method

Queries the current driver to find out if it supports the given capability.
public hasCapability ( string $capability ) : boolean
$capability string The capability to test for.
return boolean Whether or not the capability is supported.

isLocked() public method

Returns whether a user is currently locked.
public isLocked ( string $userId, boolean $show_details = false ) : boolean | array
$userId string The user to check.
$show_details boolean Return timeout too?
return boolean | array If $show_details is a true, an array with 'locked' and 'lock_timeout' values. Whether the user is locked, otherwise.

listUsers() public method

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

lockUser() public method

Locks a user indefinitely or for a specified time.
public lockUser ( string $userId, integer $time )
$userId string The user to lock.
$time integer The duration in minutes, 0 = permanent.

removeUser() public method

Deletes 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.

searchUsers() public method

Searches the users for a substring.
public searchUsers ( string $search ) : array
$search string The search term.
return array A list of all matching users.

setCredential() public method

Sets an internal credential value.
public setCredential ( string $type, mixed $value )
$type string The credential name to set. See getCredential() for the list of valid credentials/types.
$value mixed The credential value to set.

setError() public method

Sets the error message for an invalid authentication.
public setError ( string $type, string $msg = null )
$type string The type of error (Horde_Auth::REASON_* constant).
$msg string The error message/reason for invalid authentication.

transparent() public method

Transparent authentication should set 'userId', 'credentials', or 'params' in $this->_credentials as needed - these values will be used to set the credentials in the session. Transparent authentication should normally never throw an error - false should be returned.
public transparent ( ) : boolean
return boolean Whether transparent login is supported.

unlockUser() public method

Unlocks a user and optionally resets the bad login count.
public unlockUser ( string $userId, boolean $resetBadLogins = false )
$userId string The user to unlock.
$resetBadLogins boolean Reset bad login counter?

updateUser() public method

Updates 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

validateAuth() public method

These triggers are independent of the credentials.
public validateAuth ( ) : boolean
return boolean True if the results of authenticate() are still valid.

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

$_credentials protected_oe property

The credentials currently being authenticated.
protected array $_credentials
return array

$_error protected_oe property

Authentication error information.
protected array $_error
return array

$_history_api protected_oe property

History object.
protected Horde_History $_history_api
return Horde_History

$_lock_api protected_oe property

Lock object.
protected Horde_Lock $_lock_api
return Horde_Lock

$_logger protected_oe property

Logger object.
protected Horde_Log_Logger $_logger
return Horde_Log_Logger

$_params protected_oe property

Hash containing parameters needed for the drivers.
protected array $_params
return array