mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-07 08:34:42 +01:00
using one list of auth-types (in order of importance) and detecting additional ones in the filesystem
This commit is contained in:
parent
741a12bef2
commit
871e5718af
@ -59,6 +59,9 @@ class setup_cmd_config extends setup_cmd
|
||||
|
||||
$this->check_installed($this->domain,15,$this->verbose);
|
||||
|
||||
// fixing authtypes in self::$options
|
||||
self::auth_types(true);
|
||||
|
||||
$values = array();
|
||||
if ($this->arguments) // we have command line arguments
|
||||
{
|
||||
@ -317,6 +320,11 @@ class setup_cmd_config extends setup_cmd
|
||||
{
|
||||
if (is_array($data) && isset($data['allowed']))
|
||||
{
|
||||
if ($data['name'] == 'auth_type')
|
||||
{
|
||||
$options[$data['name']] = self::auth_types();
|
||||
continue;
|
||||
}
|
||||
foreach($data['allowed'] as $label => $value)
|
||||
{
|
||||
if (is_int($label))
|
||||
@ -331,6 +339,47 @@ class setup_cmd_config extends setup_cmd
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read auth-types (existing auth backends) from filesystem and fix our $options array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static function auth_types()
|
||||
{
|
||||
// default backends in order of importance
|
||||
static $auth_types = array(
|
||||
'sql' => 'SQL',
|
||||
'ldap' => 'LDAP',
|
||||
'mail' => 'Mail',
|
||||
'ads' => 'Active Directory',
|
||||
'http' => 'HTTP',
|
||||
'fallback' => 'Fallback LDAP --> SQL',
|
||||
'sqlssl' => 'SQL / SSL',
|
||||
);
|
||||
static $scan_done;
|
||||
if (!$scan_done++)
|
||||
{
|
||||
// now add auth backends found in filesystem
|
||||
foreach(scandir(EGW_INCLUDE_ROOT.'/phpgwapi/inc') as $class)
|
||||
{
|
||||
if (preg_match('/^class\.auth_([a-z]+)\.inc\.php$/',$class,$matches) &&
|
||||
!isset($auth_types[$matches[1]]))
|
||||
{
|
||||
$auth_types[$matches[1]] = ucfirst($matches[1]);
|
||||
}
|
||||
}
|
||||
foreach(self::$options['--account-auth'] as &$param)
|
||||
{
|
||||
if ($param['name'] == 'auth_type')
|
||||
{
|
||||
$param['allowed'] = array_keys($auth_types);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $auth_types;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the defaults from the $options array
|
||||
|
@ -239,20 +239,41 @@ function sql_passwdhashes($config)
|
||||
*/
|
||||
function mail_login_type($config)
|
||||
{
|
||||
$types = emailadmin_ui::getIMAPLoginTypes('cyrusimap');
|
||||
unset($types['admin']);
|
||||
|
||||
foreach($types as $value => $label)
|
||||
return _options_from(emailadmin_ui::getIMAPLoginTypes('cyrusimap'),$config['mail_login_type']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make auth-types from setup_cmd_config available
|
||||
*
|
||||
* @param array $config
|
||||
* @return string
|
||||
*/
|
||||
function auth_type($config)
|
||||
{
|
||||
return _options_from(setup_cmd_config::auth_types(),$config['auth_type']);
|
||||
}
|
||||
function auth_type_syncml($config)
|
||||
{
|
||||
return _options_from(setup_cmd_config::auth_types(),$config['auth_type_syncml']);
|
||||
}
|
||||
function auth_type_groupdav($config)
|
||||
{
|
||||
return _options_from(setup_cmd_config::auth_types(),$config['auth_type_groupdav']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns options string
|
||||
*
|
||||
* @param array $options value => label pairs
|
||||
* @param string $selected value of selected optino
|
||||
* @return string
|
||||
*/
|
||||
function _options_from(array $options,$selected)
|
||||
{
|
||||
foreach($options as $value => $label)
|
||||
{
|
||||
if($config['mail_login_type'] == $value)
|
||||
{
|
||||
$selected = ' selected="selected"';
|
||||
}
|
||||
else
|
||||
{
|
||||
$selected = '';
|
||||
}
|
||||
$out .= '<option value="' . $value . '"' . $selected . '>' . $label . '</option>' . "\n";
|
||||
$out .= '<option value="' . htmlspecialchars($value) . '"' .
|
||||
($selected == $value ? ' selected="selected"' : '') . '>' . $label . '</option>' . "\n";
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
@ -213,16 +213,7 @@
|
||||
<td>{lang_Select_which_type_of_authentication_you_are_using}:</td>
|
||||
<td>
|
||||
<select name="newsettings[auth_type]">
|
||||
<option value="sql"{selected_auth_type_sql}>SQL</option>
|
||||
<option value="sqlssl"{selected_auth_type_sqlssl}>SQL / SSL</option>
|
||||
<option value="ldap"{selected_auth_type_ldap}>LDAP</option>
|
||||
<option value="ads"{selected_auth_type_ads}>ADS</option>
|
||||
<option value="mail"{selected_auth_type_mail}>Mail</option>
|
||||
<option value="http"{selected_auth_type_http}>HTTP</option>
|
||||
<option value="nis"{selected_auth_type_nis}>NIS</option>
|
||||
<option value="pam"{selected_auth_type_pam}>PAM</option>
|
||||
<option value="cas"{selected_auth_type_cas}>CAS</option>
|
||||
<option value="fallback"{selected_auth_type_fallback}>Fallback LDAP -> SQL</option>
|
||||
{hook_auth_type}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
@ -232,15 +223,7 @@
|
||||
<td>
|
||||
<select name="newsettings[auth_type_syncml]">
|
||||
<option value="">{lang_Standard,_as_defined_above}</option>
|
||||
<option value="sql"{selected_auth_type_syncml_sql}>SQL</option>
|
||||
<option value="sqlssl"{selected_auth_type_syncml_sqlssl}>SQL / SSL</option>
|
||||
<option value="ldap"{selected_auth_type_syncml_ldap}>LDAP</option>
|
||||
<option value="ads"{selected_auth_type_syncml_ads}>ADS</option>
|
||||
<option value="mail"{selected_auth_type_syncml_mail}>Mail</option>
|
||||
<option value="http"{selected_auth_type_syncml_http}>HTTP</option>
|
||||
<option value="nis"{selected_auth_type_syncml_nis}>NIS</option>
|
||||
<option value="pam"{selected_auth_type_syncml_pam}>PAM</option>
|
||||
<option value="fallback"{selected_auth_type_fallback}>Fallback LDAP -> SQL</option>
|
||||
{hook_auth_type_syncml}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
@ -250,15 +233,7 @@
|
||||
<td>
|
||||
<select name="newsettings[auth_type_groupdav]">
|
||||
<option value="">{lang_Standard,_as_defined_above}</option>
|
||||
<option value="sql"{selected_auth_type_groupdav_sql}>SQL</option>
|
||||
<option value="sqlssl"{selected_auth_type_groupdav_sqlssl}>SQL / SSL</option>
|
||||
<option value="ldap"{selected_auth_type_groupdav_ldap}>LDAP</option>
|
||||
<option value="ads"{selected_auth_type_groupdav_ads}>ADS</option>
|
||||
<option value="mail"{selected_auth_type_groupdav_mail}>Mail</option>
|
||||
<option value="http"{selected_auth_type_groupdav_http}>HTTP</option>
|
||||
<option value="nis"{selected_auth_type_groupdav_nis}>NIS</option>
|
||||
<option value="pam"{selected_auth_type_groupdav_pam}>PAM</option>
|
||||
<option value="fallback"{selected_auth_type_fallback}>Fallback LDAP -> SQL</option>
|
||||
{hook_auth_type_groupdav}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
Loading…
Reference in New Issue
Block a user