PHP Class Jasny\SSO\Broker

The broker lives on the website visited by the user. The broken doesn't have any user credentials stored. Instead it will talk to the SSO server in name of the user, verifying credentials and getting user information.
Datei anzeigen Open project: jasny/sso

Public Properties

Property Type Description
$broker string My identifier, given by SSO provider.
$token string Session token of the client

Protected Properties

Property Type Description
$secret string My secret word, given by SSO provider.
$url string Url of SSO server
$userinfo array User info recieved from the server.

Public Methods

Method Description
__call ( string $fn, array $args ) : mixed Magic method to do arbitrary request
__construct ( string $url, string $broker, string $secret ) Class constructor
attach ( string | true $returnUrl = null ) Attach our session to the user's session on the SSO server.
clearToken ( ) Clears session token
generateToken ( ) Generate session token
getAttachUrl ( array $params = [] ) : string Get URL to attach session at SSO server.
getUserInfo ( ) : object | null Get user information.
isAttached ( ) : boolean Check if we have an SSO token.
login ( string $username = null, string $password = null ) : array Log the client in at the SSO server.
logout ( ) Logout at sso server.

Protected Methods

Method Description
getCookieName ( ) : string Get the cookie name.
getRequestUrl ( string $command, array $params = [] ) : string Get the request url for a command
getSessionId ( ) : string Generate session id from session key
request ( string $method, string $command, array | string $data = null ) : array | object Execute on SSO server.

Method Details

__call() public method

Magic method to do arbitrary request
public __call ( string $fn, array $args ) : mixed
$fn string
$args array
return mixed

__construct() public method

Class constructor
public __construct ( string $url, string $broker, string $secret )
$url string Url of SSO server
$broker string My identifier, given by SSO provider.
$secret string My secret word, given by SSO provider.

attach() public method

Attach our session to the user's session on the SSO server.
public attach ( string | true $returnUrl = null )
$returnUrl string | true The URL the client should be returned to after attaching

clearToken() public method

Clears session token
public clearToken ( )

generateToken() public method

Generate session token
public generateToken ( )

getAttachUrl() public method

Get URL to attach session at SSO server.
public getAttachUrl ( array $params = [] ) : string
$params array
return string

getCookieName() protected method

Note: Using the broker name in the cookie name. This resolves issues when multiple brokers are on the same domain.
protected getCookieName ( ) : string
return string

getRequestUrl() protected method

Get the request url for a command
protected getRequestUrl ( string $command, array $params = [] ) : string
$command string
$params array Query parameters
return string

getSessionId() protected method

Generate session id from session key
protected getSessionId ( ) : string
return string

getUserInfo() public method

Get user information.
public getUserInfo ( ) : object | null
return object | null

isAttached() public method

Check if we have an SSO token.
public isAttached ( ) : boolean
return boolean

login() public method

Only brokers marked trused can collect and send the user's credentials. Other brokers should omit $username and $password.
public login ( string $username = null, string $password = null ) : array
$username string
$password string
return array user info

logout() public method

Logout at sso server.
public logout ( )

request() protected method

Execute on SSO server.
protected request ( string $method, string $command, array | string $data = null ) : array | object
$method string HTTP method: 'GET', 'POST', 'DELETE'
$command string Command
$data array | string Query or post parameters
return array | object

Property Details

$broker public_oe property

My identifier, given by SSO provider.
public string $broker
return string

$secret protected_oe property

My secret word, given by SSO provider.
protected string $secret
return string

$token public_oe property

Session token of the client
public string $token
return string

$url protected_oe property

Url of SSO server
protected string $url
return string

$userinfo protected_oe property

User info recieved from the server.
protected array $userinfo
return array