* start of a endpoint class

* add a new session parameter LogoutMethod,
   to store a way to make logout, like an HttpRequest
This commit is contained in:
<bdauvergne@entrouvert.com> 1207326812 +0200 0001-01-01 00:00:00 +00:00
parent b8fb24273b
commit 0938ce9219
3 changed files with 73 additions and 4 deletions

View File

@ -1,7 +1,7 @@
<?php
require_once('spkitlasso/include/lassospkit_public_api.inc.php');
require_once('spkitlasso/include/lassospkit_debug.inc.php');
require_once('spkitlasso/include/lassospkit_utils.inc.php');
require_once('spkitlasso/lassospkit_public_api.inc.php');
require_once('spkitlasso/lassospkit_debug.inc.php');
require_once('spkitlasso/lassospkit_utils.inc.php');
echo '<?xml version="1.0" encoding="UTF-8"?>';
function show($a) {

View File

@ -0,0 +1,60 @@
<?php
require_once('lassospkit_helper.inc.php');
require_once('lassospkit_utils.inc.php');
require_once('lassospkit_metadata.inc.php');
class LassoSPKitEndpoint {
var $dispatch_table = array();
var $protocol = null;
function LassoSPKitEndpoint($protocol) {
$this->__construct($protocol);
}
function __construct($protocol) {
$this->protocol = $protocol;
$this->addDispatch('/metadata', 'metadata');
}
function addDispatch($point, $method) {
$dispatch_table[$point] = $method;
}
function dispatchAndExit() {
if (! isset($_SERVER['PATH_INFO'])) {
throw new Exception('No PATH INFO');
}
$path_info = $_SERVER['PATH_INFO'];
$fname = $this->dispatch_table[$path_info];
if ($fname) {
$fname();
exit(0);
} else {
header("HTTP/1.0 404 Not Found");
exit(0);
}
}
// Urls
function metadata() {
$datadir = LassoSPKitHelper::getMetadataDir($this->protocol);
$pkey = $datadir . "/" . PRIVATE_KEY;
LassoSPKitUtils::extractPublicKey($pkey, $publickey, $error);
$content = LassoSPKitMetadataSAML2::generateMetadata(dirname(LassoSPKitUtils::mydir()), LassoSPKitConfig::get('organization'), $publickey);
if ($content) {
header('Content-type: text/xml');
echo $content;
}
}
// Verify that the host is the same has HTTP_HOST
function verifyUrl($host) {
$host = strstr('//', $host);
$pos = strpos($host, '/');
if ($pos !== FALSE) {
$host = substr($host, 0, $pos);
}
if ($host && isset($_SERVER['HTTP_HOST']) && $host != $_SERVER['HTTP_HOST']) {
echo "Bad referer '$host' != '" . $_SERVER['HTTP_HOST'] . "'";
exit(1);
}
}
}

View File

@ -42,7 +42,8 @@ class LassoSPKitUtilsSession {
'loginParams'=>0,
'federateParams'=>0,
'sloParams'=>0,
'defederationParams'=>0);
'defederationParams'=>0,
'LogoutMethod'=>0);
/** The keys that must not survive one communication (one set followed by one get). */
static $keysToClearAfterGet = array(
'LastError'=>0,
@ -184,6 +185,14 @@ class LassoSPKitUtilsSession {
$athis = self::getSingleton();
$athis->clear();
}
static function setLogoutMethod($logoutMethod) {
$athis = self::getSingleton();
$athis->set('LogoutMethod',$logoutMethod);
}
static function getLogoutMethod() {
$athis = self::getSingleton();
return $athis->get('LogoutMethod');
}
/** Set the NameID to transmit. */
static function setNameID($NameID) {
$athis = self::getSingleton();