PHP Class Horde_Core_Auth_Application, horde

Author: Chuck Hagenbuch ([email protected])
Author: Michael Slusarz ([email protected])
Inheritance: extends Horde_Auth_Base
显示文件 Open project: horde/horde

Protected Properties

Property Type Description
$_app string Application for authentication.
$_appCapabilities array The list of application capabilities.
$_base Horde_Auth_Base The base auth driver, used for Horde authentication.
$_capabilities array Available capabilities.
$_view string The view mode.

Public Methods

Method Description
__construct ( array $params = [] ) Constructor.
addUser ( string $userId, array $credentials ) Add 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 a user ID exists in the system.
getCredential ( mixed $name = null ) : mixed Retrieve internal credential value(s).
getError ( boolean $msg = false ) : mixed Returns the error type or message for an invalid authentication.
getLoginParams ( ) : array Returns information on what login parameters to display on the login screen.
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 ) Checks if $userId is currently locked.
listNames ( ) : array List all users in the system with their real names.
listUsers ( $sort = false ) : array List all users in the system.
lockUser ( string $userId, integer $time ) Locks a user indefinitely or for a specified time
removeUser ( string $userId ) Delete a set of authentication credentials.
requireAuth ( ) : boolean Indicate whether the application requires authentication.
resetPassword ( string $userId ) : string Reset a user's password. Used for example when the user does not remember the existing password.
runHook ( string $userId, array $credentials, string $type, string $method = null ) : array Runs the pre/post-authenticate hook and parses the result.
setCredential ( string $name, mixed $value ) Set 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 bad login count
updateUser ( string $oldID, string $newID, array $credentials ) Update 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 ) Find out if a set of login credentials are valid.
_setAuth ( ) : boolean Set authentication credentials in the Horde session.
_setView ( ) Sets the default global view mode in the horde session. This can be checked by applications, and overridden if desired. Also sets a cookie to remember the last view selection if applicable.

Method Details

__construct() public method

Constructor.
public __construct ( array $params = [] )
$params array Required parameters: - app: (string) The application which is providing authentication. - base: (Horde_Auth_Base) The base Horde_Auth driver. Only needed if 'app' is 'horde'.

_authenticate() protected method

Find out if a set of login credentials are valid.
protected _authenticate ( string $userId, array $credentials )
$userId string The user ID to check.
$credentials array The credentials to use. This object will always be available in the 'auth_ob' key.

_setAuth() protected method

Set authentication credentials in the Horde session.
protected _setAuth ( ) : boolean
return boolean True on success, false on failure.

_setView() protected method

Sets the default global view mode in the horde session. This can be checked by applications, and overridden if desired. Also sets a cookie to remember the last view selection if applicable.
protected _setView ( )

addUser() public method

Add a set of authentication credentials.
public addUser ( string $userId, array $credentials )
$userId string The user ID 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 user ID 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 a user ID exists in the system.
public exists ( string $userId ) : boolean
$userId string User ID to check.
return boolean Whether or not the user ID already exists.

getCredential() public method

Retrieve 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 Return 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.

getLoginParams() public method

Returns information on what login parameters to display on the login screen.
public getLoginParams ( ) : array
return array An array with the following keys:
'js_code' - (array) A list of javascript statements to be included.
'js_files' - (array) A list of javascript files to be included.
'params' - (array) A list of parameters to display on the login screen.
           Each entry is an array with the following entries:
           'label' - (string) The label of the entry.
           'type' - (string) 'select', 'text', or 'password'.
           'value' - (mixed) If type is 'text' or 'password', the
                     text to insert into the field by default. If type
                     is 'select', an array with they keys as the
                     option values and an array with the following keys:
                     'hidden' - (boolean) If true, the option will be
                                hidden.
                     'name' - (string) The option label.
                     'selected' - (boolean) If true, will be selected
                                  by default.

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

Checks if $userId is currently locked.
public isLocked ( string $userId, boolean $show_details = false )
$userId string The userId to check.
$show_details boolean Toggle array format with timeout.

listNames() public method

List all users in the system with their real names.
public listNames ( ) : array
return array The array of user IDs as keys and names as values.

listUsers() public method

List all users in the system.
public listUsers ( $sort = false ) : array
return array The array of user IDs.

lockUser() public method

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

removeUser() public method

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

requireAuth() public method

Indicate whether the application requires authentication.
public requireAuth ( ) : boolean
return boolean True if application requires authentication.

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.

runHook() public method

Runs the pre/post-authenticate hook and parses the result.
public runHook ( string $userId, array $credentials, string $type, string $method = null ) : array
$userId string The userId who has been authorized.
$credentials array The credentials of the user.
$type string Either 'preauthenticate' or 'postauthenticate'.
$method string The triggering method (preauthenticate only). Either 'authenticate' or 'transparent'.
return array Two element array, $userId and $credentials.

setCredential() public method

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

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

Automatic authentication.
public transparent ( ) : boolean
return boolean Whether or not the client is allowed.

unlockUser() public method

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

updateUser() public method

Update a set of authentication credentials.
public updateUser ( string $oldID, string $newID, array $credentials )
$oldID string The old user ID.
$newID string The new user ID.
$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

$_app protected_oe property

Application for authentication.
protected string $_app
return string

$_appCapabilities protected_oe property

The list of application capabilities.
protected array $_appCapabilities
return array

$_base protected_oe property

The base auth driver, used for Horde authentication.
protected Horde_Auth_Base $_base
return Horde_Auth_Base

$_capabilities protected_oe property

Available capabilities.
protected array $_capabilities
return array

$_view protected_oe property

The view mode.
protected string $_view
return string