Single Sign On
Overview
Single Sign-On allows you to securely log your users into your personally branded user portal ( https://[your-domain].voiceportals.net ) securely from your current website.
We have chosen to use JSON Web Tokens (JWT) as our SSO solution. You can get all the information you need about it at https://jwt.io
For the quick how-to of JWT and SSO with our site, we will be giving example code using PHP, using the library available at https://github.com/firebase/php-jwt.
Information you will need:
- User ID -- Your user ID. This can be found by going to https://apiv1.teleapi.net/user/get?token=your-api-token
- Token -- Your API token, used for everything else on the API as well
- Username -- The username of the user account you would like to log in via SSO
- SSO Key -- This is a field available to you in the https://apiv1.teleapi.net/resellers/list?token=your-api-token call and the https://apiv1.teleapi.net/customers/list?token=your-api-token call.
In order to log a user in via SSO, you need to have all of this information available to you. Then, you will generate a JWT token with username and sso_key inside the payload, encoded using your API token.
Example
$token = 'your-api-token';
$sso_key = 'your-users-sso-key';
$username = 'your-users-username';
$jwt = array(
'username' => $username,
'sso_key' => $sso_key
);
$jwt = Firebase\JWT\JWT::encode($jwt, $token);
echo $jwt;
// prints something to the effect of: // ``` eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6InlvdS11c2Vycy11c2VybmFtZSIsInNzb19rZXkiOiJ5b3VyLXVzZXJzLXNzby1rZXkifQ.XdS2AAqCE5bQi6w59Rq0QUgrXC6ApjbFN0p-ZoMr-2c
It's that simple. You then take the $jwt variable and pop it into a URL: https://your-domain.voiceportals.net/sso/your-user-id/jwt-token
So, say your user id is 238, your domain is awesomevoip and your token is the one generated above, the URL would look like:
```
You now can give your users direct access into your white labeled user portal directly, without a log in screen. Cool, huh?