PHP Class Jasny\SSO\Server

The SSO server is responsible of managing users sessions which are available for brokers. To use the SSO server, extend this class and implement the abstract methods. This class may be used as controller in an MVC application.
Datei anzeigen Open project: jasny/sso

Protected Properties

Property Type Description
$brokerId mixed
$cache Desarrolla2\Cache\Cache Cache that stores the special session data for the brokers.
$options array
$returnType string

Public Methods

Method Description
__construct ( array $options = [] ) Class constructor
attach ( ) Attach a user session to a broker session
login ( ) Authenticate
logout ( ) Log out
startBrokerSession ( ) Start the session for broker requests to the SSO server
userInfo ( ) Ouput user information as json.

Protected Methods

Method Description
authenticate ( string $username, string $password ) : Jasny\ValidationResult Authenticate using user credentials
createCacheAdapter ( ) : Desarrolla2\Cache\Cache Create a cache to store the broker session id.
detectReturnType ( ) Detect the type for the HTTP response.
fail ( string $message, integer $http_status = 500 ) An error occured.
generateAttachChecksum ( string $brokerId, string $token ) : string Generate session id from session token
generateSessionId ( string $brokerId, string $token ) : string Generate session id from session token
getBrokerInfo ( string $brokerId ) : array Get the secret key and other info of a broker
getBrokerSessionID ( ) Get session ID from header Authorization or from $_GET/$_POST
getSessionData ( type $key ) Get session data
getUserInfo ( string $username ) : array | object Get the information about a user
outputAttachSuccess ( ) Output on a successful attach
outputImage ( ) Output a 1x1px transparent image
setSessionData ( string $key, string $value ) Set session data
startUserSession ( ) Start the session when a user visits the SSO server
validateBrokerSessionId ( string $sid ) : string Validate the broker session id

Method Details

__construct() public method

Class constructor
public __construct ( array $options = [] )
$options array

attach() public method

Attach a user session to a broker session
public attach ( )

authenticate() abstract protected method

Authenticate using user credentials
abstract protected authenticate ( string $username, string $password ) : Jasny\ValidationResult
$username string
$password string
return Jasny\ValidationResult

createCacheAdapter() protected method

Create a cache to store the broker session id.
protected createCacheAdapter ( ) : Desarrolla2\Cache\Cache
return Desarrolla2\Cache\Cache

detectReturnType() protected method

Should only be done for an attach request.
protected detectReturnType ( )

fail() protected method

An error occured.
protected fail ( string $message, integer $http_status = 500 )
$message string
$http_status integer

generateAttachChecksum() protected method

Generate session id from session token
protected generateAttachChecksum ( string $brokerId, string $token ) : string
$brokerId string
$token string
return string

generateSessionId() protected method

Generate session id from session token
protected generateSessionId ( string $brokerId, string $token ) : string
$brokerId string
$token string
return string

getBrokerInfo() abstract protected method

Get the secret key and other info of a broker
abstract protected getBrokerInfo ( string $brokerId ) : array
$brokerId string
return array

getBrokerSessionID() protected method

Get session ID from header Authorization or from $_GET/$_POST
protected getBrokerSessionID ( )

getSessionData() protected method

Get session data
protected getSessionData ( type $key )
$key type

getUserInfo() abstract protected method

Get the information about a user
abstract protected getUserInfo ( string $username ) : array | object
$username string
return array | object

login() public method

Authenticate
public login ( )

logout() public method

Log out
public logout ( )

outputAttachSuccess() protected method

Output on a successful attach
protected outputAttachSuccess ( )

outputImage() protected method

Output a 1x1px transparent image
protected outputImage ( )

setSessionData() protected method

Set session data
protected setSessionData ( string $key, string $value )
$key string
$value string

startBrokerSession() public method

Start the session for broker requests to the SSO server
public startBrokerSession ( )

startUserSession() protected method

Start the session when a user visits the SSO server
protected startUserSession ( )

userInfo() public method

Ouput user information as json.
public userInfo ( )

validateBrokerSessionId() protected method

Validate the broker session id
protected validateBrokerSessionId ( string $sid ) : string
$sid string session id
return string the broker id

Property Details

$brokerId protected_oe property

protected mixed $brokerId
return mixed

$cache protected_oe property

Cache that stores the special session data for the brokers.
protected Cache,Desarrolla2\Cache $cache
return Desarrolla2\Cache\Cache

$options protected_oe property

protected array $options
return array

$returnType protected_oe property

protected string $returnType
return string