From 0fd9b59b0b4d3ed243b9529e7b2d8ba565a37279 Mon Sep 17 00:00:00 2001
From: Olav Morken <olav.morken@uninett.no>
Date: Fri, 28 Aug 2009 07:47:42 +0000
Subject: [PATCH] authsource-test: Add list of authentication sources.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1726 44740490-163a-0410-bde0-09ae8108e29a
---
 .../core/templates/authsource_list.tpl.php    | 21 +++++++++++++++++++
 modules/core/www/authenticate.php             |  6 +++++-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 modules/core/templates/authsource_list.tpl.php

diff --git a/modules/core/templates/authsource_list.tpl.php b/modules/core/templates/authsource_list.tpl.php
new file mode 100644
index 000000000..0f075e8a4
--- /dev/null
+++ b/modules/core/templates/authsource_list.tpl.php
@@ -0,0 +1,21 @@
+<?php
+/**
+ * Template to show list of configured authentication sources.
+ *
+ */
+$this->data['header'] = 'Test authentication sources';
+
+$this->includeAtTemplateBase('includes/header.php');
+?>
+<h1><?php echo $this->data['header']; ?></h1>
+<ul>
+<?php
+foreach ($this->data['sources'] as $id) {
+	echo '<li><a href="?as=' . htmlspecialchars(urlencode($id)) . '">' . htmlspecialchars($id) . '</a></li>';
+}
+?>
+</ul>
+
+<?php
+$this->includeAtTemplateBase('includes/footer.php');
+?>
diff --git a/modules/core/www/authenticate.php b/modules/core/www/authenticate.php
index 75d48136b..31ed34ba1 100644
--- a/modules/core/www/authenticate.php
+++ b/modules/core/www/authenticate.php
@@ -26,7 +26,11 @@ if (array_key_exists(SimpleSAML_Auth_State::EXCEPTION_PARAM, $_REQUEST)) {
 }
 
 if(!array_key_exists('as', $_REQUEST)) {
-	throw new Exception('No authentication source chosen.');
+	$t = new SimpleSAML_XHTML_Template($config, 'core:authsource_list.tpl.php');
+
+	$t->data['sources'] = SimpleSAML_Auth_Source::getSources();
+	$t->show();
+	exit();
 }
 
 $as = $_REQUEST['as'];
-- 
GitLab