2014-09-29 06:27:11 -04:00
|
|
|
<?php
|
2016-02-08 09:41:00 -05:00
|
|
|
/* Icinga Web 2 | (c) 2014 Icinga Development Team | GPLv2+ */
|
2014-09-29 06:27:11 -04:00
|
|
|
|
2014-11-14 05:01:16 -05:00
|
|
|
namespace Icinga\Module\Setup\Forms;
|
2014-09-29 06:27:11 -04:00
|
|
|
|
2016-10-17 10:19:26 -04:00
|
|
|
use Icinga\Authentication\User\ExternalBackend;
|
2014-09-29 06:27:11 -04:00
|
|
|
use Icinga\Web\Form;
|
|
|
|
|
use Icinga\Application\Platform;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Wizard page to choose an authentication backend
|
|
|
|
|
*/
|
|
|
|
|
class AuthenticationPage extends Form
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Initialize this page
|
|
|
|
|
*/
|
|
|
|
|
public function init()
|
|
|
|
|
{
|
2015-03-02 12:36:04 -05:00
|
|
|
$this->setRequiredCue(null);
|
2014-09-29 06:27:11 -04:00
|
|
|
$this->setName('setup_authentication_type');
|
2015-03-02 12:36:04 -05:00
|
|
|
$this->setTitle($this->translate('Authentication', 'setup.page.title'));
|
|
|
|
|
$this->addDescription($this->translate(
|
|
|
|
|
'Please choose how you want to authenticate when accessing Icinga Web 2.'
|
|
|
|
|
. ' Configuring backend specific details follows in a later step.'
|
|
|
|
|
));
|
2014-09-29 06:27:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @see Form::createElements()
|
|
|
|
|
*/
|
|
|
|
|
public function createElements(array $formData)
|
|
|
|
|
{
|
2016-10-18 09:19:13 -04:00
|
|
|
if (isset($formData['type']) && $formData['type'] === 'external') {
|
2016-11-16 06:06:58 -05:00
|
|
|
list($username, $_) = ExternalBackend::getRemoteUserInformation();
|
|
|
|
|
if ($username === null) {
|
2016-10-18 09:19:13 -04:00
|
|
|
$this->info(
|
|
|
|
|
$this->translate(
|
|
|
|
|
'You\'re currently not authenticated using any of the web server\'s authentication '
|
|
|
|
|
. 'mechanisms. Make sure you\'ll configure such, otherwise you\'ll not be able to '
|
|
|
|
|
. 'log into Icinga Web 2.'
|
|
|
|
|
),
|
|
|
|
|
false
|
|
|
|
|
);
|
|
|
|
|
}
|
2015-01-26 10:58:40 -05:00
|
|
|
}
|
|
|
|
|
|
2014-09-29 06:27:11 -04:00
|
|
|
$backendTypes = array();
|
2014-12-01 09:38:10 -05:00
|
|
|
if (Platform::hasMysqlSupport() || Platform::hasPostgresqlSupport()) {
|
2015-01-19 05:07:39 -05:00
|
|
|
$backendTypes['db'] = $this->translate('Database');
|
2014-09-29 06:27:11 -04:00
|
|
|
}
|
|
|
|
|
if (Platform::extensionLoaded('ldap')) {
|
|
|
|
|
$backendTypes['ldap'] = 'LDAP';
|
|
|
|
|
}
|
2015-01-27 03:49:36 -05:00
|
|
|
$backendTypes['external'] = $this->translate('External');
|
2014-09-29 06:27:11 -04:00
|
|
|
|
|
|
|
|
$this->addElement(
|
|
|
|
|
'select',
|
|
|
|
|
'type',
|
|
|
|
|
array(
|
|
|
|
|
'required' => true,
|
2015-01-26 10:58:40 -05:00
|
|
|
'autosubmit' => true,
|
2015-01-19 05:07:39 -05:00
|
|
|
'label' => $this->translate('Authentication Type'),
|
|
|
|
|
'description' => $this->translate('The type of authentication to use when accessing Icinga Web 2'),
|
2014-09-29 06:27:11 -04:00
|
|
|
'multiOptions' => $backendTypes
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|