AuthComponent Class Reference

Inheritance diagram for AuthComponent:

Object

List of all members.


Public Member Functions

 action ($action= ':controller/:action')
 allow ()
 deny ()
getModel ($name=null)
 hashPasswords ($data)
 identify ($user=null, $conditions=null)
 initialize (&$controller)
 isAuthorized ($type=null, $object=null, $user=null)
 login ($data=null)
 logout ()
 mapActions ($map=array())
 password ($password)
 redirect ($url=null)
 shutdown (&$controller)
 startup (&$controller)
 user ($key=null)
 validate ($object, $user=null, $action=null)

Public Attributes

 $_loggedIn = false
 $actionMap
 $actionPath = null
 $ajaxLogin = null
 $allowedActions = array()
 $authenticate = null
 $authError = null
 $authorize = false
 $autoRedirect = true
 $components = array('Session', 'RequestHandler')
 $data = array()
 $fields = array('username' => 'username', 'password' => 'password')
 $loginAction = null
 $loginError = null
 $loginRedirect = null
 $logoutRedirect = null
 $object = null
 $params = array()
 $sessionKey = null
 $userModel = 'User'
 $userScope = array()

Detailed Description

Definition at line 41 of file auth.php.


Member Function Documentation

AuthComponent::action ( action = ':controller/:action'  ) 

Returns the path to the ACO node bound to a controller/action.

Parameters:
string $action Optional. The controller/action path to validate the user against. The current request action is used if none is specified.
Returns:
boolean ACO node path public

Definition at line 674 of file auth.php.

References Inflector::camelize(), and params().

Referenced by isAuthorized(), and startup().

AuthComponent::allow (  ) 

Takes a list of actions in the current controller for which authentication is not required, or no parameters to allow all actions.

Parameters:
string $action Controller action name
string $action Controller action name
string ... etc. public

Definition at line 508 of file auth.php.

AuthComponent::deny (  ) 

Removes items from the list of allowed actions.

Parameters:
string $action Controller action name
string $action Controller action name
string ... etc.
See also:
AuthComponent::allow() public

Definition at line 528 of file auth.php.

& AuthComponent::getModel ( name = null  ) 

Returns a reference to the model object specified, and attempts to load it if it is not found.

Parameters:
string $name Model name (defaults to AuthComponent::$userModel)
Returns:
object A reference to a model object public

Definition at line 689 of file auth.php.

References ClassRegistry::init().

Referenced by identify(), and isAuthorized().

AuthComponent::hashPasswords ( data  ) 

Hash any passwords found in $data using $userModel and $fields['password']

Parameters:
array $data Set of data to look for passwords
Returns:
array Data with passwords hashed public

Definition at line 791 of file auth.php.

References $data, and password().

Referenced by startup().

AuthComponent::identify ( user = null,
conditions = null 
)

Identifies a user based on specific criteria.

Parameters:
mixed $user Optional. The identity of the user to be validated. Uses the current user session if none specified.
array $conditions Optional. Additional conditions to a find.
Returns:
array User record data, or null, if the user could not be identified. public

Definition at line 717 of file auth.php.

References $data, getModel(), password(), and user().

Referenced by login().

AuthComponent::initialize ( &$  controller  ) 

Initializes AuthComponent for use in the controller

Parameters:
object $controller A reference to the instantiating controller object public

Definition at line 225 of file auth.php.

References Debugger::checkSessionKey(), App::import(), params(), and Configure::read().

AuthComponent::isAuthorized ( type = null,
object = null,
user = null 
)

Determines whether the given user is authorized to perform an action. The type of authorization used is based on the value of AuthComponent::$authorize or the passed $type param.

Types: 'controller' will validate against Controller::isAuthorized() if controller instance is passed in $object 'actions' will validate Controller::action against an AclComponent::check() 'crud' will validate mapActions against an AclComponent::check() array('model'=> 'name'); will validate mapActions against model $name::isAuthorize(user, controller, mapAction) 'object' will validate Controller::action against object::isAuthorized(user, controller, action)

Parameters:
string $type Type of authorization
mixed $object object, model object, or model name
mixed $user The user to check the authorization of
Returns:
boolean True if $user is authorized, otherwise false public

Definition at line 416 of file auth.php.

References $authorize, $object, a(), action(), getModel(), mapActions(), params(), and user().

Referenced by startup().

AuthComponent::login ( data = null  ) 

Manually log-in a user with the given parameter data. The $data provided can be any data structure used to identify a user in AuthComponent::identify(). If $data is empty or not specified, POST data from Controller::$data will be used automatically.

After (if) login is successful, the user record is written to the session key specified in AuthComponent::$sessionKey.

Parameters:
mixed $data User object
Returns:
boolean True on login success, false on failure public

Definition at line 568 of file auth.php.

References $data, and identify().

Referenced by startup().

AuthComponent::logout (  ) 

Logs a user out, and returns the login action to redirect to.

Parameters:
mixed $url Optional URL to redirect the user to after logout
Returns:
string AuthComponent::$loginAction
See also:
AuthComponent::$loginAction public

Definition at line 590 of file auth.php.

References Router::normalize().

AuthComponent::mapActions ( map = array()  ) 

Maps action names to CRUD operations. Used for controller-based authentication.

Parameters:
array $map Actions to map public

Definition at line 544 of file auth.php.

Referenced by isAuthorized().

AuthComponent::password ( password  ) 

Hash a password with the application's salt value (as defined with Configure::write('Security.salt');

Parameters:
string $password Password to hash
Returns:
string Hashed password public

Definition at line 810 of file auth.php.

References Security::hash().

Referenced by hashPasswords(), identify(), and startup().

AuthComponent::redirect ( url = null  ) 

If no parameter is passed, gets the authentication redirect URL.

Parameters:
mixed $url Optional URL to write as the login redirect URL.
Returns:
string Redirect URL public

Definition at line 627 of file auth.php.

References $url, and Router::normalize().

Referenced by startup().

AuthComponent::shutdown ( &$  controller  ) 

Component shutdown. If user is logged in, wipe out redirect.

Parameters:
object $controller Instantiating controller public

Definition at line 819 of file auth.php.

AuthComponent::startup ( &$  controller  ) 

Main execution method. Handles redirecting of invalid users, and processing of login form data.

Parameters:
object $controller A reference to the instantiating controller object public

Definition at line 256 of file auth.php.

References Controller::$components, $data, $loginAction, $object, $params, $url, Object::_stop(), action(), env(), hashPasswords(), isAuthorized(), login(), Router::normalize(), params(), password(), Configure::read(), redirect(), user(), and uses().

AuthComponent::user ( key = null  ) 

Get the current user from the session.

Returns:
array User record, or null if no user is logged in. public

Definition at line 603 of file auth.php.

Referenced by identify(), isAuthorized(), startup(), and validate().

AuthComponent::validate ( object,
user = null,
action = null 
)

Validates a user against an abstract object.

Parameters:
mixed $object The object to validate the user against.
mixed $user Optional. The identity of the user to be validated. Uses the current user session if none specified. For valid forms of identifying users, see AuthComponent::identify().
string $action Optional. The action to validate against.
See also:
AuthComponent::identify()
Returns:
boolean True if the user validates, false otherwise. public

Definition at line 656 of file auth.php.

References $object, and user().


Member Data Documentation

AuthComponent::$_loggedIn = false

Definition at line 48 of file auth.php.

AuthComponent::$actionMap

Initial value:

 array(
        'index'     => 'read',
        'add'       => 'create',
        'edit'      => 'update',
        'view'      => 'read',
        'remove'    => 'delete'
    )

Definition at line 198 of file auth.php.

AuthComponent::$actionPath = null

Definition at line 123 of file auth.php.

AuthComponent::$ajaxLogin = null

Definition at line 82 of file auth.php.

AuthComponent::$allowedActions = array()

Definition at line 190 of file auth.php.

AuthComponent::$authenticate = null

Definition at line 62 of file auth.php.

AuthComponent::$authError = null

Definition at line 175 of file auth.php.

AuthComponent::$authorize = false

Definition at line 74 of file auth.php.

Referenced by isAuthorized().

AuthComponent::$autoRedirect = true

Definition at line 182 of file auth.php.

AuthComponent::$components = array('Session', 'RequestHandler')

Definition at line 55 of file auth.php.

AuthComponent::$data = array()

Definition at line 211 of file auth.php.

Referenced by hashPasswords(), identify(), login(), and startup().

AuthComponent::$fields = array('username' => 'username', 'password' => 'password')

Definition at line 105 of file auth.php.

AuthComponent::$loginAction = null

Definition at line 131 of file auth.php.

Referenced by startup().

AuthComponent::$loginError = null

Definition at line 167 of file auth.php.

AuthComponent::$loginRedirect = null

Definition at line 141 of file auth.php.

AuthComponent::$logoutRedirect = null

Definition at line 152 of file auth.php.

AuthComponent::$object = null

Definition at line 159 of file auth.php.

Referenced by isAuthorized(), startup(), and validate().

AuthComponent::$params = array()

Definition at line 218 of file auth.php.

Referenced by startup().

AuthComponent::$sessionKey = null

Definition at line 113 of file auth.php.

AuthComponent::$userModel = 'User'

Definition at line 89 of file auth.php.

AuthComponent::$userScope = array()

Definition at line 97 of file auth.php.


The documentation for this class was generated from the following file: