pclib  2.3.2
Lightweight PHP framework
Public Member Functions | Data Fields | Protected Member Functions
Auth Class Reference

Provides authentication and authorization support. More...

Inheritance diagram for Auth:
AuthBase BaseObject AuthHttp

Public Member Functions

 setLoggedUser (pclib\AuthUser $user)
 Take $user and log him in. More...
 
 getUser ($userName=null)
 Without parameter it returns logged user, user $userName otherwise. More...
 
 exists ($userName)
 Check if user $userName exists. More...
 
 getStorage ()
 Return storage object - if not exists, create one. More...
 
 login ($userName, $password)
 Authenticate user $userName with password $password. More...
 
 logout ()
 Logout active user.
 
 testRight ($name, $objectId=0)
 Check if logged user has permission $name. More...
 
 isLogged ()
 Check if someone is logged in.
 
 hasRight ($name, $objectId=0)
 Check if logged user has permission $name. More...
 
 hasRole ($role)
 Check if logged user has role $role. More...
 
- Public Member Functions inherited from AuthBase
 __construct ()
 Constructor - load config parameters.
 
 passwordHash ($password)
 Return password hash. More...
 
 passwordHashVerify ($password, $hash)
 Verify password hash. More...
 
 setError ($message)
 Add error message into ->errors variable. More...
 
- Public Member Functions inherited from BaseObject
 loadDefaults ($className=null)
 Load default parameters of class $className into object instance.
 
 setProperties (array $defaults)
 Set public properties of object from the array. More...
 
 addEvent ($name, $callback)
 Add event handler to $object->$name property. More...
 
 toArray ()
 Convert object to array. More...
 

Data Fields

 $storage
 var AuthDbStorage
 
 $realm
 Apps with the same realm share authentization session. More...
 
 $verifyRemote = true
 Check if remote address changed. More...
 
 $loggedUser
 var AuthUser User which is logged in. More...
 
 $onAfterLogin
 Occurs after login. More...
 
 $onBeforeLogout
 Occurs before logout. More...
 
- Data Fields inherited from AuthBase
 $translator
 var Translator
 
 $errors = array()
 Array of error messages (if any)
 
 $secret
 Secret string used for enpowerment of md5 hash.
 
 $passwordAlgo
 Password algorhitm - can be 'md5' or 'bcrypt'.
 
 $passwordCost = 10
 Bcrypt cost. More...
 
 $throwsExceptions = false
 Throws exceptions instead of just collecting errors in ->errors.
 
 $onError
 Occurs on auth error. More...
 
- Data Fields inherited from BaseObject
 $onNewInstance
 Occurs when new instance of the class is created. More...
 
 $onMissingMethod
 Occurs when called method does not exist. More...
 
 $serviceLocator
 var function() Return service object when requested with service(). More...
 

Protected Member Functions

 getUserIp (pclib\AuthUser $user)
 Get user ip-address, check if changed and log notice if so.
 
 getSessionUser ()
 Load user from session storage, check session validity. More...
 
 setSessionUser (pclib\AuthUser $user=null)
 Store user to session. More...
 
- Protected Member Functions inherited from AuthBase
 log ($category, $messageId, $message=null, $itemId=null)
 log security issue using App->logger. More...
 
- Protected Member Functions inherited from BaseObject
 fireEvent ($name, array $args=array())
 Run all event handlers in $object->$name property. More...
 
 service ($service, $default=null)
 Try acquire $service and load it into property $this->$service. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from BaseObject
static defaults ()
 Set or retireve default parameters of the object. More...
 
- Protected Attributes inherited from AuthBase
 $app
 var App
 

Detailed Description

Provides authentication and authorization support.

Features:

Member Function Documentation

exists (   $userName)

Check if user $userName exists.

Parameters
string$userName
Returns
bool $yes
getSessionUser ( )
protected

Load user from session storage, check session validity.

Returns
AuthUser $user;
getStorage ( )

Return storage object - if not exists, create one.

getUser (   $userName = null)

Without parameter it returns logged user, user $userName otherwise.

Parameters
string$userName
Returns
AuthUser $user
hasRight (   $name,
  $objectId = 0 
)

Check if logged user has permission $name.

Parameters
string$name
Returns
bool $yes
hasRole (   $role)

Check if logged user has role $role.

Parameters
string$role
Returns
bool $yes
login (   $userName,
  $password 
)

Authenticate user $userName with password $password.

If user passed, log him in.

Parameters
string$userName
string$password
Returns
bool $success
setLoggedUser ( pclib\AuthUser  $user)

Take $user and log him in.

See also $loggedUser.

Parameters
AuthUser$user
setSessionUser ( pclib\AuthUser  $user = null)
protected

Store user to session.

Parameters
AuthUser$user,;
testRight (   $name,
  $objectId = 0 
)

Check if logged user has permission $name.

If not, throw exception and log security issue.

Parameters
string$nameName of permission.
int$objectIdresource object id

Field Documentation

$loggedUser

var AuthUser User which is logged in.

$onAfterLogin

Occurs after login.

$onBeforeLogout

Occurs before logout.

$realm

Apps with the same realm share authentization session.

$verifyRemote = true

Check if remote address changed.


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