Connect a PHP App
PHP applications can authenticate using The Identity Hub. This can be done using one of the Authentication Endpoints like OAuth, OpenID Connect... or using the PHP SDK.
SDK and Demo App.
A preconfigured SDK can be downloaded from the App Configurations Details page.
You can download a non-configured SDK from here
A demo app can be found here.
Installing the SDK
- Download the SDK from the App Configurations Details page or download a non-configure SDK from here.
- To install just extract the zip file and add the SDK folder (theidentityhub) to directory of the project.
Configuring the SDK
The config.php file will contain the configured values for the specific The Identity Hub App:
$this->config->baseUrl = "https://www.theidentityhub.com/{tenant}";
$this->config->clientId = "[Client Id]";
$this->config->client_secret = "[ClientSecret]";
$this->config->redirectUri = "https://[Path to SDK]/theidentityhub/callback.php";
$this->config->signOutUri = "https://[Path to SDK]/theidentityhub/signout.php";
$this->config->signOutRedirectUri = "[Your redirect link]";
Fill out the signOutUri (replace [Path to SDK] with you web url) and the signOutRedirectUri (page url to redirect to after signout).
Initialization in application
To initialize the SDK in the application file where you want to use it, at the top of the file there should be:
require_once '[Your path to SDK]/theidentityhub.php';
session_start();
$ih = new TheIdentityHub;
The last line will initialize object which will pick up configuration and later when the user is logged on it will load main identity data.
Authenticate
The method getSignInURL() returns the link which will redirect to The Identity Hub's Authentication page:
$ih-> getSignInURL();
and also there is a method to get the sign out link:
$ih-> getSignOutURL();
which you can use anywhere in your application.
Getting information on the current user
The information about current user is loaded automatically with initialization and stored at main object property identity which is stdClass object.
Getting information on the current user roles
The information about current user's roles is accessible with method:
$ih->getRoles();
This method will fill up main object property $ih->roles with the array of object with property "name" in which will be stored role name.
Getting information on the current user's accounts
The information about current user's accounts is accessible with method:
$ih->getAccounts()
This method will fill up main object property $ih->accounts with the array of object with accounts data.