From 25665dec24f00cae177b71e4fd286ddb8d02472e Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 21 Feb 2014 10:16:16 +0100 Subject: [PATCH] Vagrant: Add authentication.ini and resources.ini to /etc/icingaweb refs #5638 --- .../files/etc/icingaweb/authentication.ini | 11 ++++++ .../files/etc/icingaweb/resources.ini | 34 +++++++++++++++++++ .vagrant-puppet/manifests/default.pp | 20 +++++++++++ library/Icinga/Authentication/Manager.php | 17 +++++++++- library/Icinga/Data/ResourceFactory.php | 6 ++-- 5 files changed, 85 insertions(+), 3 deletions(-) create mode 100644 .vagrant-puppet/files/etc/icingaweb/authentication.ini create mode 100644 .vagrant-puppet/files/etc/icingaweb/resources.ini diff --git a/.vagrant-puppet/files/etc/icingaweb/authentication.ini b/.vagrant-puppet/files/etc/icingaweb/authentication.ini new file mode 100644 index 000000000..d5b0d3e33 --- /dev/null +++ b/.vagrant-puppet/files/etc/icingaweb/authentication.ini @@ -0,0 +1,11 @@ +[internal_ldap_authentication] +backend = ldap +resource = internal_ldap +; Object class of the user +user_class = inetOrgPerson +; ; Attribute name for username +user_name_attribute = uid + +[internal_db_authentication] +backend = db +resource = "internal_db" diff --git a/.vagrant-puppet/files/etc/icingaweb/resources.ini b/.vagrant-puppet/files/etc/icingaweb/resources.ini new file mode 100644 index 000000000..2ef51e921 --- /dev/null +++ b/.vagrant-puppet/files/etc/icingaweb/resources.ini @@ -0,0 +1,34 @@ +[internal_db] +type = db +db = mysql +host = localhost +port = 3306 +password = icingaweb +username = icingaweb +dbname = icingaweb + +[ido] +type = db +db = mysql +host = localhost +port = 3306 +password = icinga +username = icinga +dbname = icinga + +[statusdat] +type = statusdat +status_file = /usr/local/icinga-mysql/var/status.dat +object_file = /usr/local/icinga-mysql/var/objects.cache + +[livestatus] +type = livestatus +socket = /usr/local/icinga-mysql/var/rw/live + +[internal_ldap] +type = ldap +hostname = localhost +port = 389 +root_dn = "ou=people, dc=icinga, dc=org" +bind_dn = "cn=admin,cn=config" +bind_pw = admin diff --git a/.vagrant-puppet/manifests/default.pp b/.vagrant-puppet/manifests/default.pp index 2ff8c5452..e1f54bccf 100644 --- a/.vagrant-puppet/manifests/default.pp +++ b/.vagrant-puppet/manifests/default.pp @@ -617,3 +617,23 @@ file { '/etc/httpd/conf.d/icingaweb.conf': require => Package['apache'], notify => Service['apache'] } + +file { '/etc/icingaweb': + ensure => 'directory', + owner => 'apache', + group => 'apache' +} + +file { '/etc/icingaweb/authentication.ini': + source => 'puppet:////vagrant/.vagrant-puppet/files/etc/icingaweb/authentication.ini', + owner => 'apache', + group => 'apache', + require => File['/etc/icingaweb'] +} + +file { '/etc/icingaweb/resources.ini': + source => 'puppet:////vagrant/.vagrant-puppet/files/etc/icingaweb/resources.ini', + owner => 'apache', + group => 'apache', + require => File['/etc/icingaweb'] +} diff --git a/library/Icinga/Authentication/Manager.php b/library/Icinga/Authentication/Manager.php index 6c8821061..e4e7efc0b 100644 --- a/library/Icinga/Authentication/Manager.php +++ b/library/Icinga/Authentication/Manager.php @@ -37,6 +37,7 @@ use Icinga\Data\ResourceFactory; use Icinga\Application\Logger; use Icinga\Exception\ConfigurationError; use Icinga\Exception\NotReadableError; +use Icinga\Exception\ProgrammingError; use Icinga\Application\Config as IcingaConfig; use Icinga\Authentication\Backend\DbUserBackend; use Icinga\Authentication\Backend\LdapUserBackend; @@ -149,7 +150,21 @@ class Manager } return new $backendConfig->class($backendConfig); } - if (($type = ResourceFactory::getResourceConfig($backendConfig->resource)->type) === null) { + if ($backendConfig->resource === null) { + throw new ConfigurationError( + 'Authentication configuration for backend "' . $backendConfig->name + . '" is missing the resource directive' + ); + } + try { + $type = ResourceFactory::getResourceConfig($backendConfig->resource)->type; + } catch (ProgrammingError $e) { + throw new ConfigurationError( + 'No authentication methods available. It seems that none resources have been set up. ' + . ' Please contact your Icinga Web administrator' + ); + } + if ($type === null) { throw new ConfigurationError( 'Authentication configuration for backend "%s" is missing the type directive', $backendConfig->name, diff --git a/library/Icinga/Data/ResourceFactory.php b/library/Icinga/Data/ResourceFactory.php index 7746e4f6e..d8a38c8d0 100644 --- a/library/Icinga/Data/ResourceFactory.php +++ b/library/Icinga/Data/ResourceFactory.php @@ -53,7 +53,7 @@ class ResourceFactory implements ConfigAwareFactory /** * Get the configuration for a specific resource * - * @param $resourceName String The resources name + * @param $resourceName String The resource's name * * @return Zend_Config The configuration of the resource * @throws \Icinga\Exception\ConfigurationError @@ -62,7 +62,9 @@ class ResourceFactory implements ConfigAwareFactory { self::assertResourcesExist(); if (($resourceConfig = self::$resources->get($resourceName)) === null) { - throw new ConfigurationError('Resource "' . $resourceName . '" couldn\'t be retrieved'); + throw new ConfigurationError( + 'Cannot load resource config "' . $resourceName . '". Resource does not exist' + ); } return $resourceConfig; }