AuthComponent Class Reference

Inheritance diagram for AuthComponent:

Object List of all members.

Public Member Functions

 __authType ($auth=null)
 __setDefaults ()
 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
 $_methods = array()
 $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 39 of file auth.php.


Member Function Documentation

AuthComponent::__authType ( auth = null  ) 

Get authorization type

Parameters:
string $auth Type of authorization
Returns:
array Associative array with: type, object private

Definition at line 539 of file auth.php.

References $object.

Referenced by isAuthorized(), and startup().

AuthComponent::__setDefaults (  ) 

Attempts to introspect the correct values for object properties including $userModel and $sessionKey.

Parameters:
object $controller A reference to the instantiating controller object
Returns:
boolean private

Definition at line 418 of file auth.php.

References __(), login(), Router::normalize(), password(), pluralize(), and underscore().

Referenced by login(), logout(), startup(), and user().

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 731 of file auth.php.

References 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.
Returns:
void public

Definition at line 563 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.
Returns:
void
See also:
AuthComponent::allow() public

Definition at line 584 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 746 of file auth.php.

References __(), and 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 847 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 774 of file auth.php.

References $data, exists(), 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
Returns:
void public

Definition at line 231 of file auth.php.

References Debugger::checkSessionKey(), create(), App::import(), params(), Configure::read(), and 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::isAuthorized(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 461 of file auth.php.

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

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 625 of file auth.php.

References $data, __setDefaults(), and identify().

Referenced by __setDefaults(), and 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 647 of file auth.php.

References __setDefaults(), and Router::normalize().

AuthComponent::mapActions ( map = array()  ) 

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

Parameters:
array $map Actions to map
Returns:
void public

Definition at line 601 of file auth.php.

References create(), and read().

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 866 of file auth.php.

References Security::hash().

Referenced by __setDefaults(), 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 684 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 875 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
Returns:
boolean public

Definition at line 264 of file auth.php.

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

AuthComponent::user ( key = null  ) 

Get the current user from the session.

Parameters:
string $key field to retrive. Leave null to get entire User record
Returns:
mixed User record. or null if no user is logged in. public

Definition at line 661 of file auth.php.

References __setDefaults().

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 713 of file auth.php.

References $object, and user().


Member Data Documentation

AuthComponent::$_loggedIn = false

Definition at line 46 of file auth.php.

AuthComponent::$_methods = array()

Definition at line 223 of file auth.php.

AuthComponent::$actionMap

Initial value:

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

Definition at line 196 of file auth.php.

AuthComponent::$actionPath = null

Definition at line 121 of file auth.php.

AuthComponent::$ajaxLogin = null

Definition at line 80 of file auth.php.

AuthComponent::$allowedActions = array()

Definition at line 188 of file auth.php.

Referenced by startup().

AuthComponent::$authenticate = null

Definition at line 60 of file auth.php.

AuthComponent::$authError = null

Definition at line 173 of file auth.php.

AuthComponent::$authorize = false

Definition at line 72 of file auth.php.

Referenced by isAuthorized().

AuthComponent::$autoRedirect = true

Definition at line 180 of file auth.php.

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

Definition at line 53 of file auth.php.

AuthComponent::$data = array()

Definition at line 209 of file auth.php.

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

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

Definition at line 103 of file auth.php.

AuthComponent::$loginAction = null

Definition at line 129 of file auth.php.

Referenced by startup().

AuthComponent::$loginError = null

Definition at line 165 of file auth.php.

AuthComponent::$loginRedirect = null

Definition at line 139 of file auth.php.

AuthComponent::$logoutRedirect = null

Definition at line 150 of file auth.php.

AuthComponent::$object = null

Definition at line 157 of file auth.php.

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

AuthComponent::$params = array()

Definition at line 216 of file auth.php.

AuthComponent::$sessionKey = null

Definition at line 111 of file auth.php.

AuthComponent::$userModel = 'User'

Definition at line 87 of file auth.php.

AuthComponent::$userScope = array()

Definition at line 95 of file auth.php.


The documentation for this class was generated from the following file:
Generated on Sun Nov 22 00:30:55 2009 for CakePHP 1.2.x.x (v1.2.4.8284) by doxygen 1.4.7