1. Go to this page and download the library: Download fei/connect-client library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
fei / connect-client example snippets
$metadata = new Metadata();
// Configure your metadata... (See next chapter)
$config = (new Config())
->setDefaultTargetPath('/resource.php')
->setLogoutTargetPath('/');
$connect = new Connect(new Saml($metadata), $config);
$connect->handleRequest($_SERVER['REQUEST_URI'], $_SERVER['REQUEST_METHOD'])->emit();
$config = (new Config())
->registerProfileAssociation(
function (UsernamePasswordMessage $message) {
if ($message->getUsername() != 'test' || $message->getPassword() != 'test') {
throw new ProfileAssociationException('Profile not found', 400);
}
// Get allowed roles
$roles = $message->getRoles();
return (new ResponseMessage())->setRole('USER');
},
'/connect-profile-association'
);
// Create a Connect client instance
$connect = new Connect(new Saml($metadata), $config);
// Create a Token client instance
$client = new Token([Connect::OPTION_BASEURL => 'http://idp.dev:8080']);
// Create a Token
$token = $client->createToken($connect);
// Use the token...
// Create a Token client instance
$client = new Token([Connect::OPTION_BASEURL => 'http://idp.dev:8080']);
// Validate a Token
try {
$user = $client->validate($token);
} catch (\Exception $e) {
// Handle exception
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.