Skip to content

Commit

Permalink
add config section to adjust the cookie path (#218)
Browse files Browse the repository at this point in the history
add config section to adjust the cookie path
  • Loading branch information
lazyfrosch committed May 20, 2019
2 parents 7a61339 + b76adf6 commit 289a31b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,9 @@ parameter. Default is dependent on the platform
##### `default_domain`
When using domain-aware authentication, you can set a default domain here.

##### `cookie_path`
Set the Cookie validity path for the Icinga Web 2 sessions. Defaults to `/icingaweb2`

#### Class: `icingaweb2::module::monitoring`
Manage the monitoring module. This module is mandatory for probably every setup.

Expand Down
10 changes: 10 additions & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
$theme = $::icingaweb2::theme
$theme_disabled = $::icingaweb2::theme_disabled

$cookie_path = $::icingaweb2::cookie_path

$import_schema = $::icingaweb2::import_schema
$schema_dir = $::icingaweb2::params::schema_dir
$db_name = $::icingaweb2::db_name
Expand Down Expand Up @@ -109,6 +111,14 @@
},
}

icingaweb2::inisection {'config-cookie':
section_name => 'cookie',
target => "${conf_dir}/config.ini",
settings => {
'path' => $cookie_path,
},
}

file { "${conf_dir}/modules":
ensure => 'directory'
}
Expand Down
1 change: 1 addition & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
Enum['ini', 'db'] $config_backend = 'ini',
String $conf_user = $icingaweb2::params::conf_user,
Optional[String] $default_domain = undef,
String $cookie_path = '/icingaweb2',
) inherits ::icingaweb2::params {

anchor { '::icingaweb2::begin': }
Expand Down
13 changes: 13 additions & 0 deletions spec/classes/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
.with_settings({ 'show_stacktraces' => false, 'module_path' => '/usr/share/icingaweb2/modules', 'config_backend' => 'ini' })
}
it { is_expected.to contain_icingaweb2__inisection('config-themes') }
it { is_expected.to contain_icingaweb2__inisection('config-cookie')
.with_settings({ 'path' => '/icingaweb2' })
}
it { is_expected.to contain_file('/var/log/icingaweb2')
.with_ensure('directory')
.with_mode('0750')
Expand Down Expand Up @@ -81,6 +84,16 @@
it { is_expected.to contain_icingaweb2__config__resource('mysql-icingaweb2')}
end

context 'with cookie_path => /' do
let :pre_condition do
"class { 'icingaweb2': cookie_path => '/' }"
end

it { is_expected.to contain_icingaweb2__inisection('config-cookie')
.with_settings({ 'path' => '/' })
}
end

context 'with invalid config_backend' do
let :pre_condition do
"class { 'icingaweb2': config_backend => 'foobar' }"
Expand Down

0 comments on commit 289a31b

Please sign in to comment.