diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..485dee6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea diff --git a/hooks/hook_frontpage.php b/hooks/hook_frontpage.php index 368ea60..48fe5ff 100644 --- a/hooks/hook_frontpage.php +++ b/hooks/hook_frontpage.php @@ -10,8 +10,13 @@ function aa_hook_frontpage(&$links) assert('is_array($links)'); assert('array_key_exists("links", $links)'); + $links['config'][] = array( + 'href' => SimpleSAML_Module::getModuleURL('aa/test.php'), + 'text' => 'Attribute Authority test page', + ); + $links['federation'][] = array( 'href' => SimpleSAML_Module::getModuleURL('aa/metadata.php?output=xhtml'), 'text' => '{aa:aa:text}', - ); + ); } diff --git a/templates/status.twig b/templates/status.twig new file mode 100644 index 0000000..ea335f3 --- /dev/null +++ b/templates/status.twig @@ -0,0 +1,89 @@ +{% set pagetitle = 'AttributeAuthority tester'|trans %} +{% extends 'base.twig' %} + +{% block content %} +
{{ name }} | + {%- endblock %} ++ {% block value %} + {{ value.class }} + {% endblock %} + | +
+ {{ debug }}
+
+ {% endif %}
+
+ {% if exception %}
+ + {{ exception }} ++ {% endif %} + +{% endblock %} diff --git a/www/test.php b/www/test.php new file mode 100644 index 0000000..3f65fb0 --- /dev/null +++ b/www/test.php @@ -0,0 +1,61 @@ +getTwig()->enableDebug(); +$t->getTwig()->addExtension(new Twig\Extension\DebugExtension()); + +$metadata = SimpleSAML\Metadata\MetaDataStorageHandler::getMetadataHandler(); + +$aaEntityId = $metadata->getMetaDataCurrentEntityID('attributeauthority-hosted'); +$aaMetadata = $metadata->getMetadataConfig($aaEntityId, 'attributeauthority-hosted'); + +$config = \SimpleSAML\Configuration::getInstance(); +$configauthproc = $config->getArray('authproc.aa', null); +$t->data['configauthproc'] = $configauthproc; + +$spMetadatas = $metadata->getList('saml20-sp-remote'); +$t->data['sps'] = $spMetadatas; + +$attributes = []; + +try { + if ($_POST['keyattributename'] && $_POST['keyattributevalue']) { + $attributes[$_POST['keyattributename']] = [0 => $_POST['keyattributevalue']]; + } + $t->data['attributes'] = $attributes; + + if ($_POST['sp']) { + $spEntityId = $_POST['sp']; + $spMetadataArray = $metadata->getMetaData($spEntityId, 'saml20-sp-remote'); + $pc = new \SimpleSAML\Auth\ProcessingChain($aaMetadata->toArray(), $spMetadataArray, 'aa'); + $authProcState = [ + 'Attributes' => $attributes, + 'Destination' => $spMetadataArray, + 'Source' => $aaMetadata->toArray(), + ]; + $pc->processStatePassive($authProcState); + $processedattributes = $authProcState['Attributes']; + $t->data['processedattributes'] = $processedattributes; + } + +} catch (Exception $exception) { + $t->data['exception'] = $exception->getMessage(); + $t->send(); +} + +if (!empty($debug)) { + $t->data['debug'] = var_export($debug, true); +} + +$t->send();