Skip to content

Commit 9574607

Browse files
committed
Pass potentially Sensitive params as Sensitive
In 699f944 the parameters started to accept Sensitive but it didn't default to Sensitive. They also weren't converting data coming from Hiera. This adds a data-in-modules setup and sets lookup_options for those. This means Kafo (which heavily relies on Hiera) will pass sensitive values. It also changes the data type to accept Sensitive[Undef] which is needed if Hiera unconditionally converts the value to Sensitive. Fixes: 699f944
1 parent 699f944 commit 9574607

File tree

5 files changed

+26
-7
lines changed

5 files changed

+26
-7
lines changed

data/common.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
lookup_options:
2+
'^foreman::(\w_)+password$':
3+
convert_to: "Sensitive"
4+
'^foreman::oauth_consumer_(key|secret)$':
5+
convert_to: "Sensitive"
6+
foreman::cli::password:
7+
convert_to: "Sensitive"
8+
foreman::plugin::supervisory_authority::secret_token:
9+
convert_to: "Sensitive"

hiera.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
version: 5
3+
4+
defaults: # Used for any hierarchy level that omits these keys.
5+
datadir: data # This path is relative to hiera.yaml's directory.
6+
data_hash: yaml_data # Use the built-in YAML backend.
7+
8+
hierarchy:
9+
- name: "common"
10+
path: "common.yaml"

manifests/cli.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
String $version = $foreman::cli::params::version,
3131
Boolean $manage_root_config = $foreman::cli::params::manage_root_config,
3232
Optional[String] $username = $foreman::cli::params::username,
33-
Optional[Variant[String, Sensitive[String]]] $password = $foreman::cli::params::password,
33+
Variant[Optional[String], Sensitive[Optional[String]]] $password = $foreman::cli::params::password,
3434
Boolean $use_sessions = $foreman::cli::params::use_sessions,
3535
Boolean $refresh_cache = $foreman::cli::params::refresh_cache,
3636
Integer[-1] $request_timeout = $foreman::cli::params::request_timeout,

manifests/init.pp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@
215215
Variant[Undef, Enum['UNSET'], Stdlib::Port] $db_port = 'UNSET',
216216
Optional[String] $db_database = 'UNSET',
217217
Optional[String] $db_username = $foreman::params::db_username,
218-
Optional[Variant[String, Sensitive[String]]] $db_password = $foreman::params::db_password,
218+
Variant[Optional[String], Sensitive[Optional[String]]] $db_password = $foreman::params::db_password,
219219
Optional[String] $db_sslmode = 'UNSET',
220220
Optional[String] $db_root_cert = undef,
221221
Integer[0] $db_pool = $foreman::params::db_pool,
@@ -265,7 +265,7 @@
265265
Optional[Stdlib::Fqdn] $email_smtp_domain = $foreman::params::email_smtp_domain,
266266
Enum['none', 'plain', 'login', 'cram-md5'] $email_smtp_authentication = $foreman::params::email_smtp_authentication,
267267
Optional[String] $email_smtp_user_name = $foreman::params::email_smtp_user_name,
268-
Optional[Variant[String, Sensitive[String]]] $email_smtp_password = $foreman::params::email_smtp_password,
268+
Variant[Optional[String], Sensitive[Optional[String]]] $email_smtp_password = $foreman::params::email_smtp_password,
269269
Optional[String] $email_reply_address = $foreman::params::email_reply_address,
270270
Optional[String] $email_subject_prefix = $foreman::params::email_subject_prefix,
271271
String $telemetry_prefix = $foreman::params::telemetry_prefix,

manifests/params.pp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
$db_username = 'foreman'
3333
# Generate and cache the password on the master once
3434
# In multi-puppetmaster setups, the user should specify their own
35-
$db_password = extlib::cache_data('foreman_cache_data', 'db_password', extlib::random_password(32))
35+
$db_password = Sensitive(extlib::cache_data('foreman_cache_data', 'db_password', extlib::random_password(32)))
3636
# Default database connection pool
3737
$db_pool = 5
3838
# if enabled, will run rake jobs, which depend on the database
@@ -147,13 +147,13 @@
147147
# We need the REST API interface with OAuth for some REST Puppet providers
148148
$oauth_active = true
149149
$oauth_map_users = false
150-
$oauth_consumer_key = extlib::cache_data('foreman_cache_data', 'oauth_consumer_key', extlib::random_password(32))
151-
$oauth_consumer_secret = extlib::cache_data('foreman_cache_data', 'oauth_consumer_secret', extlib::random_password(32))
150+
$oauth_consumer_key = Sensitive(extlib::cache_data('foreman_cache_data', 'oauth_consumer_key', extlib::random_password(32)))
151+
$oauth_consumer_secret = Sensitive(extlib::cache_data('foreman_cache_data', 'oauth_consumer_secret', extlib::random_password(32)))
152152
$oauth_effective_user = 'admin'
153153

154154
# Initial admin account details
155155
$initial_admin_username = 'admin'
156-
$initial_admin_password = extlib::cache_data('foreman_cache_data', 'admin_password', extlib::random_password(16))
156+
$initial_admin_password = Sensitive(extlib::cache_data('foreman_cache_data', 'admin_password', extlib::random_password(16)))
157157
$initial_admin_first_name = undef
158158
$initial_admin_last_name = undef
159159
$initial_admin_email = undef

0 commit comments

Comments
 (0)