diff options
author | Simon Rettberg | 2016-07-06 11:55:35 +0200 |
---|---|---|
committer | Simon Rettberg | 2016-07-06 11:55:35 +0200 |
commit | dcb27f27031991668afafeffe5ea6dc04035a663 (patch) | |
tree | 79612a6b4d44f29a808d95a34cf06198f4a4453f /modules-available/sysconfig/inc/configmodule | |
parent | [dozmod] api: Add error checks, implement lecture list resource type (diff) | |
download | slx-admin-dcb27f27031991668afafeffe5ea6dc04035a663.tar.gz slx-admin-dcb27f27031991668afafeffe5ea6dc04035a663.tar.xz slx-admin-dcb27f27031991668afafeffe5ea6dc04035a663.zip |
[sysconfig] Refactor ldapauth and adauth classes; show mainpage warning; improve config module handling
Diffstat (limited to 'modules-available/sysconfig/inc/configmodule')
4 files changed, 29 insertions, 132 deletions
diff --git a/modules-available/sysconfig/inc/configmodule/adauth.inc.php b/modules-available/sysconfig/inc/configmodule/adauth.inc.php index 180ac717..db06a4a4 100644 --- a/modules-available/sysconfig/inc/configmodule/adauth.inc.php +++ b/modules-available/sysconfig/inc/configmodule/adauth.inc.php @@ -1,5 +1,12 @@ <?php +class ConfigModule_AdAuth extends ConfigModuleBaseLdap +{ + + const MODID = 'AdAuth'; + +} + ConfigModule::registerModule( ConfigModule_AdAuth::MODID, // ID Dictionary::translateFileModule('sysconfig', 'config-module', 'adAuth_title'), // Title @@ -7,69 +14,3 @@ ConfigModule::registerModule( Dictionary::translateFileModule('sysconfig', 'config-module', 'group_authentication'), // Group true // Only one per config? ); - -class ConfigModule_AdAuth extends ConfigModule -{ - - const MODID = 'AdAuth'; - const VERSION = 1; - - private static $REQUIRED_FIELDS = array('server', 'searchbase', 'binddn'); - private static $OPTIONAL_FIELDS = array('bindpw', 'home', 'ssl', 'fingerprint', 'certificate', 'homeattr'); - - protected function generateInternal($tgz, $parent) - { - Trigger::ldadp($this->id(), $parent); - $config = $this->moduleData; - if (isset($config['certificate']) && !is_string($config['certificate'])) { - unset($config['certificate']); - } - if (preg_match('/^([^\:]+)\:(\d+)$/', $config['server'], $out)) { - $config['server'] = $out[1]; - $config['adport'] = $out[2]; - } else { - if (isset($config['certificate'])) { - $config['adport'] = 636; - } else { - $config['adport'] = 389; - } - } - $config['parentTask'] = $parent; - $config['failOnParentFail'] = false; - $config['proxyip'] = Property::getServerIp(); - $config['proxyport'] = 3100 + $this->id(); - $config['filename'] = $tgz; - $config['moduleid'] = $this->id(); - return Taskmanager::submit('CreateLdapConfig', $config); - } - - protected function moduleVersion() - { - return self::VERSION; - } - - protected function validateConfig() - { - // Check if required fields are filled - return Util::hasAllKeys($this->moduleData, self::$REQUIRED_FIELDS); - } - - public function setData($key, $value) - { - if (!in_array($key, self::$REQUIRED_FIELDS) && !in_array($key, self::$OPTIONAL_FIELDS)) - return false; - $this->moduleData[$key] = $value; - return true; - } - - // ############## Callbacks ############################# - - /** - * Server IP changed - rebuild all AD modules. - */ - public function event_serverIpChanged() - { - $this->generate(false); - } - -} diff --git a/modules-available/sysconfig/inc/configmodule/branding.inc.php b/modules-available/sysconfig/inc/configmodule/branding.inc.php index 4a9718d6..fd11dade 100644 --- a/modules-available/sysconfig/inc/configmodule/branding.inc.php +++ b/modules-available/sysconfig/inc/configmodule/branding.inc.php @@ -53,4 +53,9 @@ class ConfigModule_Branding extends ConfigModule return false; } + public function allowDownload() + { + return true; + } + } diff --git a/modules-available/sysconfig/inc/configmodule/customodule.inc.php b/modules-available/sysconfig/inc/configmodule/customodule.inc.php index 8d1b6bf0..336d794f 100644 --- a/modules-available/sysconfig/inc/configmodule/customodule.inc.php +++ b/modules-available/sysconfig/inc/configmodule/customodule.inc.php @@ -53,4 +53,9 @@ class ConfigModule_CustomModule extends ConfigModule return false; } + public function allowDownload() + { + return true; + } + } diff --git a/modules-available/sysconfig/inc/configmodule/ldapauth.inc.php b/modules-available/sysconfig/inc/configmodule/ldapauth.inc.php index ed1a47c3..1a706234 100644 --- a/modules-available/sysconfig/inc/configmodule/ldapauth.inc.php +++ b/modules-available/sysconfig/inc/configmodule/ldapauth.inc.php @@ -1,77 +1,23 @@ <?php -ConfigModule::registerModule( - ConfigModule_LdapAuth::MODID, // ID - Dictionary::translateFileModule('sysconfig', 'config-module', 'ldapAuth_title'), // Title - Dictionary::translateFileModule('sysconfig', 'config-module', 'ldapAuth_description'), // Description - Dictionary::translateFileModule('sysconfig', 'config-module', 'group_authentication'), // Group - true // Only one per config? -); - -class ConfigModule_LdapAuth extends ConfigModule +class ConfigModule_LdapAuth extends ConfigModuleBaseLdap { const MODID = 'LdapAuth'; - const VERSION = 1; - private static $REQUIRED_FIELDS = array('server', 'searchbase'); - private static $OPTIONAL_FIELDS = array('binddn', 'bindpw', 'home', 'ssl', 'fingerprint', 'certificate'); - - protected function generateInternal($tgz, $parent) + protected function preTaskmanagerHook(&$config) { - Trigger::ldadp($this->id(), $parent); - $config = $this->moduleData; - if (isset($config['certificate']) && !is_string($config['certificate'])) { - unset($config['certificate']); - } - if (preg_match('/^([^\:]+)\:(\d+)$/', $config['server'], $out)) { - $config['server'] = $out[1]; - $config['adport'] = $out[2]; // sic! - } else { - if (isset($config['certificate'])) { - $config['adport'] = 636; - } else { - $config['adport'] = 389; - } - } - $config['parentTask'] = $parent; - $config['failOnParentFail'] = false; - $config['proxyip'] = Property::getServerIp(); - $config['proxyport'] = 3100 + $this->id(); - $config['filename'] = $tgz; - $config['moduleid'] = $this->id(); + // Just set the flag so the taskmanager job knows we're dealing with a normal ldap server, + // not AD scheme $config['plainldap'] = true; - return Taskmanager::submit('CreateLdapConfig', $config); - } - - protected function moduleVersion() - { - return self::VERSION; - } - - protected function validateConfig() - { - // Check if required fields are filled - return Util::hasAllKeys($this->moduleData, self::$REQUIRED_FIELDS); - } - - public function setData($key, $value) - { - if (!in_array($key, self::$REQUIRED_FIELDS) && !in_array($key, self::$OPTIONAL_FIELDS)) - return false; - $this->moduleData[$key] = $value; - return true; - } - - // ############## Callbacks ############################# - - /** - * Server IP changed - rebuild all LDAP modules. - */ - public function event_serverIpChanged() - { - error_log('Calling generate on ' . $this->title()); - $this->generate(false); } } + +ConfigModule::registerModule( + ConfigModule_LdapAuth::MODID, // ID + Dictionary::translateFileModule('sysconfig', 'config-module', 'ldapAuth_title'), // Title + Dictionary::translateFileModule('sysconfig', 'config-module', 'ldapAuth_description'), // Description + Dictionary::translateFileModule('sysconfig', 'config-module', 'group_authentication'), // Group + true // Only one per config? +); |