diff --git a/www/example-simple/attributequery.php b/www/example-simple/attributequery.php deleted file mode 100644 index 76932baf6f6c91e849a294c76fcc58d277db40b6..0000000000000000000000000000000000000000 --- a/www/example-simple/attributequery.php +++ /dev/null @@ -1,173 +0,0 @@ -<?php - -/** - * WARNING: - * - * THIS FILE IS DEPRECATED AND WILL BE REMOVED IN FUTURE VERSIONS - * - * @deprecated - */ - -require_once('../_include.php'); - -$session = SimpleSAML_Session::getSessionFromRequest(); -$metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler(); - -SimpleSAML_Logger::warning('The file example-simple/attributequery.php is deprecated and will be removed in future versions.'); - -$spEntityId = $metadata->getMetaDataCurrentEntityID('saml20-sp-hosted'); - -function sendQuery($dataId, $url, $nameId) { - assert('is_string($dataId)'); - assert('is_string($url)'); - assert('is_array($nameId)'); - - SimpleSAML_Logger::debug('attributequery - sending request'); - - $query = new SAML2_AttributeQuery(); - $query->setRelayState($dataId); - $query->setDestination($url); - $query->setIssuer($GLOBALS['spEntityId']); - $query->setNameId($nameId); - - $binding = new SAML2_HTTPRedirect(); - $binding->send($query); -} - -function handleResponse() { - try { - $binding = SAML2_Binding::getCurrentBinding(); - $response = $binding->receive(); - } catch (Exception $e) { - return; - } - - SimpleSAML_Logger::debug('attributequery - received message.'); - - if (!($response instanceof SAML2_Response)) { - throw new SimpleSAML_Error_Exception('Unexpected message received to attribute query example.'); - } - - $idpEntityId = $response->getIssuer(); - if ($idpEntityId === NULL) { - throw new SimpleSAML_Error_Exception('Missing issuer in response.'); - } - - $idpMetadata = $GLOBALS['metadata']->getMetaDataConfig($idpEntityId, 'saml20-idp-remote'); - $spMetadata = $GLOBALS['metadata']->getMetaDataConfig($GLOBALS['spEntityId'], 'saml20-sp-hosted'); - - $assertion = sspmod_saml_Message::processResponse($spMetadata, $idpMetadata, $response); - if (count($assertion) > 1) { - throw new SimpleSAML_Error_Exception('More than one assertion in received response.'); - } - $assertion = $assertion[0]; - - $dataId = $response->getRelayState(); - if ($dataId === NULL) { - throw new SimpleSAML_Error_Exception('RelayState was lost during request.'); - } - - $data = $GLOBALS['session']->getData('attributequeryexample:data', $dataId); - $data['attributes'] = $assertion->getAttributes(); - $GLOBALS['session']->setData('attributequeryexample:data', $dataId, $data, 3600); - - SimpleSAML_Utilities::redirectTrustedURL(SimpleSAML_Utilities::selfURLNoQuery(), - array('dataId' => $dataId)); -} - -handleResponse(); - -$defNameId = $session->getNameId(); -if (empty($defNameId)) { - $defNameId = array(); -} -if (!array_key_exists('Value', $defNameId)) { - $defNameId['Value'] = SimpleSAML_Utilities::generateID(); -} -if (!array_key_exists('Format', $defNameId)) { - $defNameId['Format'] = SAML2_Const::NAMEID_TRANSIENT; -} -if (!array_key_exists('NameQualifier', $defNameId) || $defNameId['NameQualifier'] === NULL) { - $defNameId['NameQualifier'] = ''; -} -if (!array_key_exists('SPNameQualifier', $defNameId) || $defNameId['SPNameQualifier'] === NULL) { - $defNameId['SPNameQualifier'] = ''; -} - - -if (array_key_exists('dataId', $_REQUEST)) { - $dataId = (string)$_REQUEST['dataId']; - $data = $session->getData('attributequeryexample:data', $dataId); - if ($data == NULL) { - $data = array(); - } -} else { - $dataId = SimpleSAML_Utilities::generateID(); - $data = array(); -} - -if (array_key_exists('nameIdFormat', $_REQUEST)) { - $data['nameIdFormat'] = (string)$_REQUEST['nameIdFormat']; -} elseif (!array_key_exists('nameIdFormat', $data)) { - $data['nameIdFormat'] = $defNameId['Format']; -} - -if (array_key_exists('nameIdValue', $_REQUEST)) { - $data['nameIdValue'] = (string)$_REQUEST['nameIdValue']; -} elseif (!array_key_exists('nameIdValue', $data)) { - $data['nameIdValue'] = $defNameId['Value']; -} - -if (array_key_exists('nameIdQualifier', $_REQUEST)) { - $data['nameIdQualifier'] = (string)$_REQUEST['nameIdQualifier']; -} elseif (!array_key_exists('nameIdQualifier', $data)) { - $data['nameIdQualifier'] = $defNameId['NameQualifier']; -} - -if (array_key_exists('nameIdSPQualifier', $_REQUEST)) { - $data['nameIdSPQualifier'] = (string)$_REQUEST['nameIdSPQualifier']; -} elseif (!array_key_exists('nameIdSPQualifier', $data)) { - $data['nameIdSPQualifier'] = $defNameId['SPNameQualifier']; -} - - -if (array_key_exists('url', $_REQUEST)) { - $data['url'] = (string)$_REQUEST['url']; -} elseif (!array_key_exists('url', $data)) { - $data['url'] = SimpleSAML_Module::getModuleURL('exampleattributeserver/attributeserver.php'); -} - -if (!array_key_exists('attributes', $data)) { - $data['attributes'] = NULL; -} - -$session->setData('attributequeryexample:data', $dataId, $data, 3600); - -if (array_key_exists('send', $_REQUEST)) { - - $nameId = array( - 'Format' => $data['nameIdFormat'], - 'Value' => $data['nameIdValue'], - 'NameQualifier' => $data['nameIdQualifier'], - 'SPNameQualifier' => $data['nameIdSPQualifier'], - ); - if (empty($nameId['NameQualifier'])) { - $nameId['NameQualifier'] = NULL; - } - if (empty($nameId['SPNameQualifier'])) { - $nameId['SPNameQualifier'] = NULL; - } - - sendQuery($dataId, $data['url'], $nameId); -} - -$t = new SimpleSAML_XHTML_Template(SimpleSAML_Configuration::getInstance(), 'attributequery.php'); -$t->data['dataId'] = $dataId; -$t->data['url'] = $data['url']; -$t->data['nameIdFormat'] = $data['nameIdFormat']; -$t->data['nameIdValue'] = $data['nameIdValue']; -$t->data['nameIdQualifier'] = $data['nameIdQualifier']; -$t->data['nameIdSPQualifier'] = $data['nameIdSPQualifier']; -$t->data['attributes'] = $data['attributes']; - -$t->show(); diff --git a/www/example-simple/hostnames.php b/www/example-simple/hostnames.php deleted file mode 100644 index e92e26dd640bdfaed3428e2ff13f3291e8b00405..0000000000000000000000000000000000000000 --- a/www/example-simple/hostnames.php +++ /dev/null @@ -1,47 +0,0 @@ -<?php - -require_once('../_include.php'); - -/* Load simpleSAMLphp, configuration */ -$config = SimpleSAML_Configuration::getInstance(); -$session = SimpleSAML_Session::getSessionFromRequest(); - -/* Check if valid local session exists.. */ -SimpleSAML_Utilities::requireAdmin(); - - - - - -$attributes = array(); - - -$attributes['HTTP_HOST'] = array($_SERVER['HTTP_HOST']); -$attributes['HTTPS'] = array($_SERVER['HTTPS']); -$attributes['SERVER_PROTOCOL'] = array($_SERVER['SERVER_PROTOCOL']); -$attributes['SERVER_PORT'] = array($_SERVER['SERVER_PORT']); - -$attributes['Utilities_getBaseURL()'] = array(SimpleSAML_Utilities::getBaseURL()); -$attributes['Utilities_getSelfHost()'] = array(SimpleSAML_Utilities::getSelfHost()); -$attributes['Utilities_selfURLhost()'] = array(SimpleSAML_Utilities::selfURLhost()); -$attributes['Utilities_selfURLNoQuery()'] = array(SimpleSAML_Utilities::selfURLNoQuery()); -$attributes['Utilities_getSelfHostWithPath()'] = array(SimpleSAML_Utilities::getSelfHostWithPath()); -$attributes['Utilities_getFirstPathElement()'] = array(SimpleSAML_Utilities::getFirstPathElement()); -$attributes['Utilities_selfURL()'] = array(SimpleSAML_Utilities::selfURL()); - - - - - -$et = new SimpleSAML_XHTML_Template($config, 'status.php'); - -$et->data['header'] = '{status:header_diagnostics}'; -$et->data['remaining'] = 'na'; -$et->data['attributes'] = $attributes; -$et->data['valid'] = 'na'; -$et->data['logout'] = null; - -$et->show(); - - -?> \ No newline at end of file diff --git a/www/example-simple/saml2-example.php b/www/example-simple/saml2-example.php deleted file mode 100644 index 5fdc83b60df93c0ca951bd9253819c6fed42598c..0000000000000000000000000000000000000000 --- a/www/example-simple/saml2-example.php +++ /dev/null @@ -1,90 +0,0 @@ -<?php - -/** - * WARNING: - * - * THIS FILE IS DEPRECATED AND WILL BE REMOVED IN FUTURE VERSIONS - * - * @deprecated - */ - -/** - * The _include script registers a autoloader for the simpleSAMLphp libraries. It also - * initializes the simpleSAMLphp config class with the correct path. - */ -require_once('../_include.php'); - -/* - * Explisit instruct consent page to send no-cache header to browsers - * to make sure user attribute information is not store on client disk. - * - * In an vanilla apache-php installation is the php variables set to: - * session.cache_limiter = nocache - * so this is just to make sure. - */ -session_cache_limiter('nocache'); - - -/* Load simpleSAMLphp, configuration and metadata */ -$config = SimpleSAML_Configuration::getInstance(); -$session = SimpleSAML_Session::getSessionFromRequest(); - -SimpleSAML_Logger::warning('The file example-simple/saml2-example.php is deprecated and will be removed in future versions.'); - -/** - * Check if valid local session exists, and the authority is the SAML 2.0 SP - * part of simpleSAMLphp. If the currenct session is not valid, the user is - * redirected to the initSSO.php script. This script will send the user to - * a SAML 2.0 IdP with an authentication request, and thereafter the user - * will be asked at the SAML 2.0 IdP to authenticate. You add one important - * parameter when you send the user to the initSSO script, the RelayState. - * The RelayState URL is the URL that you want to send the user to after - * authentication is complete - and usually you want to send the user back - * to this very page. To get the URL of the current page we use the selfURL() - * helper function. - * - * When the user is complete authenticating at the IdP, the user will be sent - * back to the AssertionConsumerService.php script in simpleSAMLphp. The assertion - * is validated, and if trusted, the user's session is set to be valid, and the user - * is redirected back to the RelayState URL. And then the user is here again, but - * authenticated, and therefore passes the if sentence below, and moves on to - * retrieving attributes from the session. - */ -if (!$session->isValid('saml2') ) { - SimpleSAML_Utilities::redirectTrustedURL( - '/' . $config->getBaseURL() . 'saml2/sp/initSSO.php', - array('RelayState' => SimpleSAML_Utilities::selfURL()) - ); -} - -/* Prepare attributes for presentation -* and call a hook function for organizing the attribute array -*/ -$attributes = $session->getAuthData('saml2', 'Attributes'); -$para = array( - 'attributes' => &$attributes -); -SimpleSAML_Module::callHooks('attributepresentation', $para); - -/* - * The attributes variable now contains all the attributes. So this variable is basicly all you need to perform integration in - * your PHP application. - * - * To debug the content of the attributes variable, do something like: - * - * print_r($attributes); - * - */ - -$t = new SimpleSAML_XHTML_Template($config, 'status.php', 'attributes'); - -$t->data['header'] = '{status:header_saml20_sp}'; -$t->data['remaining'] = $session->getAuthData('saml2', 'Expire') - time(); -$t->data['sessionsize'] = $session->getSize(); -$t->data['attributes'] = $attributes; -$t->data['logouturl'] = '/' . $config->getBaseURL() . 'saml2/sp/initSLO.php?RelayState=/' . - $config->getBaseURL() . 'logout.php'; -$t->show(); - - -?> \ No newline at end of file diff --git a/www/example-simple/shib13-example.php b/www/example-simple/shib13-example.php deleted file mode 100644 index 4b275ed8369af34edd8aed9e00f840bb35d1fd46..0000000000000000000000000000000000000000 --- a/www/example-simple/shib13-example.php +++ /dev/null @@ -1,89 +0,0 @@ -<?php - -/** - * WARNING: - * - * THIS FILE IS DEPRECATED AND WILL BE REMOVED IN FUTURE VERSIONS - * - * @deprecated - */ - -/** - * The _include script registers a autoloader for the simpleSAMLphp libraries. It also - * initializes the simpleSAMLphp config class with the correct path. - */ -require_once('../_include.php'); - -/* - * Explisit instruct consent page to send no-cache header to browsers - * to make sure user attribute information is not store on client disk. - * - * In an vanilla apache-php installation is the php variables set to: - * session.cache_limiter = nocache - * so this is just to make sure. - */ -session_cache_limiter('nocache'); - - -/* Load simpleSAMLphp, configuration and metadata */ -$config = SimpleSAML_Configuration::getInstance(); -$session = SimpleSAML_Session::getSessionFromRequest(); - -SimpleSAML_Logger::warning('The file example-simple/shib13-example.php is deprecated and will be removed in future versions.'); - -/** - * Check if valid local session exists, and the authority is the Shib 1.3 SP - * part of simpleSAMLphp. If the currenct session is not valid, the user is - * redirected to the initSSO.php script. This script will send the user to - * a Shib 1.3 IdP with an authentication request, and thereafter the user - * will be asked at the Shib 1.3 IdP to authenticate. You add one important - * parameter when you send the user to the initSSO script, the RelayState. - * The RelayState URL is the URL that you want to send the user to after - * authentication is complete - and usually you want to send the user back - * to this very page. To get the URL of the current page we use the selfURL() - * helper function. - * - * When the user is complete authenticating at the IdP, the user will be sent - * back to the AssertionConsumerService.php script in simpleSAMLphp. The assertion - * is validated, and if trusted, the user's session is set to be valid, and the user - * is redirected back to the RelayState URL. And then the user is here again, but - * authenticated, and therefore passes the if sentence below, and moves on to - * retrieving attributes from the session. - */ -if (!$session->isValid('shib13') ) { - SimpleSAML_Utilities::redirectTrustedURL( - '/' . $config->getBaseURL() . 'shib13/sp/initSSO.php', - array('RelayState' => SimpleSAML_Utilities::selfURL()) - ); -} - -/* Prepare attributes for presentation -* and call a hook function for organizing the attribute array -*/ -$attributes = $session->getAuthData('shib13', 'Attributes'); -$para = array( - 'attributes' => &$attributes -); -SimpleSAML_Module::callHooks('attributepresentation', $para); - -/* - * The attributes variable now contains all the attributes. So this variable is basicly all you need to perform integration in - * your PHP application. - * - * To debug the content of the attributes variable, do something like: - * - * print_r($attributes); - * - */ - -$t = new SimpleSAML_XHTML_Template($config, 'status.php', 'attributes'); - -$t->data['header'] = '{status:header_shib}'; -$t->data['remaining'] = $session->getAuthData('shib13', 'Expire') - time(); -$t->data['sessionsize'] = $session->getSize(); -$t->data['attributes'] = $attributes; -$t->data['logout'] = null; -$t->show(); - - -?> diff --git a/www/example-simple/verysimple.php b/www/example-simple/verysimple.php deleted file mode 100644 index 5c981ee4bf102908a8ef56278a2eed5475a34ead..0000000000000000000000000000000000000000 --- a/www/example-simple/verysimple.php +++ /dev/null @@ -1,139 +0,0 @@ -<?php - -/** - * WARNING: - * - * THIS FILE IS DEPRECATED AND WILL BE REMOVED IN FUTURE VERSIONS - * - * @deprecated - */ - -/* - * This script is meant as an example of how simpleSAMLphp can be - * accessed from an existing application. - * - * As such, it does not use any of the simpleSAMLphp templates. - */ - - -/* - * We need access to the various simpleSAMLphp classes. These are loaded - * by the simpleSAMLphp autoloader. - */ -require_once('../../lib/_autoload.php'); - -SimpleSAML_Logger::warning('The file example-simple/verysimple.php is deprecated and will be removed in future versions.'); - -/* - * We use the default-sp authentication source. - */ -$as = new SimpleSAML_Auth_Simple('default-sp'); - -/* This handles logout requests. */ -if (array_key_exists('logout', $_REQUEST)) { - /* - * We redirect to the current URL _without_ the query parameter. This - * avoids a redirect loop, since otherwise it will access the logout - * endpoint again. - */ - $as->logout(SimpleSAML_Utilities::selfURLNoQuery()); - /* The previous function will never return. */ -} - -if (array_key_exists('login', $_REQUEST)) { - /* - * If the login parameter is requested, it means that we should log - * the user in. We do that by requiring the user to be authenticated. - * - * Note that the requireAuth-function will preserve all GET-parameters - * and POST-parameters by default. - */ - $as->requireAuth(); - /* The previous function will only return if the user is authenticated. */ -} - -if (array_key_exists('message', $_POST)) { - /* - * We require authentication while posting a message. If the user is - * authenticated, the message will be shown. - * - * Since POST parameters are preserved during requireAuth-processing, - * the message will be presented to the user after the authentication. - */ - $as->requireAuth(); - $message = $_POST['message']; -} else { - $message = NULL; -} - -/* - * We set a variable depending on whether the user is authenticated or not. - * This allows us to show the user a login link or a logout link depending - * on the authentication state. - */ -$isAuth = $as->isAuthenticated(); - - -/* - * Retrieve the users attributes. We will list them if the user - * is authenticated. - */ -$attributes = $as->getAttributes(); - -?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> - <meta http-equiv="content-type" content="text/html; charset=utf-8" /> - <title>Simple test</title> -</head> -<body> - -<h1>Simple auth test</h1> - -<?php -/* Show a logout message if authenticated or a login message if not. */ -if ($isAuth) { - echo '<p>You are currently authenticated. <a href="?logout">Log out</a>.</p>'; -} else { - echo '<p>You are not authenticated. <a href="?login">Log in</a>.</p>'; -} -?> - -<p>The following form makes it possible to test requiering authentication -in a POST handler. Try to submit the message while unauthenticated.</p> -<form method="post" action="#"> -<input type="text" name="message" id="msg" /> -<input type="submit" value="Post message" /> -</form> - -<?php - -/* Print out the message if it is present. */ -if ($message !== NULL) { - echo '<h2>Message</h2>'; - echo '<p>' . htmlspecialchars($message) . '</p>'; -} - -/* Print out the attributes if the user is authenticated. */ -if ($isAuth) { - echo '<h2>Attributes</h2>'; - echo '<dl>'; - - foreach ($attributes as $name => $values) { - echo '<dt>' . htmlspecialchars($name) . '</dt>'; - echo '<dd><ul>'; - foreach ($values as $value) { - echo '<li>' . htmlspecialchars($value) . '</li>'; - } - echo '</ul></dd>'; - } - - echo '</dl>'; -} - -?> - -</body> -</html> \ No newline at end of file diff --git a/www/example-simple/wsfed-example.php b/www/example-simple/wsfed-example.php deleted file mode 100644 index 166fc61b3f4f0150b433585b7f3402f5b8dfd8c9..0000000000000000000000000000000000000000 --- a/www/example-simple/wsfed-example.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php - -/** - * WARNING: - * - * THIS FILE IS DEPRECATED AND WILL BE REMOVED IN FUTURE VERSIONS - * - * @deprecated - */ - -require_once('../_include.php'); - -$config = SimpleSAML_Configuration::getInstance(); -$session = SimpleSAML_Session::getSessionFromRequest(); - -SimpleSAML_Logger::warning('The file example-simple/wsfed-example.php is deprecated and will be removed in future versions.'); - -if (!$session->isValid('wsfed') ) { - SimpleSAML_Utilities::redirectTrustedURL( - '/' . $config->getBaseURL() . 'wsfed/sp/initSSO.php', - array('RelayState' => SimpleSAML_Utilities::selfURL()) - ); -} - -$attributes = $session->getAuthData('wsfed', 'Attributes'); - -$t = new SimpleSAML_XHTML_Template($config, 'status.php', 'attributes'); - -$t->data['header'] = '{status:header_wsfed}'; -$t->data['remaining'] = $session->getAuthData('wsfed', 'Expire') - time(); -$t->data['sessionsize'] = $session->getSize(); -$t->data['attributes'] = $attributes; -$t->data['logouturl'] = '/' . $config->getBaseURL() . 'wsfed/sp/initSLO.php?RelayState=/' . $config->getBaseURL() . 'logout.php'; -$t->show(); - - -?>