Class Auth
public static
|
#
GetInstance( )
Return singleton instance. If instance exists, return existing instance, if not, create new Auth service instance, store it and return it. |
public
|
#
__construct( )
Create new Auth service instance. For each configuration item- check if it is class definition and if it is, complete whole class definition. |
public
stdClass
&
|
|
public
|
|
public
|
#
SetExpirationSeconds( integer $expirationSeconds = 600 )
Set authorization expiration seconds, 10 minutes by default. |
public
|
#
SetPasswordHashSalt( string $passwordHashSalt = '' )
Set user's passwords hash salt, put here any string, every request the same. |
public
|
#
SetUserClass( string $userClass = '' )
Set authorization service user class to get store username from session stored from previous requests for 10 minutes by default, by sign in action to compare sender credentials with any user from your custom place and by sign out action to remove username from session. It has to extend \MvcCore\Ext\Auth\Virtual\User. |
public
|
#
SetControllerClass( string $controllerClass = '' )
Set authorization service controller class to handle signin and signout actions, it has to extend \MvcCore\Ext\Auth\Virtual\Controller. |
public
|
#
SetSignInFormClass( string $signInFormClass = '' )
Set authorization service sign in form class, to create, render and submit sign in user. it has to implement \MvcCore\Ext\Auth\Virtual\Form. |
public
|
#
SetSignOutFormClass( string $signOutFormClass = '' )
Set authorization service sign out form class, to create, render and submit sign out user. it has to implement \MvcCore\Ext\Auth\Virtual\Form. |
public
|
#
SetTranslator( callable $translator = NULL )
Set translator callable if you want to translate sign in and sign out forms labels, placeholders and error messages. |
public
|
#
SetSignedInUrl( string $signedInUrl = '' )
Set url to redirect user after sign in process was successfull. By default signed in url is the same as current request url, internaly configured by default authentication service pre request handler. |
public
|
#
SetSignedOutUrl( string $signedOutUrl = '' )
Set url to redirect user after sign out process was successfull. By default signed out url is the same as current request url, internaly configured by default authentication service pre request handler. |
public
|
#
SetErrorUrl( string $errorUrl = '' )
Set url to redirect user after sign in or sign out process was not successfull. By default signed in/out error url is the same as current request url, internaly configured by default authentication service pre request handler. |
public
|
#
SetSignInRoute( string|array|stdClass|
Set sign in route, where to navigate user browser after user clicks on submit button in sign in form and where to run authentication process. Route shoud be any pattern string without any groups, or route configuration array/stdClass or \MvcCore\Route instance. Sign in route is prepended before all routes in default service preroute handler. |
public
|
#
SetSignOutRoute( string|array|stdClass|
Set sign out route, where to navigate user browser after user clicks on submit button in sign out form and where to run deauthentication process. Route shoud be any pattern string without any groups, or route configuration array/stdClass or \MvcCore\Route instance. Sign out route is prepended before all routes in default service preroute handler. |
public
boolean
|
#
IsAuthenticated( )
Return TRUE if user is authenticated/signed in. If user is not loaded yet, load the user internaly by $auth->GetUser(); to start session and try to load user by session username record. |
public
|
|
public
|
#
SetUser(
Set user instance by you custom external authorization service. If user instance is not null, set internal $auth->userInitialized property to TRUE to not load user internaly again. |
public
|
#
GetForm( )
Return completed signin/signout form instance. Form instance completiion is processed only once, created instance is stored in $auth->form property. This method is always called by you, your application to set form into you custom template to render it for user. If user is not authenticated, sign in form is returned and if user is authenticated, opposite sign out form is returned. |
public
|
#
SetForm(
Set sign in/sign out form instance. Use this method only if you need sometimes to complete different form to render. |
public
|
|
public
|
#
PrepareHandler( )
Process necessary operations before request is routed. This method is called internaly by default and it's called by \MvcCore pre route handler initialized in $auth->Init(); method. |
public
|
#
PrepareRoutes( )
Second prepare handler internal method: - If controller class begins with substring containing this authentication class name, then it is obvious that controller has to have in route definition full class name defined by slash character in class name begin - so correct this controller class name if necessary to set up routes properly immediately on lines bellow. - If configured singin/out routes are still strings only, create from those strings new \MvcCore\Route instances into the same config place to add them into router immediately on lines bellow. |
public
|
#
PrepareAdresses( )
Third prepare handler internal method: - Set up sign in form success url, sign out form success url and error url for both ign in/out forms, as current request url by default. If any url is configured already, nothing is changed. |
public
|
#
PrepareRouter( )
Fourth prepare handler internal method: - Set up sign in or sign out route into router, only route which is currently by authenticated/not authenticated user necessary to process in $router->Route() processing. |
string |
VERSION
MvcCore Extension - Auth - version: Comparation by PHP function version_compare(); |
#
'4.2.0'
|
protected static
|
$instance
Singleton instance of authentication extension service. |
#
NULL
|
protected
|
$user
User model isntace or null if user is not authenticated in session. |
#
NULL
|
protected
|
$form
If user is authenticated in session, there is scompleted sign in form, else there is sign out form. |
#
NULL
|
protected
stdClass
|
$config
Authentication configuration, there is possible to change any configuration option ne by one by any setter method multiple values or by \MvcCore\Ext\Auth::GetInstance()->Configure([...]) method. Config array is retyped to stdClass in __constructor(). |
#
array(
'expirationSeconds' => 600, // 10 minutes
'userClass' => '\User',
'controllerClass' => '\Controller',
'signInFormClass' => '\SignInForm',
'signOutFormClass' => '\SignOutForm',
'signedInUrl' => '',
'signedOutUrl' => '',
'errorUrl' => '',
'signInRoute' => "#^/signin#",
'signOutRoute' => "#^/signout#",
'passwordHashSalt' => 'S3F8OI2P3X6ER1F6XY2Q9ZCY',
'translator' => NULL,
)
|
protected
boolean
|
$userInitialized
If true, authentication service allready try to load user from session and authentication detection os not necessary to run again. False by default. |
#
FALSE
|