Single Sign-On for PHP (Ajax compatible)
This sso client it is based on the LegalThings/SSO developed by Jasny., (*1)
For a more indepth explanation of the SSO implementation, please read this article, (*2)
Installation
Install this library through composer, (*3)
composer require smoothbytes/sso
Usage
Broker (Client)
When creating a Jasny\SSO\Broker instance, you need to pass the server url, broker id and broker secret. The broker id
and secret needs to be registered at the server (so fetched when using getBrokerInfo($brokerId)
)., (*4)
Be careful: The broker id SHOULD be alphanumeric. In any case it MUST NOT contain the "-" character., (*5)
Next you need to call attach()
. This will generate a token an redirect the client to the server to attach the token
to the client's session. If the client is already attached, the function will simply return., (*6)
When the session is attached you can do actions as login/logout or get the user's info., (*7)
$broker = new Sal\SSO\Broker($serverUrl, $brokerId, $brokerSecret);
$broker->attach();
$user = $broker->getUserInfo();
echo json_encode($user);
For more information, checkout the broker
and ajax-broker
examples in sso-examples., (*8)
Notes
- This is only for login and logout to be able to register new clients you need to use SAL api