From 97954849914a70165a3900cd1d530853e1cb3d78 Mon Sep 17 00:00:00 2001 From: Andjelko Horvat <comel@vingd.com> Date: Wed, 9 Jan 2013 11:23:31 +0000 Subject: [PATCH] SimpleSAML_Module: add module.enable configuration option for enabling/disabling modules (issue #475). git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@3218 44740490-163a-0410-bde0-09ae8108e29a --- config-templates/config.php | 20 ++++++++++++++++++++ lib/SimpleSAML/Module.php | 11 +++++++++++ 2 files changed, 31 insertions(+) diff --git a/config-templates/config.php b/config-templates/config.php index 0e82fb130..a6812d906 100644 --- a/config-templates/config.php +++ b/config-templates/config.php @@ -177,6 +177,26 @@ $config = array ( 'enable.wsfed-sp' => false, 'enable.authmemcookie' => false, + + /* + * Module enable configuration + * + * Configuration to override module enabling/disabling. + * + * Example: + * + * 'module.enable' => array( + * // Setting to TRUE enables. + * 'exampleauth' => TRUE, + * // Setting to FALSE disables. + * 'saml' => FALSE, + * // Unset or NULL uses default. + * 'core' => NULL, + * ), + * + */ + + /* * This value is the duration of the session in seconds. Make sure that the time duration of * cookies both at the SP and the IdP exceeds this duration. diff --git a/lib/SimpleSAML/Module.php b/lib/SimpleSAML/Module.php index be35cbce4..b1b776217 100644 --- a/lib/SimpleSAML/Module.php +++ b/lib/SimpleSAML/Module.php @@ -42,6 +42,17 @@ class SimpleSAML_Module { return FALSE; } + $globalConfig = SimpleSAML_Configuration::getInstance(); + $moduleEnable = $globalConfig->getArray('module.enable', array()); + + if(isset($moduleEnable[$module])) { + if(is_bool($moduleEnable[$module]) === TRUE) { + return $moduleEnable[$module]; + } + + throw new Exception("Invalid module.enable value for for the module $module"); + } + if (assert_options(ASSERT_ACTIVE) && !file_exists($moduleDir . '/default-enable') && !file_exists($moduleDir . '/default-disable')) { SimpleSAML_Logger::error("Missing default-enable or default-disable file for the module $module"); } -- GitLab