mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-31 01:34:09 +02:00
parent
0fa133abfb
commit
50fc85d7ff
@ -1,5 +1,5 @@
|
|||||||
[autologin]
|
[autologin]
|
||||||
backend = autologin
|
backend = external
|
||||||
|
|
||||||
[icingaweb-mysql]
|
[icingaweb-mysql]
|
||||||
backend = db
|
backend = db
|
||||||
|
@ -8,16 +8,16 @@ use Zend_Validate_Callback;
|
|||||||
use Icinga\Web\Form;
|
use Icinga\Web\Form;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Form class for adding/modifying autologin authentication backends
|
* Form class for adding/modifying authentication backends of type "external"
|
||||||
*/
|
*/
|
||||||
class AutologinBackendForm extends Form
|
class ExternalBackendForm extends Form
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Initialize this form
|
* Initialize this form
|
||||||
*/
|
*/
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
$this->setName('form_config_authbackend_autologin');
|
$this->setName('form_config_authbackend_external');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -69,7 +69,7 @@ class AutologinBackendForm extends Form
|
|||||||
'backend',
|
'backend',
|
||||||
array(
|
array(
|
||||||
'disabled' => true,
|
'disabled' => true,
|
||||||
'value' => 'autologin'
|
'value' => 'external'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ class AutologinBackendForm extends Form
|
|||||||
/**
|
/**
|
||||||
* Validate the configuration by creating a backend and requesting the user count
|
* Validate the configuration by creating a backend and requesting the user count
|
||||||
*
|
*
|
||||||
* Returns always true as autologin backends are just "passive" backends. (The webserver authenticates users.)
|
* Returns always true as backends of type "external" are just "passive" backends.
|
||||||
*
|
*
|
||||||
* @param Form $form The form to fetch the configuration values from
|
* @param Form $form The form to fetch the configuration values from
|
||||||
*
|
*
|
@ -14,7 +14,7 @@ use Icinga\Data\ResourceFactory;
|
|||||||
use Icinga\Exception\ConfigurationError;
|
use Icinga\Exception\ConfigurationError;
|
||||||
use Icinga\Forms\Config\Authentication\DbBackendForm;
|
use Icinga\Forms\Config\Authentication\DbBackendForm;
|
||||||
use Icinga\Forms\Config\Authentication\LdapBackendForm;
|
use Icinga\Forms\Config\Authentication\LdapBackendForm;
|
||||||
use Icinga\Forms\Config\Authentication\AutologinBackendForm;
|
use Icinga\Forms\Config\Authentication\ExternalBackendForm;
|
||||||
|
|
||||||
class AuthenticationBackendConfigForm extends ConfigForm
|
class AuthenticationBackendConfigForm extends ConfigForm
|
||||||
{
|
{
|
||||||
@ -67,8 +67,8 @@ class AuthenticationBackendConfigForm extends ConfigForm
|
|||||||
} elseif ($type === 'ldap') {
|
} elseif ($type === 'ldap') {
|
||||||
$form = new LdapBackendForm();
|
$form = new LdapBackendForm();
|
||||||
$form->setResources(isset($this->resources['ldap']) ? $this->resources['ldap'] : array());
|
$form->setResources(isset($this->resources['ldap']) ? $this->resources['ldap'] : array());
|
||||||
} elseif ($type === 'autologin') {
|
} elseif ($type === 'external') {
|
||||||
$form = new AutologinBackendForm();
|
$form = new ExternalBackendForm();
|
||||||
} else {
|
} else {
|
||||||
throw new InvalidArgumentException(sprintf($this->translate('Invalid backend type "%s" provided'), $type));
|
throw new InvalidArgumentException(sprintf($this->translate('Invalid backend type "%s" provided'), $type));
|
||||||
}
|
}
|
||||||
@ -251,14 +251,14 @@ class AuthenticationBackendConfigForm extends ConfigForm
|
|||||||
$configValues['name'] = $authBackend;
|
$configValues['name'] = $authBackend;
|
||||||
$this->populate($configValues);
|
$this->populate($configValues);
|
||||||
} elseif (empty($this->resources)) {
|
} elseif (empty($this->resources)) {
|
||||||
$autologinBackends = array_filter(
|
$externalBackends = array_filter(
|
||||||
$this->config->toArray(),
|
$this->config->toArray(),
|
||||||
function ($authBackendCfg) {
|
function ($authBackendCfg) {
|
||||||
return isset($authBackendCfg['backend']) && $authBackendCfg['backend'] === 'autologin';
|
return isset($authBackendCfg['backend']) && $authBackendCfg['backend'] === 'external';
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
if (false === empty($autologinBackends)) {
|
if (false === empty($externalBackends)) {
|
||||||
throw new ConfigurationError($this->translate('Could not find any resources for authentication'));
|
throw new ConfigurationError($this->translate('Could not find any resources for authentication'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -299,14 +299,14 @@ class AuthenticationBackendConfigForm extends ConfigForm
|
|||||||
$backendTypes['ldap'] = 'LDAP';
|
$backendTypes['ldap'] = 'LDAP';
|
||||||
}
|
}
|
||||||
|
|
||||||
$autologinBackends = array_filter(
|
$externalBackends = array_filter(
|
||||||
$this->config->toArray(),
|
$this->config->toArray(),
|
||||||
function ($authBackendCfg) {
|
function ($authBackendCfg) {
|
||||||
return isset($authBackendCfg['backend']) && $authBackendCfg['backend'] === 'autologin';
|
return isset($authBackendCfg['backend']) && $authBackendCfg['backend'] === 'external';
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
if ($backendType === 'autologin' || empty($autologinBackends)) {
|
if ($backendType === 'external' || empty($externalBackends)) {
|
||||||
$backendTypes['autologin'] = $this->translate('Autologin');
|
$backendTypes['external'] = $this->translate('External');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($backendType === null) {
|
if ($backendType === null) {
|
||||||
|
@ -24,7 +24,7 @@ For delegating authentication to the web server simply add `autologin` to your a
|
|||||||
|
|
||||||
````
|
````
|
||||||
[autologin]
|
[autologin]
|
||||||
backend = autologin
|
backend = external
|
||||||
````
|
````
|
||||||
|
|
||||||
If your web server is not configured for authentication though the `autologin` section has no effect.
|
If your web server is not configured for authentication though the `autologin` section has no effect.
|
||||||
|
@ -11,7 +11,7 @@ use Icinga\User;
|
|||||||
/**
|
/**
|
||||||
* Test login with external authentication mechanism, e.g. Apache
|
* Test login with external authentication mechanism, e.g. Apache
|
||||||
*/
|
*/
|
||||||
class AutoLoginBackend extends UserBackend
|
class ExternalBackend extends UserBackend
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Regexp expression to strip values from a username
|
* Regexp expression to strip values from a username
|
||||||
@ -21,7 +21,7 @@ class AutoLoginBackend extends UserBackend
|
|||||||
private $stripUsernameRegexp;
|
private $stripUsernameRegexp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create new autologin backend
|
* Create new authentication backend of type "external"
|
||||||
*
|
*
|
||||||
* @param ConfigObject $config
|
* @param ConfigObject $config
|
||||||
*/
|
*/
|
||||||
@ -33,7 +33,7 @@ class AutoLoginBackend extends UserBackend
|
|||||||
/**
|
/**
|
||||||
* Count the available users
|
* Count the available users
|
||||||
*
|
*
|
||||||
* Autologin backends will always return 1
|
* Authenticaton backends of type "external" will always return 1
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
@ -5,7 +5,7 @@
|
|||||||
namespace Icinga\Authentication;
|
namespace Icinga\Authentication;
|
||||||
|
|
||||||
use Countable;
|
use Countable;
|
||||||
use Icinga\Authentication\Backend\AutoLoginBackend;
|
use Icinga\Authentication\Backend\ExternalBackend;
|
||||||
use Icinga\Authentication\Backend\DbUserBackend;
|
use Icinga\Authentication\Backend\DbUserBackend;
|
||||||
use Icinga\Authentication\Backend\LdapUserBackend;
|
use Icinga\Authentication\Backend\LdapUserBackend;
|
||||||
use Icinga\Data\ConfigObject;
|
use Icinga\Data\ConfigObject;
|
||||||
@ -69,8 +69,8 @@ abstract class UserBackend implements Countable
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
$backendType = strtolower($backendType);
|
$backendType = strtolower($backendType);
|
||||||
if ($backendType === 'autologin') {
|
if ($backendType === 'external') {
|
||||||
$backend = new AutoLoginBackend($backendConfig);
|
$backend = new ExternalBackend($backendConfig);
|
||||||
$backend->setName($name);
|
$backend->setName($name);
|
||||||
return $backend;
|
return $backend;
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ namespace Icinga\Module\Setup\Forms;
|
|||||||
use Icinga\Web\Form;
|
use Icinga\Web\Form;
|
||||||
use Icinga\Forms\Config\Authentication\DbBackendForm;
|
use Icinga\Forms\Config\Authentication\DbBackendForm;
|
||||||
use Icinga\Forms\Config\Authentication\LdapBackendForm;
|
use Icinga\Forms\Config\Authentication\LdapBackendForm;
|
||||||
use Icinga\Forms\Config\Authentication\AutologinBackendForm;
|
use Icinga\Forms\Config\Authentication\ExternalBackendForm;
|
||||||
use Icinga\Data\ConfigObject;
|
use Icinga\Data\ConfigObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -80,7 +80,7 @@ class AuthBackendPage extends Form
|
|||||||
'Before you are able to authenticate using the LDAP connection defined earlier you need to'
|
'Before you are able to authenticate using the LDAP connection defined earlier you need to'
|
||||||
. ' provide some more information so that Icinga Web 2 is able to locate account details.'
|
. ' provide some more information so that Icinga Web 2 is able to locate account details.'
|
||||||
);
|
);
|
||||||
} else { // if ($this->config['type'] === 'autologin'
|
} else { // if ($this->config['type'] === 'external'
|
||||||
$note = $this->translate(
|
$note = $this->translate(
|
||||||
'You\'ve chosen to authenticate using a web server\'s mechanism so it may be necessary'
|
'You\'ve chosen to authenticate using a web server\'s mechanism so it may be necessary'
|
||||||
. ' to adjust usernames before any permissions, restrictions, etc. are being applied.'
|
. ' to adjust usernames before any permissions, restrictions, etc. are being applied.'
|
||||||
@ -103,8 +103,8 @@ class AuthBackendPage extends Form
|
|||||||
} elseif ($this->config['type'] === 'ldap') {
|
} elseif ($this->config['type'] === 'ldap') {
|
||||||
$backendForm = new LdapBackendForm();
|
$backendForm = new LdapBackendForm();
|
||||||
$backendForm->createElements($formData)->removeElement('resource');
|
$backendForm->createElements($formData)->removeElement('resource');
|
||||||
} else { // $this->config['type'] === 'autologin'
|
} else { // $this->config['type'] === 'external'
|
||||||
$backendForm = new AutologinBackendForm();
|
$backendForm = new ExternalBackendForm();
|
||||||
$backendForm->createElements($formData);
|
$backendForm->createElements($formData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,10 +37,10 @@ class AuthenticationPage extends Form
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (isset($formData['type']) && $formData['type'] === 'autologin' && !isset($_SERVER['REMOTE_USER'])) {
|
if (isset($formData['type']) && $formData['type'] === 'external' && !isset($_SERVER['REMOTE_USER'])) {
|
||||||
$this->addElement(
|
$this->addElement(
|
||||||
'note',
|
'note',
|
||||||
'autologin_note',
|
'external_note',
|
||||||
array(
|
array(
|
||||||
'value' => sprintf(
|
'value' => sprintf(
|
||||||
$this->translate(
|
$this->translate(
|
||||||
@ -80,7 +80,7 @@ class AuthenticationPage extends Form
|
|||||||
if (Platform::extensionLoaded('ldap')) {
|
if (Platform::extensionLoaded('ldap')) {
|
||||||
$backendTypes['ldap'] = 'LDAP';
|
$backendTypes['ldap'] = 'LDAP';
|
||||||
}
|
}
|
||||||
$backendTypes['autologin'] = $this->translate('Autologin');
|
$backendTypes['external'] = $this->translate('External');
|
||||||
|
|
||||||
$this->addElement(
|
$this->addElement(
|
||||||
'select',
|
'select',
|
||||||
|
@ -139,7 +139,7 @@ class AuthenticationStep extends Step
|
|||||||
. '<td><strong>' . t('User Name Attribute') . '</strong></td>'
|
. '<td><strong>' . t('User Name Attribute') . '</strong></td>'
|
||||||
. '<td>' . $this->data['backendConfig']['user_name_attribute'] . '</td>'
|
. '<td>' . $this->data['backendConfig']['user_name_attribute'] . '</td>'
|
||||||
. '</tr>'
|
. '</tr>'
|
||||||
) : ($authType === 'autologin' ? (
|
) : ($authType === 'external' ? (
|
||||||
'<tr>'
|
'<tr>'
|
||||||
. '<td><strong>' . t('Filter Pattern') . '</strong></td>'
|
. '<td><strong>' . t('Filter Pattern') . '</strong></td>'
|
||||||
. '<td>' . $this->data['backendConfig']['strip_username_regexp'] . '</td>'
|
. '<td>' . $this->data['backendConfig']['strip_username_regexp'] . '</td>'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user