nyroFwk  0.2
Public Member Functions | Protected Member Functions | Protected Attributes
security_default Class Reference
Inheritance diagram for security_default:
security_abstract object

Public Member Functions

 getUserFromCryptic ($cryptic)
 
 isLogged ()
 
 getUser ()
 
 setUser (db_row $user, $saveLogin=true, $cookieStayConnected=false)
 
 login ($prm=null, $page=null, $redirectIfLogged=true)
 
 logFromCryptic ($cryptic, $cookieStayConnected=false)
 
 saveCookieStayConnected ()
 
 cryptPass ($str, $plus='Password')
 
 logout ($prm=null)
 
 addRole ($role)
 
 hasRole ($role=null)
 
 delRole ($role=null)
 
 check (array $url=null, $redirect=true)
 
 getLoginForm (array $prm=array())
 
 getSession ()
 
 login ($prm=null, $page=null)
 
 protect ($page=null)
 
 getPage ($type='login', $uri=false)
 
 getAttr ($name)
 
 setAttr ($name, $value)
 
 getCfg ()
 

Protected Member Functions

 afterInit ()
 
 autoLogin ()
 
 saveLogin ($cookieStayConnected=false)
 
 getWhereLogin ($login, $pass)
 
 hook ($name)
 
 isContained (array $url, array $checks)
 
 beforeInit ()
 

Protected Attributes

 $session
 
 $table
 
 $user
 
 $form
 
 $logged = false
 
 $roles = array()
 
 $cfg
 

Detailed Description

Security class to check user rights. By default, allowing everything to the logged users

Definition at line 11 of file default.class.php.

Member Function Documentation

◆ addRole()

addRole (   $role)

Definition at line 256 of file default.class.php.

◆ afterInit()

afterInit ( )
protected

Definition at line 55 of file default.class.php.

◆ autoLogin()

autoLogin ( )
protected

Autologin the user with session vars or an eventual cookie

Definition at line 67 of file default.class.php.

◆ beforeInit()

beforeInit ( )
protectedinherited

Call just before the configuration initialisation

Definition at line 35 of file object.class.php.

◆ check()

check ( array  $url = null,
  $redirect = true 
)

Definition at line 277 of file default.class.php.

◆ cryptPass()

cryptPass (   $str,
  $plus = 'Password' 
)

Crypt a string with the function configured

Parameters
string$strThe string to crypt
null | string$plusIf need to used the second crypt function (or other configured)
Returns
string The crypted string

Definition at line 237 of file default.class.php.

◆ delRole()

delRole (   $role = null)

Definition at line 268 of file default.class.php.

◆ getAttr()

getAttr (   $name)
inherited

Get an attribute

Parameters
string$nameAttribute name
Returns
mixed|null The attribute or null if not set

Definition at line 48 of file object.class.php.

◆ getCfg()

getCfg ( )
inherited

Get the configuration object

Returns
config

Definition at line 67 of file object.class.php.

◆ getLoginForm()

getLoginForm ( array  $prm = array())

Definition at line 319 of file default.class.php.

◆ getPage()

getPage (   $type = 'login',
  $uri = false 
)
inherited

Get a configured page

Parameters
string$typePagename (login, logged, logout, forbidden)
bool$uriIndiciate if the url should be parsed with request::uri to be used directly
Returns
string The page url

Definition at line 101 of file security/abstract.class.php.

◆ getSession()

getSession ( )

Return the session object used for security

Returns
session_abstract

Definition at line 349 of file default.class.php.

◆ getUser()

getUser ( )

Get the user object

Returns
null|db_row

Definition at line 108 of file default.class.php.

◆ getUserFromCryptic()

getUserFromCryptic (   $cryptic)

Get a DB user from it's cryptic

Parameters
string$crypticCryptic
Returns
db_row|null

Definition at line 93 of file default.class.php.

◆ getWhereLogin()

getWhereLogin (   $login,
  $pass 
)
protected

Return the SQL Clause against login and password

Parameters
string$loginLogin
string$passClear password
Returns
string

Definition at line 148 of file default.class.php.

◆ hasRole()

hasRole (   $role = null)

Definition at line 261 of file default.class.php.

◆ hook()

hook (   $name)
protectedinherited

Function to be rewritten in eventual child to change the way security works Available actions:

  • autoLogin
  • autoLoginSession
  • login
  • redirectError
  • logout
Parameters
string$action

Definition at line 117 of file security/abstract.class.php.

◆ isContained()

isContained ( array  $url,
array  $checks 
)
protectedinherited

Indicate if a configuration array is contained in the url

Parameters
array$url
array$checks
Returns
bool True if a line in $checks matches the $url

Definition at line 126 of file security/abstract.class.php.

◆ isLogged()

isLogged ( )

Definition at line 99 of file default.class.php.

◆ logFromCryptic()

logFromCryptic (   $cryptic,
  $cookieStayConnected = false 
)

Log a session user using his cryptic

Parameters
string$cryptic
boolean$cookieStayConnectedIndicats if the stay connected cookie should be set

Definition at line 214 of file default.class.php.

◆ login() [1/2]

login (   $prm = null,
  $page = null 
)
abstractinherited

Login the current user

Parameters
mixed$prm
null | string$pageThe page where to be redirected. If null, config will be used
Returns
bool True if successful

◆ login() [2/2]

login (   $prm = null,
  $page = null,
  $redirectIfLogged = true 
)

Login the current user

Parameters
mixed$prm
null | string$pageThe page where to be redirected. If null, config will be used
boolean$redirectIfLoggedEnable the redirect when login is successful
Returns
bool True if successful

Definition at line 167 of file default.class.php.

◆ logout()

logout (   $prm = null)

Definition at line 244 of file default.class.php.

◆ protect()

protect (   $page = null)
inherited

Redirect the user if not logged

Parameters
null | string$pagePage to redirect or configured page forbidden if not provided
Returns
true|void True if allowed, will be redirected if not

Definition at line 88 of file security/abstract.class.php.

◆ saveCookieStayConnected()

saveCookieStayConnected ( )

Save the connection on the parametred cookie

Definition at line 224 of file default.class.php.

◆ saveLogin()

saveLogin (   $cookieStayConnected = false)
protected

Save the login. Set a new cryptic, save the DB user and save it in session.

Parameters
boolean$cookieStayConnectedIndicats if the stay connected cookie should be set

Definition at line 133 of file default.class.php.

◆ setAttr()

setAttr (   $name,
  $value 
)
inherited

Set an attribute

Parameters
string$nameAttribute name
mixed$valueAttribute value

Definition at line 58 of file object.class.php.

◆ setUser()

setUser ( db_row  $user,
  $saveLogin = true,
  $cookieStayConnected = false 
)

Set the logged user

Parameters
db_row$user
boolean$saveLoginIndicates if the session should be saved
boolean$cookieStayConnectedIndicats if the stay connected cookie should be set

Definition at line 121 of file default.class.php.

Field Documentation

◆ $cfg

$cfg
protectedinherited

Definition at line 17 of file object.class.php.

◆ $form

$form
protected

Definition at line 39 of file default.class.php.

◆ $logged

$logged = false
protected

Definition at line 46 of file default.class.php.

◆ $roles

$roles = array()
protected

Definition at line 53 of file default.class.php.

◆ $session

$session
protected

Definition at line 18 of file default.class.php.

◆ $table

$table
protected

Definition at line 25 of file default.class.php.

◆ $user

$user
protected

Definition at line 32 of file default.class.php.


The documentation for this class was generated from the following file:
Generated on Sun Oct 15 2017 22:25:21 for nyroFwk by doxygen 1.8.13