diff --git a/mymodule/templates/.gitkeep b/mymodule/templates/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/mymodule/templates/selectsource.tpl.php b/mymodule/templates/selectsource.tpl.php new file mode 100644 index 0000000000000000000000000000000000000000..f520ef802370a35f4b5c590538f49c6418ce5f4a --- /dev/null +++ b/mymodule/templates/selectsource.tpl.php @@ -0,0 +1,28 @@ +<?php +$this->data['header'] = $this->t('{multiauth:multiauth:select_source_header}'); +$this->includeAtTemplateBase('includes/header.php'); +?> + +<h2><?php echo 'Benutzerkonto auswählen' ?></h2> + +<p><?php echo 'Bitte wählen Sie ein Benutzerkonto aus, mit dem Sie sich authentifizieren wollen:' ?></p> + +<form action="/idp/module.php/multiauth/selectsource.php" method="get"> + <input type="hidden" name="AuthState" value="<?php echo htmlspecialchars($this->data['authstate']); ?>" /> +<?php +echo '<div>'; +foreach ($this->data['sources'] as $source) { + if ($source['source'] === $this->data['preferred']) { + $autofocus = ' autofocus="autofocus"'; + } else { + $autofocus = ''; + } + $name = 'src-'.base64_encode($source['source']); + echo '<input type="submit" class="'.htmlspecialchars($source['css_class']).'" name="'.htmlspecialchars($name).'"'.$autofocus.' '. + 'id="button-'.htmlspecialchars($source['source']).'" '. + 'value="'.htmlspecialchars($source['text']).'" ></input>'; +} +echo '</div>'; +?> +</form> +<?php $this->includeAtTemplateBase('includes/footer.php'); diff --git a/mymodule/themes/fancytheme/multiauth/.gitkeep b/mymodule/themes/fancytheme/multiauth/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/mymodule/themes/fancytheme/multiauth/selectsource.php b/mymodule/themes/fancytheme/multiauth/selectsource.php new file mode 100644 index 0000000000000000000000000000000000000000..e6952065ee11a3aa0f76df9591f28c576bd10177 --- /dev/null +++ b/mymodule/themes/fancytheme/multiauth/selectsource.php @@ -0,0 +1,85 @@ +<?php + +/** + * This page shows a list of authentication sources. When the user selects + * one of them if pass this information to the + * \SimpleSAML\Module\multiauth\Auth\Source\MultiAuth class and call the + * delegateAuthentication method on it. + * + * @author Lorenzo Gil, Yaco Sistemas S.L. + * @package SimpleSAMLphp + */ + +// Retrieve the authentication state +if (!array_key_exists('AuthState', $_REQUEST)) { + throw new \SimpleSAML\Error\BadRequest('Missing AuthState parameter.'); +} +$authStateId = $_REQUEST['AuthState']; + +/** @var array $state */ +$state = \SimpleSAML\Auth\State::loadState($authStateId, \SimpleSAML\Module\multiauth\Auth\Source\MultiAuth::STAGEID); + +if (array_key_exists("\SimpleSAML\Auth\Source.id", $state)) { + $authId = $state["\SimpleSAML\Auth\Source.id"]; + /** @var \SimpleSAML\Module\multiauth\Auth\Source\MultiAuth $as */ + $as = \SimpleSAML\Auth\Source::getById($authId); +} else { + $as = null; +} + +$source = null; +if (array_key_exists('source', $_REQUEST)) { + $source = $_REQUEST['source']; +} else { + foreach ($_REQUEST as $k => $v) { + $k = explode('-', $k, 2); + if (count($k) === 2 && $k[0] === 'src') { + $source = base64_decode($k[1]); + } + } +} +if ($source !== null) { + if ($as !== null) { + $as->setPreviousSource($source); + } + \SimpleSAML\Module\multiauth\Auth\Source\MultiAuth::delegateAuthentication($source, $state); +} + +if (array_key_exists('multiauth:preselect', $state)) { + $source = $state['multiauth:preselect']; + \SimpleSAML\Module\multiauth\Auth\Source\MultiAuth::delegateAuthentication($source, $state); +} + +$globalConfig = \SimpleSAML\Configuration::getInstance(); +$t = new \SimpleSAML\XHTML\Template($globalConfig, 'mymodule:selectsource.tpl.php'); + +$defaultLanguage = $globalConfig->getString('language.default', 'en'); +$language = $t->getTranslator()->getLanguage()->getLanguage(); + +$sources = $state[\SimpleSAML\Module\multiauth\Auth\Source\MultiAuth::SOURCESID]; +foreach ($sources as $key => $source) { + $sources[$key]['source64'] = base64_encode($sources[$key]['source']); + if (isset($sources[$key]['text'][$language])) { + $sources[$key]['text'] = $sources[$key]['text'][$language]; + } else { + $sources[$key]['text'] = $sources[$key]['text'][$defaultLanguage]; + } + + if (isset($sources[$key]['help'][$language])) { + $sources[$key]['help'] = $sources[$key]['help'][$language]; + } else { + $sources[$key]['help'] = $sources[$key]['help'][$defaultLanguage]; + } +} + +$t->data['authstate'] = $authStateId; +$t->data['sources'] = $sources; +$t->data['selfUrl'] = $_SERVER['PHP_SELF']; + +if ($as !== null) { + $t->data['preferred'] = $as->getPreviousSource(); +} else { + $t->data['preferred'] = null; +} +$t->show(); +exit();