From be4b7941640bd0c54792bf942fd48b887a32dcaf Mon Sep 17 00:00:00 2001
From: Tim van Dijen <tvdijen@gmail.com>
Date: Sun, 16 Feb 2020 17:18:24 +0100
Subject: [PATCH] Make sure that certain modules are always enabled, unless
 specifically disabled by config

---
 lib/SimpleSAML/Module.php | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/lib/SimpleSAML/Module.php b/lib/SimpleSAML/Module.php
index 0cd8b3dee..d5dd1b2c5 100644
--- a/lib/SimpleSAML/Module.php
+++ b/lib/SimpleSAML/Module.php
@@ -69,6 +69,16 @@ class Module
      */
     public static $modules = [];
 
+    /**
+     * A list containing the modules that are enabled by default, unless specifically disabled
+     *
+     * @var array
+     */
+    public static $core_modules = [
+        'core' => true,
+        'saml' => true
+    ];
+
     /**
      * A cache containing specific information for modules, like whether they are enabled or not, or their hooks.
      *
@@ -109,7 +119,7 @@ class Module
     public static function isModuleEnabled(string $module): bool
     {
         $config = Configuration::getOptionalConfig();
-        return self::isModuleEnabledWithConf($module, $config->getArray('module.enable', []));
+        return self::isModuleEnabledWithConf($module, $config->getArray('module.enable', $this->core_modules));
     }
 
 
@@ -342,8 +352,10 @@ class Module
             throw new \Exception("Invalid module.enable value for the '$module' module.");
         }
 
-        self::$module_info[$module]['enabled'] = false;
-        return false;
+        $core_module =  array_key_exists($module, $this->core_modules) ? true : false;
+
+        self::$module_info[$module]['enabled'] = $core_module ? true : false;
+        return $core_module ? true : false;
     }
 
 
-- 
GitLab