From b26c1b974af78f6b3a949528f3c0b85e6d3aee65 Mon Sep 17 00:00:00 2001
From: Tim van Dijen <tvdijen@gmail.com>
Date: Sun, 16 Feb 2020 16:31:27 +0100
Subject: [PATCH] Enable modules by config

---
 docs/simplesamlphp-customauth.md               |  8 +-------
 docs/simplesamlphp-modules.md                  | 14 ++------------
 docs/simplesamlphp-theming.md                  |  4 ++--
 lib/SimpleSAML/Module.php                      | 18 ------------------
 .../exampleauth/lib/Auth/Source/External.php   |  2 +-
 5 files changed, 6 insertions(+), 40 deletions(-)

diff --git a/docs/simplesamlphp-customauth.md b/docs/simplesamlphp-customauth.md
index 8e6ee8d25..f52f448e7 100644
--- a/docs/simplesamlphp-customauth.md
+++ b/docs/simplesamlphp-customauth.md
@@ -19,13 +19,7 @@ First we need to create the module directory:
     cd modules
     mkdir mymodule
 
-Since this is a custom module, it should always be enabled.
-Therefore we create a `default-enable` file in the module.
-We do that by copying the `default-enable` file from the `core` module.
-
-    cd mymodule
-    cp ../core/default-enable .
-
+Since this is a custom module, it should always be enabled in the configuration.
 Now that we have our own module, we can move on to creating an authentication source.
 
 
diff --git a/docs/simplesamlphp-modules.md b/docs/simplesamlphp-modules.md
index ed0df9982..111c14f3b 100644
--- a/docs/simplesamlphp-modules.md
+++ b/docs/simplesamlphp-modules.md
@@ -46,23 +46,13 @@ Each SimpleSAMLphp module is stored in a directory under the
 `modules`-directory. The module directory contains the following
 directories and files:
 
-default-disable
-:   The presence of this file indicates that the module is disabled
-    by default. It can be enabled using the `module.enable`
-    option in `config.php`.
-
-default-enable
-:   The presence of this file indicates that the module is enabled
-    by default. It can be disabled using the `module.enable`
-    option in `config.php`.
-
-dictionaries
+locales
 :   This directory contains dictionaries which belong to this
     module. To use a dictionary stored in a module, the extended tag
     names can be used:
     `{<module name>:<dictionary name>:<tag name>}` For
     example, `{example:login:hello}` will look up `hello` in
-    `modules/example/dictionaries/login.php`.
+    `modules/example/locales/<lang>/login.po`.
 
 :   It is also possible to specify
     `<module name>:<dictionary name>` as the default
diff --git a/docs/simplesamlphp-theming.md b/docs/simplesamlphp-theming.md
index 987ee0f8a..7cc62a777 100644
--- a/docs/simplesamlphp-theming.md
+++ b/docs/simplesamlphp-theming.md
@@ -44,8 +44,8 @@ The first thing you need to do is having a SimpleSAMLphp module to place your th
 
 	cd modules
 	mkdir mymodule
-	cd mymodule
-	touch default-enable
+
+	Enable the module by setting `$config['module.enable' => ['mymodule' => true]]`
 
 Then within this module, you can create a new theme named `fancytheme`.
 
diff --git a/lib/SimpleSAML/Module.php b/lib/SimpleSAML/Module.php
index 285882f7c..0cd8b3dee 100644
--- a/lib/SimpleSAML/Module.php
+++ b/lib/SimpleSAML/Module.php
@@ -342,24 +342,6 @@ class Module
             throw new \Exception("Invalid module.enable value for the '$module' module.");
         }
 
-        if (
-            assert_options(ASSERT_ACTIVE)
-            && !file_exists($moduleDir . '/default-enable')
-            && !file_exists($moduleDir . '/default-disable')
-        ) {
-            Logger::error("Missing default-enable or default-disable file for the module $module");
-        }
-
-        if (file_exists($moduleDir . '/enable')) {
-            self::$module_info[$module]['enabled'] = true;
-            return true;
-        }
-
-        if (!file_exists($moduleDir . '/disable') && file_exists($moduleDir . '/default-enable')) {
-            self::$module_info[$module]['enabled'] = true;
-            return true;
-        }
-
         self::$module_info[$module]['enabled'] = false;
         return false;
     }
diff --git a/modules/exampleauth/lib/Auth/Source/External.php b/modules/exampleauth/lib/Auth/Source/External.php
index 606479543..a90468395 100644
--- a/modules/exampleauth/lib/Auth/Source/External.php
+++ b/modules/exampleauth/lib/Auth/Source/External.php
@@ -18,7 +18,7 @@ use Webmozart\Assert\Assert;
  *
  * To adapt this to your own web site, you should:
  * 1. Create your own module directory.
- * 2. Add a file "default-enable" to that directory.
+ * 2. Enable to module in the config by adding '<module-dir>' => true to the $config['module.enable'] array.
  * 3. Copy this file and modules/exampleauth/www/resume.php to their corresponding
  *    location in the new module.
  * 4. Replace all occurrences of "exampleauth" in this file and in resume.php with the name of your module.
-- 
GitLab