Skip to content

Commit

Permalink
Allow hostname setting to not use default value (#275)
Browse files Browse the repository at this point in the history
Fixes #274
  • Loading branch information
treydock authored Feb 15, 2023
1 parent 295d2c3 commit df8c15d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ apache::vhost { 'idp.example.com':
}
```

**NOTE:** Can set `hostname` parameter to `unset` if you wish for that configuration to not be set in the Keycloak configuration if you wish for Keycloak to not use strict hostname checking and respond to multiple hostnames.

### Deploy SPI

A simple example of deploying a custom SPI from a URL:
Expand Down
14 changes: 10 additions & 4 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
# Additional configs for keycloak.conf
# @param hostname
# hostname to set in keycloak.conf
# Set to `unset` or `UNSET` to not define this in keycloak.conf
# @param http_enabled
# Whether to enable HTTP
# @param http_host
Expand Down Expand Up @@ -225,7 +226,7 @@
Optional[Stdlib::Absolutepath] $service_environment_file = undef,
Keycloak::Configs $configs = {},
Hash[String, Variant[String[1],Boolean,Array]] $extra_configs = {},
Stdlib::Host $hostname = $facts['networking']['fqdn'],
Variant[Stdlib::Host, Enum['unset','UNSET']] $hostname = $facts['networking']['fqdn'],
Boolean $http_enabled = true,
Stdlib::IP::Address $http_host = '0.0.0.0',
Stdlib::Port $http_port = 8080,
Expand Down Expand Up @@ -326,7 +327,7 @@
'features' => $features,
'features-disabled' => $features_disabled,
'proxy' => $proxy,
}
}.filter |$key, $value| { $value =~ NotUndef and ! ($value in ['unset', 'UNSET']) }
if $truststore {
$truststore_configs = {
'https-trust-store-file' => $truststore_file,
Expand All @@ -350,11 +351,16 @@
$validator_server = $config['http-host']
}
} else {
if $config['hostname'] in ['unset', 'UNSET'] {
$hostname = $facts['networking']['fqdn']
} else {
$hostname = $config['hostname']
}
$wrapper_protocol = 'https'
$wrapper_port = $config['https-port']
$wrapper_address = $config['hostname']
$wrapper_address = $hostname
$validator_port = $config['https-port']
$validator_server = $config['hostname']
$validator_server = $hostname
$validator_ssl = true
}
$wrapper_server = "${wrapper_protocol}://${wrapper_address}:${wrapper_port}${config['http-relative-path']}"
Expand Down
8 changes: 8 additions & 0 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,14 @@
])
end

context 'when hostname is unset' do
let(:params) { { hostname: 'unset' } }

it do
is_expected.to contain_file("/opt/keycloak-#{version}/conf/keycloak.conf").without_content(%r{^hostname=})
end
end

context 'when features defined' do
let(:params) { { features: ['authorization', 'impersonation'] } }

Expand Down

0 comments on commit df8c15d

Please sign in to comment.