Пример #1
0
 /**
  * @see Form::createElements()
  */
 public function createElements(array $formData)
 {
     if (isset($formData['type']) && $formData['type'] === 'external') {
         list($username, $_) = ExternalBackend::getRemoteUserInformation();
         if ($username === null) {
             $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);
         }
     }
     $backendTypes = array();
     if (Platform::hasMysqlSupport() || Platform::hasPostgresqlSupport()) {
         $backendTypes['db'] = $this->translate('Database');
     }
     if (Platform::extensionLoaded('ldap')) {
         $backendTypes['ldap'] = 'LDAP';
     }
     $backendTypes['external'] = $this->translate('External');
     $this->addElement('select', 'type', array('required' => true, 'autosubmit' => true, 'label' => $this->translate('Authentication Type'), 'description' => $this->translate('The type of authentication to use when accessing Icinga Web 2'), 'multiOptions' => $backendTypes));
 }
Пример #2
0
 /**
  * Return the name of the externally authenticated user
  *
  * @return  string
  */
 protected function getUsername()
 {
     list($name, $_) = ExternalBackend::getRemoteUserInformation();
     if ($name === null) {
         return '';
     }
     if (isset($this->backendConfig['strip_username_regexp']) && $this->backendConfig['strip_username_regexp']) {
         // No need to silence or log anything here because the pattern has
         // already been successfully compiled during backend configuration
         $name = preg_replace($this->backendConfig['strip_username_regexp'], '', $name);
     }
     return $name;
 }