Skip to content
Snippets Groups Projects
Commit 027a69e9 authored by Tim van Dijen's avatar Tim van Dijen
Browse files

Twigify multiauth module

parent 1698caba
No related branches found
No related tags found
No related merge requests found
{% set pagetitle = '{multiauth:multiauth:select_source_header}'|trans %}
{% extends "base.twig" %}
{% block content %}
<h2>{{ '{multiauth:multiauth:select_source_header}'| trans }}</h2>
<p>{{ '{multiauth:multiauth:select_source_text}'| trans }}</p>
<form action="{{ selfUrl|escape('html') }}" method="get">
<input type="hidden" name="AuthState" value="{{ authstate|escape('html') }} " />
<ul>
{% for key, source in sources %}
{% set name = ('src-' ~ source.source64) %}
{% set button = ('button-' ~ source.source) %}
<li class="{{ source.css_class|escape('html') }} authsource">
{% if source.source == preferred %}
<input type="submit" name="{{ name|escape('html') }}" autofocus="autofocus" id="{{ button|escape('html') }}" value="{{ source.text|escape('html') }}" />
{% else %}
<input type="submit" name="{{ name|escape('html') }}" id="{{ button|escape('html') }}" value="{{ source.text|escape('html') }}" />
{% endif %}
</li>
{% endfor %}
</ul>
</form>
{% endblock %}
......@@ -12,49 +12,59 @@
// Retrieve the authentication state
if (!array_key_exists('AuthState', $_REQUEST)) {
throw new SimpleSAML_Error_BadRequest('Missing AuthState parameter.');
throw new SimpleSAML_Error_BadRequest('Missing AuthState parameter.');
}
$authStateId = $_REQUEST['AuthState'];
$state = SimpleSAML_Auth_State::loadState($authStateId, sspmod_multiauth_Auth_Source_MultiAuth::STAGEID);
if (array_key_exists("SimpleSAML_Auth_Source.id", $state)) {
$authId = $state["SimpleSAML_Auth_Source.id"];
$as = SimpleSAML_Auth_Source::getById($authId);
$authId = $state["SimpleSAML_Auth_Source.id"];
$as = SimpleSAML_Auth_Source::getById($authId);
} else {
$as = NULL;
$as = null;
}
$source = NULL;
$source = null;
if (array_key_exists('source', $_REQUEST)) {
$source = $_REQUEST['source'];
$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]);
}
}
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);
}
sspmod_multiauth_Auth_Source_MultiAuth::delegateAuthentication($source, $state);
if ($source !== null) {
if ($as !== null) {
$as->setPreviousSource($source);
}
sspmod_multiauth_Auth_Source_MultiAuth::delegateAuthentication($source, $state);
}
if (array_key_exists('multiauth:preselect', $state)) {
$source = $state['multiauth:preselect'];
sspmod_multiauth_Auth_Source_MultiAuth::delegateAuthentication($source, $state);
$source = $state['multiauth:preselect'];
sspmod_multiauth_Auth_Source_MultiAuth::delegateAuthentication($source, $state);
}
$globalConfig = SimpleSAML_Configuration::getInstance();
$t = new SimpleSAML_XHTML_Template($globalConfig, 'multiauth:selectsource.php');
$language = $t->getLanguage();
$sources = $state[sspmod_multiauth_Auth_Source_MultiAuth::SOURCESID];
foreach ($sources as $key => $source){
$sources[$key]['source64'] = base64_encode($sources[$key]['source']);
$sources[$key]['text'] = $sources[$key]['text'][$language];
}
$t->data['authstate'] = $authStateId;
$t->data['sources'] = $state[sspmod_multiauth_Auth_Source_MultiAuth::SOURCESID];
if ($as !== NULL) {
$t->data['preferred'] = $as->getPreviousSource();
$t->data['sources'] = $sources;
$t->data['selfUrl'] = $_SERVER['PHP_SELF'];
if ($as !== null) {
$t->data['preferred'] = $as->getPreviousSource();
} else {
$t->data['preferred'] = NULL;
$t->data['preferred'] = null;
}
$t->show();
exit();
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment