Main SSO class

Can by used by client application

package sso\lib

 Methods

Check if user is logged and make appropriate actions

auth(boolean $checkCredentials = TRUE, boolean $initApplication = TRUE, boolean $redirect = FALSE) : \sso\AuthUser

Redirect user to login page if not

Parameters

$checkCredentials

boolean

(default TRUE) FALSE for do not check credentials (only check sso login)

$initApplication

boolean

(default TRUE) FALSE for do not call application handler

$redirect

boolean

(default FALSE) TRUE for redirect to application

Returns

\sso\AuthUserreturn current user if logged

Redirect to login page when error occured during client init

clientError(integer $code, string $message, string $file, integer $line) 

Parameters

$code

integer

error code

$message

string

error message

$file

string

file name

$line

integer

line number

Redirect to login page when exception occured during client init

clientException(\sso\Exception $ex) 

Parameters

$ex

\sso\Exception

the exception

Display the SSO menu in page without the CSS in header.

displayFullMenuAfterBody() 

CSS will be added by javascript during page load

display the SSO menu

displayMenu(boolean $hidden = FALSE

Parameters

$hidden

boolean

TRUE for do not display menu

Return HTML link tag for CSS SSO menu

displayMenuCssHeader(boolean $hidden = FALSE

Parameters

$hidden

boolean

TRUE for do not display menu

Retrieve SsoClient instance

getInstance(string $path = NULL) : \sso\SsoClient
Static

Parameters

$path

string

web path of SSO. Needed for retrieve SSO from client application

Returns

\sso\SsoClientcurrent instance

Retrieve login user name

getLogin() : string

Returns

stringlogin user name

Retrieve the logout reason

getLogoutReason(integer $reason) : string
Static

Parameters

$reason

integer

self::AUTHKO*

Returns

stringlogout reason

Retrieve AuthUser

getUser() : \sso\AuthUser

Returns

\sso\AuthUserthe AuthUser returned by an auth method

Retrieve user name

getUserName() : string

Returns

stringuser name for display

Check user is logged

isLogged() : boolean

Returns

booleanTRUE if user is logged and enabled

Check user is SSO Admin

isSsoAdmin() : boolean

Returns

booleanTRUE if logged user is an SSO admin

Check a fullpath is a subpath of a basepath

isSubPath(string $fullPath, string $basePath) : TRUE

Examples :
/a/b/c is a subpath of /a/b
/a/b is a subpath of /a/b
/a/bc is NOT a subpath of /a/b

Parameters

$fullPath

string

full path to check

$basePath

string

the base path the full path have to begin with

Returns

TRUEif $fullPath start with $basePath and match exactly for last path element.

SSO pages list

pagesList() : array<mixed,string>

Returns

array<mixed,string>key => text

Register variables in session

registerGlobals(array<mixed,mixed> $variables) 

Variables will be restored at each page in global variables

Parameters

$variables

array<mixed,mixed>

variableName => variableValue

Set the URL for redirect after login

setRedirectUrl(string $url, boolean $init = FALSE

Parameters

$url

string

URL for redirect after login

$init

boolean

set to TRUE for initialize application before redirect

Redirect to another page

technicalRedirectTo(string $page, integer $code = 303, boolean $allowCaching = FALSE

Parameters

$page

string

the page, from server root

$code

integer

HTTP code, default 303

$allowCaching

boolean

FALSE by default, set to TRUE for not send HTTP headers prevent redirection caching

Check user can access to an application path

checkCredentials(string $appli) : boolean

currentApplication became $appli if user have access

Parameters

$appli

string

application path

Returns

booleanTRUE if user can access to this application, FALSE otherwise

Retrieve handler for application (or current application)

getClientHandler(string $appli = NULL) : \sso\Handler

Parameters

$appli

string

application path, or NULL for use current application

Returns

\sso\Handlerthe Handler instance for this application. Can be NULL

Initialize an application Handler

loadClientHandler(string $handler, string $appli) : \sso\Handler

Parameters

$handler

string

handler class name

$appli

string

application path

Returns

\sso\Handlerinstance

Build a new SsoClient instance

__construct(string $path = NULL

Parameters

$path

string

web path of SSO

Check session validity

checkUserAuth() : integer

Returns

integerstatus of session : self::AUTH_*

Retrieve an ID that identify the SSO menu (for handle browser cache)

getMenuId(boolean $hidden = FALSE) : string

Parameters

$hidden

boolean

TRUE for do not display menu

Returns

stringan ID prefixed by destination : application=ID

Try to init a client application

initApplication() 

Exceptions

\sso\Exception if something go wrong during init

Check current or provided page is a SSO page

isSsoPage(string $url = NULL) : boolean

Parameters

$url

string

URL to check, NULL will check current page

Returns

booleanTRUE if it's an SSO page

Redirect to current application (setted by setRedirectUrl() in session->SSO_REDIRECT)

resumeApplication() 

If user have credentials for this application, call the init handler and redirect.
If not, redirect to Application List page

 Properties

 

current session

$session : \sso\Session

Default

 

current application path

$currentApplication : string

Default

NULL
 

current instance

$instance : \sso\SsoClient

Default

NULL
Static
 

all logout reason : int (self::AUTH<em>KO</em>*) => logout reason

$logoutReasons : array<mixed,string>

Default

array(self::AUTH_KO_AGENT => \sso\L::logout_reason_invalid, self::AUTH_KO_IP => \sso\L::logout_reason_invalid, self::AUTH_KO_NO_SESSION => \sso\L::logout_reason_not_exists, self::AUTH_KO_TIMEOUT => \sso\L::logout_reason_expire, self::AUTH_KO_UNKNOWN => \sso\L::logout_reason_unknown, self::AUTH_KO_INIT_APP => \sso\L::logout_reason_auth)
Static

 Constants

 

Auth status : User Agent check failed

AUTH_KO_AGENT = 21 
 

Auth status : error occured during application init

AUTH_KO_INIT_APP = 40 
 

Auth status : IP check failed

AUTH_KO_IP = 20 
 

Auth status : session does not exists anymore

AUTH_KO_NO_SESSION = 11 
 

Auth status : session has expired

AUTH_KO_TIMEOUT = 30 
 

Auth status : unknown error occured

AUTH_KO_UNKNOWN = 99 
 

Auth status : OK

AUTH_OK = 10