IAuth implementation using Smalldb state machine and simple session token in cookie. More...
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. | |
IAuth implementation using Smalldb state machine and simple session token in cookie.
Configuration options (all mandatory):
smalldb
: Instance of Smalldb::StateMachine::AbstractBackend.machine_ref_prefix
: Prefix of machine ID (array).machine_null_ref
: State machine type for null ref.cookie_name
: Name of the cookie for a token. (default: 'auth')cookie_ttl
: How long cookie is valid. (default: 10 years)session_ttl
: Duration of the session (should be greater or equal to cookie_ttl
, default: 10 years).user_id_property
: Name of the session machine property with user's ID.user_role_property
: Name of the session machine property with user's role. You may want to have this property calculated. getUserId | ( | ) |
Get user's ID.
User's ID is limited to single scalar value (any integer or string).
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.
Implements IAuth.
isBlockAllowed | ( | $block_name, | |
& | $details = null |
||
) |
First level of authorization.