diff options
author | Simon Rettberg | 2015-10-20 17:15:49 +0200 |
---|---|---|
committer | Simon Rettberg | 2015-10-20 17:15:49 +0200 |
commit | 2c6bbc84799bcca7beb88abc4781ab0bc8ec5328 (patch) | |
tree | 21ca2565c6dd63b7405201964652d396e4d87d7c /modules | |
parent | [serversetup] Fix ipxe html layout (diff) | |
download | slx-admin-2c6bbc84799bcca7beb88abc4781ab0bc8ec5328.tar.gz slx-admin-2c6bbc84799bcca7beb88abc4781ab0bc8ec5328.tar.xz slx-admin-2c6bbc84799bcca7beb88abc4781ab0bc8ec5328.zip |
Support creating ad and ldap modules with ca-based cert checking
Diffstat (limited to 'modules')
-rw-r--r-- | modules/sysconfig/addmodule.inc.php | 43 | ||||
-rw-r--r-- | modules/sysconfig/addmodule_adauth.inc.php | 42 | ||||
-rw-r--r-- | modules/sysconfig/addmodule_ldapauth.inc.php | 42 |
3 files changed, 77 insertions, 50 deletions
diff --git a/modules/sysconfig/addmodule.inc.php b/modules/sysconfig/addmodule.inc.php index bbb827e5..0fed67a9 100644 --- a/modules/sysconfig/addmodule.inc.php +++ b/modules/sysconfig/addmodule.inc.php @@ -135,3 +135,46 @@ class AddModule_Start extends AddModule_Base } } + +/* + * Helper functions to set/get a batch of vars from/to post variables or a module + */ + +/** + * + * @param \ConfigModule $module + * @param array $array + * @param array $keys + */ +function moduleToArray($module, &$array, $keys) +{ + foreach ($keys as $key) { + $array[$key] = $module->getData($key); + } +} + +/** + * + * @param \ConfigModule $module + * @param array $array + * @param array $keys + */ +function arrayToModule($module, $array, $keys) +{ + foreach ($keys as $key) { + $module->setData($key, $array[$key]); + } +} +/** + * + * @param array $array + * @param array $keys + */ +function postToArray(&$array, $keys, $ignoreMissing = false) +{ + foreach ($keys as $key) { + $val = Request::post($key, '--not-in-post'); + if ($ignoreMissing && $val === '--not-in-post') continue; + $array[$key] = $val; + } +} diff --git a/modules/sysconfig/addmodule_adauth.inc.php b/modules/sysconfig/addmodule_adauth.inc.php index 251ee5d6..89d822c9 100644 --- a/modules/sysconfig/addmodule_adauth.inc.php +++ b/modules/sysconfig/addmodule_adauth.inc.php @@ -9,28 +9,14 @@ class AdAuth_Start extends AddModule_Base protected function renderInternal() { + $ADAUTH_COMMON_FIELDS = array('title', 'server', 'searchbase', 'binddn', 'bindpw', 'home', 'ssl', 'certificate'); + $data = array(); if ($this->edit !== false) { - $data = array( - 'title' => $this->edit->title(), - 'server' => $this->edit->getData('server'), - 'searchbase' => $this->edit->getData('searchbase'), - 'binddn' => $this->edit->getData('binddn'), - 'bindpw' => $this->edit->getData('bindpw'), - 'home' => $this->edit->getData('home'), - 'ssl' => $this->edit->getData('ssl'), - 'edit' => $this->edit->id() - ); - } else { - $data = array( - 'title' => Request::post('title'), - 'server' => Request::post('server'), - 'searchbase' => Request::post('searchbase'), - 'binddn' => Request::post('binddn'), - 'bindpw' => Request::post('bindpw'), - 'home' => Request::post('home'), - 'ssl' => Request::post('ssl') - ); + moduleToArray($this->edit, $data, $ADAUTH_COMMON_FIELDS); + $data['title'] = $this->edit->title(); + $data['edit'] = $this->edit->id(); } + postToArray($data, $ADAUTH_COMMON_FIELDS, true); if (preg_match('/^(.*)\:(636|3269|389|3268)$/', $data['server'], $out)) { $data['server'] = $out[1]; } @@ -66,7 +52,8 @@ class AdAuth_CheckConnection extends AddModule_Base } $this->scanTask = Taskmanager::submit('PortScan', array( 'host' => $this->server, - 'ports' => $ports + 'ports' => $ports, + 'certificate' => Request::post('certificate', '') )); if (!isset($this->scanTask['id'])) { AddModule_Base::setStep('AdAuth_Start'); // Continues with AdAuth_Start for render() @@ -85,10 +72,12 @@ class AdAuth_CheckConnection extends AddModule_Base 'bindpw' => Request::post('bindpw'), 'home' => Request::post('home'), 'ssl' => Request::post('ssl'), + 'certificate' => Request::post('certificate', ''), 'taskid' => $this->scanTask['id'] ); - $data['step'] = 'AdAuth_CheckCredentials'; - Render::addDialog(Dictionary::translate('config-module', 'adAuth_title'), false, 'sysconfig/ad-checkconnection', $data); + $data['prev'] = 'AdAuth_Start'; + $data['next'] = 'AdAuth_CheckCredentials'; + Render::addDialog(Dictionary::translate('config-module', 'adAuth_title'), false, 'sysconfig/ad_ldap-checkconnection', $data); } } @@ -161,7 +150,7 @@ class AdAuth_CheckCredentials extends AddModule_Base protected function renderInternal() { - Render::addDialog(Dictionary::translate('config-module', 'adAuth_title'), false, 'sysconfig/ad-checkcredentials', array_merge($this->taskIds, array( + Render::addDialog(Dictionary::translate('config-module', 'adAuth_title'), false, 'sysconfig/ad_ldap-checkcredentials', array_merge($this->taskIds, array( 'edit' => Request::post('edit'), 'title' => Request::post('title'), 'server' => Request::post('server') . ':' . Request::post('port'), @@ -171,8 +160,10 @@ class AdAuth_CheckCredentials extends AddModule_Base 'home' => Request::post('home'), 'ssl' => Request::post('ssl') === 'on', 'fingerprint' => Request::post('fingerprint'), + 'certificate' => Request::post('certificate', ''), 'originalbinddn' => $this->originalBindDn, - 'step' => 'AdAuth_Finish' + 'prev' => 'AdAuth_Start', + 'next' => 'AdAuth_Finish' )) ); } @@ -228,6 +219,7 @@ class AdAuth_Finish extends AddModule_Base $module->setData('binddn', $binddn); $module->setData('bindpw', Request::post('bindpw')); $module->setData('home', Request::post('home')); + $module->setData('certificate', Request::post('certificate')); $module->setData('ssl', $ssl); if ($ssl) { $module->setData('fingerprint', Request::post('fingerprint', '')); diff --git a/modules/sysconfig/addmodule_ldapauth.inc.php b/modules/sysconfig/addmodule_ldapauth.inc.php index 44dbcca1..6cefbe58 100644 --- a/modules/sysconfig/addmodule_ldapauth.inc.php +++ b/modules/sysconfig/addmodule_ldapauth.inc.php @@ -9,28 +9,14 @@ class LdapAuth_Start extends AddModule_Base protected function renderInternal() { + $LDAPAUTH_COMMON_FIELDS = array('title', 'server', 'searchbase', 'binddn', 'bindpw', 'home', 'ssl', 'certificate'); + $data = array(); if ($this->edit !== false) { - $data = array( - 'title' => $this->edit->title(), - 'server' => $this->edit->getData('server'), - 'searchbase' => $this->edit->getData('searchbase'), - 'binddn' => $this->edit->getData('binddn'), - 'bindpw' => $this->edit->getData('bindpw'), - 'home' => $this->edit->getData('home'), - 'ssl' => $this->edit->getData('ssl'), - 'edit' => $this->edit->id() - ); - } else { - $data = array( - 'title' => Request::post('title'), - 'server' => Request::post('server'), - 'searchbase' => Request::post('searchbase'), - 'binddn' => Request::post('binddn'), - 'bindpw' => Request::post('bindpw'), - 'home' => Request::post('home'), - 'ssl' => Request::post('ssl') - ); + moduleToArray($this->edit, $data, $LDAPAUTH_COMMON_FIELDS); + $data['title'] = $this->edit->title(); + $data['edit'] = $this->edit->id(); } + postToArray($data, $LDAPAUTH_COMMON_FIELDS, true); if (preg_match('/^(.*)\:(636|389)$/', $data['server'], $out)) { $data['server'] = $out[1]; } @@ -66,7 +52,8 @@ class LdapAuth_CheckConnection extends AddModule_Base } $this->scanTask = Taskmanager::submit('PortScan', array( 'host' => $this->server, - 'ports' => $ports + 'ports' => $ports, + 'certificate' => Request::post('certificate', '') )); if (!isset($this->scanTask['id'])) { AddModule_Base::setStep('LdapAuth_Start'); // Continues with LdapAuth_Start for render() @@ -85,10 +72,12 @@ class LdapAuth_CheckConnection extends AddModule_Base 'bindpw' => Request::post('bindpw'), 'home' => Request::post('home'), 'ssl' => Request::post('ssl'), + 'certificate' => Request::post('certificate', ''), 'taskid' => $this->scanTask['id'] ); - $data['step'] = 'LdapAuth_CheckCredentials'; - Render::addDialog(Dictionary::translate('config-module', 'ldapAuth_title'), false, 'sysconfig/ldap-checkconnection', $data); + $data['prev'] = 'LdapAuth_Start'; + $data['next'] = 'LdapAuth_CheckCredentials'; + Render::addDialog(Dictionary::translate('config-module', 'ldapAuth_title'), false, 'sysconfig/ad_ldap-checkconnection', $data); } } @@ -144,7 +133,7 @@ class LdapAuth_CheckCredentials extends AddModule_Base protected function renderInternal() { - Render::addDialog(Dictionary::translate('config-module', 'ldapAuth_title'), false, 'sysconfig/ldap-checkcredentials', array_merge($this->taskIds, array( + Render::addDialog(Dictionary::translate('config-module', 'ldapAuth_title'), false, 'sysconfig/ad_ldap-checkcredentials', array_merge($this->taskIds, array( 'edit' => Request::post('edit'), 'title' => Request::post('title'), 'server' => Request::post('server') . ':' . Request::post('port'), @@ -154,7 +143,9 @@ class LdapAuth_CheckCredentials extends AddModule_Base 'home' => Request::post('home'), 'ssl' => Request::post('ssl') === 'on', 'fingerprint' => Request::post('fingerprint'), - 'step' => 'LdapAuth_Finish' + 'certificate' => Request::post('certificate', ''), + 'prev' => 'LdapAuth_Start', + 'next' => 'LdapAuth_Finish' )) ); } @@ -190,6 +181,7 @@ class LdapAuth_Finish extends AddModule_Base $module->setData('binddn', $binddn); $module->setData('bindpw', Request::post('bindpw')); $module->setData('home', Request::post('home')); + $module->setData('certificate', Request::post('certificate')); $module->setData('ssl', $ssl); if ($ssl) { $module->setData('fingerprint', Request::post('fingerprint', '')); |