From c96938906038ed94b92e493871ff1ad00a6fd054 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20=C3=85kre=20Solberg?= <andreas.solberg@uninett.no>
Date: Mon, 14 Apr 2008 13:33:53 +0000
Subject: [PATCH] Making use of the configuration class instead of require_once

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@494 44740490-163a-0410-bde0-09ae8108e29a
---
 config-templates/config-login-auto.php | 68 ++++++++++++++++++++++++++
 config-templates/config.php            | 56 ---------------------
 www/auth/login-auto.php                | 11 +++--
 3 files changed, 75 insertions(+), 60 deletions(-)
 create mode 100644 config-templates/config-login-auto.php

diff --git a/config-templates/config-login-auto.php b/config-templates/config-login-auto.php
new file mode 100644
index 000000000..2fd0741d6
--- /dev/null
+++ b/config-templates/config-login-auto.php
@@ -0,0 +1,68 @@
+<?php
+/* 
+ * The configuration of the login-auto authentication module.
+ * 
+ * $Id: config.php 451 2008-03-27 15:33:34Z olavmrk $
+ */
+
+$config = array (
+
+	/*
+	 * This option enables or disables the login-auto authentication
+	 * handler. This handler is implemented in 'www/auth/login-auto.php'.
+	 *
+	 * When this option is set to true, a user can go to the
+	 * 'auth/login-auto.php' web page to be authenticated as an example
+	 * user. The user will receive the attributes set in the
+	 * 'auth.auto.attributes' option.
+	 *
+	 * WARNING: setting this option to true will make it possible to use
+	 * this authenticator for all users, irrespectively of the 'auth'
+	 * setting in the IdP's metadata. They can always use it by opening the
+	 * 'auth/login-auto.php' webpage manually.
+	 */
+	'auth.auto.enable' => true,
+
+	/*
+	 * This option configures which attributes the login-auto
+	 * authentication handler will set for the user. It is an array of
+	 * arrays. The name of the attribute is the index in the first array,
+	 * and all the values for the attribute is given in the array
+	 * referenced to by the name.
+	 *
+	 * Example:
+	 * 'auth.auto.attributes' => array(
+	 *     'edupersonaffiliation' => array('student', 'member'),
+	 *     'uid' => array('example_uid'),
+	 *     'mail' => array('example@example.com'),
+	 * ),
+	 */
+	'auth.auto.attributes' => array(
+		'edupersonaffiliation' => array('student', 'member'),
+		'title' => array('Example user title'),
+		'uid' => array('example_uid'),
+		'mail' => array('example@example.com'),
+		'cn' => array('Example user commonname'),
+		'givenname' => array('Example user givenname'),
+		'sn' => array("Example surname"),
+	),
+
+	/*
+	 * When this option is set to true, the login-auto authentication
+	 * handler will ask for a username and a password. This can be used to
+	 * test the IdP. The username and password isn't verified, and the
+	 * user/script can enter anything.
+	 */
+	'auth.auto.ask_login' => false,
+
+	/*
+	 * This option configures a delay in the login-auto authentication
+	 * handler. The script will wait for the given number of milliseconds
+	 * before authenticating the user. This can, for example, be used in
+	 * a simple simulation of a slow LDAP server.
+	 */
+	'auth.auto.delay_login' => 0,
+);
+
+
+?>
\ No newline at end of file
diff --git a/config-templates/config.php b/config-templates/config.php
index 650279acd..e44b80ff1 100644
--- a/config-templates/config.php
+++ b/config-templates/config.php
@@ -334,62 +334,6 @@ $config = array (
 
 
 
-	/*
-	 * This option enables or disables the login-auto authentication
-	 * handler. This handler is implemented in 'www/auth/login-auto.php'.
-	 *
-	 * When this option is set to true, a user can go to the
-	 * 'auth/login-auto.php' web page to be authenticated as an example
-	 * user. The user will receive the attributes set in the
-	 * 'auth.auto.attributes' option.
-	 *
-	 * WARNING: setting this option to true will make it possible to use
-	 * this authenticator for all users, irrespectively of the 'auth'
-	 * setting in the IdP's metadata. They can always use it by opening the
-	 * 'auth/login-auto.php' webpage manually.
-	 */
-	'auth.auto.enable' => false,
-
-	/*
-	 * This option configures which attributes the login-auto
-	 * authentication handler will set for the user. It is an array of
-	 * arrays. The name of the attribute is the index in the first array,
-	 * and all the values for the attribute is given in the array
-	 * referenced to by the name.
-	 *
-	 * Example:
-	 * 'auth.auto.attributes' => array(
-	 *     'edupersonaffiliation' => array('student', 'member'),
-	 *     'uid' => array('example_uid'),
-	 *     'mail' => array('example@example.com'),
-	 * ),
-	 */
-	'auth.auto.attributes' => array(
-		'edupersonaffiliation' => array('student', 'member'),
-		'title' => array('Example user title'),
-		'uid' => array('example_uid'),
-		'mail' => array('example@example.com'),
-		'cn' => array('Example user commonname'),
-		'givenname' => array('Example user givenname'),
-		'sn' => array("Example surname"),
-	),
-
-	/*
-	 * When this option is set to true, the login-auto authentication
-	 * handler will ask for a username and a password. This can be used to
-	 * test the IdP. The username and password isn't verified, and the
-	 * user/script can enter anything.
-	 */
-	'auth.auto.ask_login' => false,
-
-	/*
-	 * This option configures a delay in the login-auto authentication
-	 * handler. The script will wait for the given number of milliseconds
-	 * before authenticating the user. This can, for example, be used in
-	 * a simple simulation of a slow LDAP server.
-	 */
-	'auth.auto.delay_login' => 0,
-
 );
 
 
diff --git a/www/auth/login-auto.php b/www/auth/login-auto.php
index a5dab629c..85b36bd53 100644
--- a/www/auth/login-auto.php
+++ b/www/auth/login-auto.php
@@ -26,10 +26,13 @@ require_once((isset($SIMPLESAML_INCPREFIX)?$SIMPLESAML_INCPREFIX:'') . 'SimpleSA
 
 /* Load the configuration. */
 $config = SimpleSAML_Configuration::getInstance();
-$enable = (bool)$config->getValue('auth.auto.enable');
-$attributes = $config->getValue('auth.auto.attributes');
-$ask_login = (bool)$config->getValue('auth.auto.ask_login');
-$delay_login = (int)$config->getValue('auth.auto.delay_login');
+$autoconfig = $config->copyFromBase('loginauto', 'config-login-auto.php');
+
+
+$enable = (bool)$autoconfig->getValue('auth.auto.enable');
+$attributes = $autoconfig->getValue('auth.auto.attributes');
+$ask_login = (bool)$autoconfig->getValue('auth.auto.ask_login');
+$delay_login = (int)$autoconfig->getValue('auth.auto.delay_login');
 
 /* Verify that this authentication handler is enabled. */
 if(!$enable) {
-- 
GitLab