Example Web Pages


Table of Contents:

Example Error Page

An example error page which can be used for handling error messages coming for the server:

<?php
// Example PHP page to display errors generated by srv-idp.
// The URL of this page should be set in the "errorPageURL" configuration parameter of srv-idp.

$srvIdpURL = '';
$error_message = 'Unknown error';
if (!empty($_GET['e'])) {
    $data = base64_decode($_GET['e']);
    if ($data !== false) {
        $decoded = @gzinflate($data);
        if ($decoded !== false) {
            $json = json_decode($decoded, true);
            $srvIdpURL = $json['url'];
            filter_var($srvIdpURL, FILTER_SANITIZE_STRING);
            $error_message = $json['data'];
            filter_var($error_message, FILTER_SANITIZE_STRING);
        }
    }
}

$out = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" '
    .'"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'."\n"
    .'<html xmlns="http://www.w3.org/1999/xhtml">'."\n"
    .'<head>'."\n"
    .'<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'."\n"
    .'<title>SSO ERROR</title>'."\n"
    .'</head>'."\n"
    .'<body>'."\n"
    .'<h1>SSO ERROR</h1>'."\n"
    .'<h2>'.$error_message.'</h2>'."\n";

if (!empty($json)) {
    $out .= '<div><pre><code>'.json_encode($json, JSON_PRETTY_PRINT).'</code></pre></div>';
}

$out .= '<div>'
    .'<a href="'.$srvIdpURL.'/services" title="SSO Login">SSO LOGIN</a> '
    .'<a href="'.$srvIdpURL.'/logout" title="Terminate the main SSO session">SSO LOGOUT</a>'
    .'</div>'."\n";

$out .= '</body>'."\n"
    .'</html>'."\n";

echo $out;

Example Logout Page

<?php
// Example PHP page to display logout message from srv-idp.
// The URL of this page should be set in the "logoutPageURL" configuration parameter of srv-idp.

require 'sanitize.php';

$srvIdpURL = '';
if (!empty($_GET['x'])) {
    $data = base64_decode($_GET['x']);
    if ($data !== false) {
        $decoded = @gzinflate($data);
        if ($decoded !== false) {
            $json = json_decode($decoded, true);
            $srvIdpURL = $json['url'];
            filter_var($srvIdpURL, FILTER_SANITIZE_STRING);
        }
    }
}

$out = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" '
    .'"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'."\n"
    .'<html xmlns="http://www.w3.org/1999/xhtml">'."\n"
    .'<head>'."\n"
    .'<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'."\n"
    .'<title>SSO LOGOUT</title>'."\n"
    .'</head>'."\n"
    .'<body>'."\n"
    .'<h1>SSO LOGOUT</h1>'."\n"
    .'<h2>The IDP Session has been successfully deleted</h2>'."\n"
    .'<div><a href="'.$srvIdpURL.'/services" title="SSO Login">SSO LOGIN</a></div>'."\n";

if (!empty($json['splist'])) {
    filter_var($name, FILTER_SANITIZE_STRING);
    $logout = sanitizeURL($logout);
    $splist = '';
    foreach ($json['splist'] as $name => $logout) {
        $splist .= '<li><a href="'.$logout.'" title="Logout from '.$name.'" target="_blank">'.$name.'</a></li>'."\n";
    }
    if (!empty($splist)) {
        $out .= '<h3>Logout links of visited Service Providers:</h3>'."\n"
            .'<ul>'.$splist.'</ul>'."\n";
    }
}

$out .= '</body>'."\n"
    .'</html>'."\n";

echo $out;

Example Services Page

<?php
// Example PHP page to display services message from srv-idp.
// The URL of this page should be set in the "servicesPageURL" configuration parameter of srv-idp.

require 'sanitize.php';

$srvIdpURL = '';
if (!empty($_GET['x'])) {
    $data = base64_decode($_GET['x']);
    if ($data !== false) {
        $decoded = @gzinflate($data);
        if ($decoded !== false) {
            $json = json_decode($decoded, true);
            $srvIdpURL = $json['url'];
            filter_var($srvIdpURL, FILTER_SANITIZE_STRING);
        }
    }
}

$out = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" '
    .'"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'."\n"
    .'<html xmlns="http://www.w3.org/1999/xhtml">'."\n"
    .'<head>'."\n"
    .'<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'."\n"
    .'<title>SSO Authorized Service Providers</title>'."\n"
    .'</head>'."\n"
    .'<body>'."\n"
    .'<h1>SSO Authorized Service Providers</h1>'."\n"
    .'<div><a href="'.$srvIdpURL.'/logout" title="Terminate the main SSO session">SSO LOGOUT</a></div>'."\n";

if (!empty($json['splist'])) {
    filter_var($item['name'], FILTER_SANITIZE_STRING);
    filter_var($item['description'], FILTER_SANITIZE_STRING);
    $item['login'] = sanitizeURL($item['login']);
    $item['logout'] = sanitizeURL($item['logout']);
    $item['idplogin'] = sanitizeURL($item['idplogin']);
    $splist = '';
    foreach ($json['splist'] as $item) {
        $splist .= '<li><strong>'.$item['name'].'</strong><br />'
            .'<small><em>'.$item['description'].'</em></small>'
            .'<ul>'
            .'<li><a href="'.$item['idplogin'].'" title="IdP-Login: '
            .$item['description'].'">IdP-initiated login</a></li>'
            .'<li><a href="'.$item['login'].'" title="Login: '.$item['description'].'" target="_blank">Login Page</a></li>'
            .'<li><a href="'.$item['logout'].'" title="Logout: '.$item['description'].'" target="_blank">Logout</a></li>'
            .'</ul>'
            .'</li>';
    }
    if (!empty($splist)) {
        $out .= '<ul>'.$splist.'</ul>'."\n";
    }
}

$out .= '</body>'."\n"
    .'</html>'."\n";

echo $out;

Example Service Providers List

<?php
// Example PHP page to display the list of available Service Providers from srv-idp.

require 'sanitize.php';

$srvIdpURL = 'http://127.0.0.1:8000';

$splistURL = $srvIdpURL.'/splist';

$data = file_get_contents($splistURL);
if (!empty($data)) {
    $json = json_decode($data, true);
}

$out = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" '
    .'"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'."\n"
    .'<html xmlns="http://www.w3.org/1999/xhtml">'."\n"
    .'<head>'."\n"
    .'<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'."\n"
    .'<title>SSO Service Providers</title>'."\n"
    .'</head>'."\n"
    .'<body>'."\n"
    .'<h1>SSO Service Providers</h1>'."\n"
    .'<div>'
    .'<a href="'.$srvIdpURL.'/services" title="SSO Login">SSO LOGIN</a> '
    .'<a href="'.$srvIdpURL.'/logout" title="Terminate the main SSO session">SSO LOGOUT</a>'
    .'</div>'."\n";

if (!empty($json) && !empty($json['data'])) {
    filter_var($item['name'], FILTER_SANITIZE_STRING);
    filter_var($item['description'], FILTER_SANITIZE_STRING);
    $item['login'] = sanitizeURL($item['login']);
    $item['logout'] = sanitizeURL($item['logout']);
    $item['idplogin'] = sanitizeURL($item['idplogin']);
    $splist = '';
    foreach ($json['data'] as $item) {
        $splist .= '<li><strong>'.$item['name'].'</strong><br />'
            .'<small><em>'.$item['description'].'</em></small>'
            .'<ul>'
            .'<li><a href="'.$item['idplogin'].'" title="IdP-Login: '
            .$item['description'].'">IdP-initiated login</a></li>'
            .'<li><a href="'.$item['login'].'" title="Login: '.$item['description'].'" target="_blank">Login Page</a></li>'
            .'<li><a href="'.$item['logout'].'" title="Logout: '.$item['description'].'" target="_blank">Logout</a></li>'
            .'</ul>'
            .'</li>';
    }
    if (!empty($splist)) {
        $out .= '<ul>'.$splist.'</ul>'."\n";
    }
}

$out .= '</body>'."\n"
    .'</html>'."\n";

echo $out;

Example php sanitize page

<?php

// Sanitize URL string
function sanitizeURL($url)
{
    filter_var($url, FILTER_SANITIZE_URL);
    return preg_replace('/&(?!amp;)/', '&amp;', $url);
}

Top