Smalldb  v0.0-177-g1a83180
 All Classes Namespaces Functions Variables Pages
Public Member Functions | Protected Attributes | List of all members
Auth Class Reference

IAuth implementation using Smalldb state machine and simple session token in cookie. More...

Inheritance diagram for Auth:
Inheritance graph

Public Member Functions

 __construct ($config)
 Constructor.
 
 getSessionMachine ()
 Get session machine which manages all stuff around login and session.
 
 getUserId ()
 Get user's ID. More...
 
 getUserRole ()
 Get user's role. More...
 
 isBlockAllowed ($block_name, &$details=null)
 First level of authorization. More...
 

Protected Attributes

 $smalldb
 Smalldb backend.
 
 $session_machine
 Reference to session state machine.
 
 $cookie_name = 'AuthToken'
 Cookie name.
 
 $cookie_ttl = 315569260
 Cookie duration [seconds].
 
 $session_ttl = 315569260
 Session duration [seconds].
 
 $user_id_property = 'user_id'
 Name of the session machine property with user's ID.
 
 $user_role_property = 'user_role'
 Name of the session machine property with user's role.
 

Detailed Description

IAuth implementation using Smalldb state machine and simple session token in cookie.

Configuration options (all mandatory):

Member Function Documentation

getUserId ( )

Get user's ID.

User's ID is limited to single scalar value (any integer or string).

Returns
User's ID, or NULL when nobody is logged in.

Implements IAuth.

getUserRole ( )

Get user's role.

Smalldb does not understand user roles, it can only check whether user's role is one of required values. User's role is global and it is not related to any instance of anything.

User is expected to have exactly one role.

Returns
User's role, or NULL when nobody is logged in or there are no roles.

Implements IAuth.

isBlockAllowed (   $block_name,
$details = null 
)

First level of authorization.

Returns
Returns true if user is allowed to use the block.