Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
namespace Plexus\SSO\Resource;
use GuzzleHttp\Client;
use Plexus\SSO\Resource\Sign\ISign;
class SSOSession
{
private $baseServerUri;
const GET_SSO_SESSION_PATH = '/getSSO';
/**
* @var ISign
*/
private $signer;
public function __construct($baseServerUri, ISign $signer)
{
$this->baseServerUri = $baseServerUri;
$this->signer = $signer;
}
public function startPhpSession() {
session_start();
}
public function getSSOSession($returnUrl, $resourceId)
{
if (session_id() === '') {
$this->startPhpSession();
}
if(array_key_exists('HTTP_RESOURCE_SSO_SIGNATURE', $_REQUEST))
{
return;
}
$requestData = $returnUrl.$resourceId;
header('Resource-SSO-Signature: '.$this->signer->sign($requestData));
header('Location: '.$this->baseServerUri.SSOSession::GET_SSO_SESSION_PATH);
exit();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.