Overview

Namespaces

  • MvcCore
    • Ext
      • Auth
        • Virtual
      • Debug
        • Tracy
      • Form
        • Core
        • Validators
      • Request
      • Router
        • Lang
      • View
        • Helpers
  • None

Classes

  • Auth
  • Form
  • Overview
  • Namespace
  • Class
  • Tree

Class Auth

Namespace: MvcCore\Ext
Located at ext-auth/src/MvcCore/Ext/Auth.php
Methods summary
public static MvcCore\Ext\Auth
# GetInstance( )

Return singleton instance. If instance exists, return existing instance, if not, create new Auth service instance, store it and return it.

Return singleton instance. If instance exists, return existing instance, if not, create new Auth service instance, store it and return it.

Returns

MvcCore\Ext\Auth
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.

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 &
# GetConfig( )

Return configuration object.

Return configuration object.

Returns

stdClass
public MvcCore\Ext\Auth
# Configure( array $config = array() )

Set up authorization service configuration. Each array key must have key by default configuration item. If configuration item is class, it's checked if it exists.

Set up authorization service configuration. Each array key must have key by default configuration item. If configuration item is class, it's checked if it exists.

Parameters

$config

Returns

MvcCore\Ext\Auth
public MvcCore\Ext\Auth
# SetExpirationSeconds( integer $expirationSeconds = 600 )

Set authorization expiration seconds, 10 minutes by default.

Set authorization expiration seconds, 10 minutes by default.

Parameters

$expirationSeconds

Returns

MvcCore\Ext\Auth
public MvcCore\Ext\Auth
# SetPasswordHashSalt( string $passwordHashSalt = '' )

Set user's passwords hash salt, put here any string, every request the same.

Set user's passwords hash salt, put here any string, every request the same.

Parameters

$passwordHashSalt

Returns

MvcCore\Ext\Auth
public MvcCore\Ext\Auth
# 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.

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.

Parameters

$userClass

Returns

MvcCore\Ext\Auth
public MvcCore\Ext\Auth
# SetControllerClass( string $controllerClass = '' )

Set authorization service controller class to handle signin and signout actions, it has to extend \MvcCore\Ext\Auth\Virtual\Controller.

Set authorization service controller class to handle signin and signout actions, it has to extend \MvcCore\Ext\Auth\Virtual\Controller.

Parameters

$controllerClass

Returns

MvcCore\Ext\Auth
public MvcCore\Ext\Auth
# 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.

Set authorization service sign in form class, to create, render and submit sign in user. it has to implement \MvcCore\Ext\Auth\Virtual\Form.

Parameters

$signInFormClass

Returns

MvcCore\Ext\Auth
public MvcCore\Ext\Auth
# 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.

Set authorization service sign out form class, to create, render and submit sign out user. it has to implement \MvcCore\Ext\Auth\Virtual\Form.

Parameters

$signOutFormClass
$signInFormClass

Returns

MvcCore\Ext\Auth
public MvcCore\Ext\Auth
# SetTranslator( callable $translator = NULL )

Set translator callable if you want to translate sign in and sign out forms labels, placeholders and error messages.

Set translator callable if you want to translate sign in and sign out forms labels, placeholders and error messages.

Parameters

$translator

Returns

MvcCore\Ext\Auth
public MvcCore\Ext\Auth
# 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.

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.

Parameters

$signedInUrl

Returns

MvcCore\Ext\Auth
public MvcCore\Ext\Auth
# 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.

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.

Parameters

$signedOutUrl

Returns

MvcCore\Ext\Auth
public MvcCore\Ext\Auth
# 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.

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.

Parameters

$errorUrl

Returns

MvcCore\Ext\Auth
public MvcCore\Ext\Auth
# SetSignInRoute( string|array|stdClass|MvcCore\Route $signInRoute = NULL )

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.

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.

Parameters

$signInRoute

Returns

MvcCore\Ext\Auth
public MvcCore\Ext\Auth
# SetSignOutRoute( string|array|stdClass|MvcCore\Route $signOutRoute = NULL )

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.

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.

Parameters

$signOutRoute
$signInRoute

Returns

MvcCore\Ext\Auth
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.

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.

Returns

boolean
public MvcCore\Ext\Auth\Virtual\User &
# GetUser( )

Get authenticated user instance reference or null if user is not authenticated. 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.

Get authenticated user instance reference or null if user is not authenticated. 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.

Returns

MvcCore\Ext\Auth\Virtual\User
public MvcCore\Ext\Auth
# SetUser( MvcCore\Ext\Auth\Virtual\User & $user )

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.

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.

Parameters

$user

Returns

MvcCore\Ext\Auth
public MvcCore\Ext\Auth\SignInForm|MvcCore\Ext\Auth\SignOutForm|mixed &
# 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.

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.

Returns

MvcCore\Ext\Auth\SignInForm|MvcCore\Ext\Auth\SignOutForm|mixed
public MvcCore\Ext\Auth
# SetForm( MvcCore\Ext\Auth\Virtual\Form & $form )

Set sign in/sign out form instance. Use this method only if you need sometimes to complete different form to render.

Set sign in/sign out form instance. Use this method only if you need sometimes to complete different form to render.

Parameters

$form

Returns

MvcCore\Ext\Auth
public MvcCore\Ext\Auth
# Init( )

Initialize necessary authentication service handlers. Call this method always in Bootstrap before request is routed by: MvcCore\Ext\Auth::GetInstance()->Init();

Initialize necessary authentication service handlers. Call this method always in Bootstrap before request is routed by: MvcCore\Ext\Auth::GetInstance()->Init();

Returns

MvcCore\Ext\Auth
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.

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.

  • Try to load user by stored session username from previous requests.

  • 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.

  • 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.

  • 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.

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.

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.

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.

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.

Constants summary
string VERSION

MvcCore Extension - Auth - version: Comparation by PHP function version_compare();

MvcCore Extension - Auth - version: Comparation by PHP function version_compare();

See

http://php.net/manual/en/function.version-compare.php
# '4.2.0'
Properties summary
protected static MvcCore\Ext\Auth $instance

Singleton instance of authentication extension service.

Singleton instance of authentication extension service.

# NULL
protected MvcCore\Ext\Auth\Virtual\User $user

User model isntace or null if user is not authenticated in session.

User model isntace or null if user is not authenticated in session.

# NULL
protected MvcCore\Ext\Auth\Virtual\Form $form

If user is authenticated in session, there is scompleted sign in form, else there is sign out 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().

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.

If true, authentication service allready try to load user from session and authentication detection os not necessary to run again. False by default.

# FALSE
MvcCore API documentation generated by ApiGen