Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "use puppetlabs-{hocon, puppet_authorization} for auth.conf #615

Merged
merged 1 commit into from
Aug 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions .fixtures.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
fixtures:
repositories:
apache: 'https://github.com/puppetlabs/puppetlabs-apache.git'
concat: 'https://github.com/puppetlabs/puppetlabs-concat.git'
extlib: 'https://github.com/voxpupuli/puppet-extlib.git'
foreman: 'https://github.com/theforeman/puppet-foreman.git'
git: 'https://github.com/theforeman/puppet-git.git'
hocon: 'https://github.com/puppetlabs/puppetlabs-hocon.git'
inifile: 'https://github.com/puppetlabs/puppetlabs-inifile.git'
puppet_authorization: 'https://github.com/puppetlabs/puppetlabs-puppet_authorization.git'
puppetdb: 'https://github.com/puppetlabs/puppetlabs-puppetdb.git'
stdlib: 'https://github.com/puppetlabs/puppetlabs-stdlib.git'
apache: 'https://github.com/puppetlabs/puppetlabs-apache.git'
concat: 'https://github.com/puppetlabs/puppetlabs-concat.git'
extlib: 'https://github.com/voxpupuli/puppet-extlib.git'
foreman: 'https://github.com/theforeman/puppet-foreman.git'
git: 'https://github.com/theforeman/puppet-git.git'
hocon: 'https://github.com/puppetlabs/puppetlabs-hocon.git'
inifile: 'https://github.com/puppetlabs/puppetlabs-inifile.git'
puppetdb: 'https://github.com/puppetlabs/puppetlabs-puppetdb.git'
stdlib: 'https://github.com/puppetlabs/puppetlabs-stdlib.git'

symlinks:
puppet: "#{source_dir}"
300 changes: 2 additions & 298 deletions manifests/server/puppetserver.pp
Original file line number Diff line number Diff line change
Expand Up @@ -269,305 +269,9 @@
content => template('puppet/server/puppetserver/conf.d/puppetserver.conf.erb'),
}

$auth_conf = "${server_puppetserver_dir}/conf.d/auth.conf"

file { $auth_conf:
file { "${server_puppetserver_dir}/conf.d/auth.conf":
ensure => file,
}

hocon_setting { 'authorization.version':
ensure => present,
path => $auth_conf,
setting => 'authorization.version',
value => 1,
require => File[$auth_conf],
}

hocon_setting { 'authorization.allow-header-cert-info':
ensure => present,
path => $auth_conf,
setting => 'authorization.allow-header-cert-info',
value => $allow_header_cert_info or $server_http,
require => File[$auth_conf],
}

puppet_authorization::rule { 'puppetlabs catalog':
match_request_path => '^/puppet/v3/catalog/([^/]+)$',
match_request_type => 'regex',
match_request_method => ['get', 'post'],
allow => flatten(['$1', $server_trusted_agents]),
sort_order => 500,
path => $auth_conf,
require => File[$auth_conf],
}

puppet_authorization::rule { 'puppetlabs certificate':
match_request_path => '/puppet-ca/v1/certificate/',
match_request_type => 'path',
match_request_method => 'get',
allow_unauthenticated => true,
sort_order => 500,
path => $auth_conf,
require => File[$auth_conf],
}

puppet_authorization::rule { 'puppetlabs crl':
match_request_path => '/puppet-ca/v1/certificate_revocation_list/ca',
match_request_type => 'path',
match_request_method => 'get',
allow_unauthenticated => true,
sort_order => 500,
path => $auth_conf,
require => File[$auth_conf],
}

puppet_authorization::rule { 'puppetlabs csr':
match_request_path => '/puppet-ca/v1/certificate_request',
match_request_type => 'path',
match_request_method => ['get', 'put'],
allow_unauthenticated => true,
sort_order => 500,
path => $auth_conf,
require => File[$auth_conf],
}

puppet_authorization::rule { 'puppetlabs environments':
match_request_path => '/puppet/v3/environments',
match_request_type => 'path',
match_request_method => 'get',
allow => '*',
sort_order => 500,
path => $auth_conf,
require => File[$auth_conf],
}

puppet_authorization::rule { 'puppetlabs environment classes':
match_request_path => '/puppet/v3/environment_classes',
match_request_type => 'path',
match_request_method => 'get',
allow => '*',
sort_order => 500,
path => $auth_conf,
require => File[$auth_conf],
}

puppet_authorization::rule { 'puppetlabs node':
match_request_path => '^/puppet/v3/node/([^/]+)$',
match_request_type => 'regex',
match_request_method => 'get',
allow => '$1',
sort_order => 500,
path => $auth_conf,
require => File[$auth_conf],
}

puppet_authorization::rule { 'puppetlabs report':
match_request_path => '^/puppet/v3/report/([^/]+)$',
match_request_type => 'regex',
match_request_method => 'put',
allow => '$1',
sort_order => 500,
path => $auth_conf,
require => File[$auth_conf],
}

puppet_authorization::rule { 'puppetlabs status':
match_request_path => '/puppet/v3/status',
match_request_type => 'path',
match_request_method => 'get',
allow_unauthenticated => true,
sort_order => 500,
path => $auth_conf,
require => File[$auth_conf],
}

puppet_authorization::rule { 'puppetlabs static file content':
match_request_path => '/puppet/v3/static_file_content',
match_request_type => 'path',
match_request_method => 'get',
allow => '*',
sort_order => 500,
path => $auth_conf,
require => File[$auth_conf],
}

puppet_authorization::rule { 'environment-cache':
match_request_path => '/puppet-admin-api/v1/environment-cache',
match_request_type => 'path',
match_request_method => 'delete',
allow => $server_admin_api_whitelist,
sort_order => 200,
path => $auth_conf,
require => File[$auth_conf],
}

puppet_authorization::rule { 'jruby-pool':
match_request_path => '/puppet-admin-api/v1/jruby-pool',
match_request_type => 'path',
match_request_method => 'delete',
allow => $server_admin_api_whitelist,
sort_order => 200,
path => $auth_conf,
require => File[$auth_conf],
}

puppet_authorization::rule { 'puppetlabs deny all':
match_request_path => '/',
match_request_type => 'path',
deny => '*',
sort_order => 999,
path => $auth_conf,
require => File[$auth_conf],
}

$auth_conf_setting_ensure = $server_ca ? {
true => present,
default => absent,
}

if $server_ca_auth_required {
puppet_authorization::rule { 'certificate_status':
ensure => $auth_conf_setting_ensure,
match_request_path => '/puppet-ca/v1/certificate_status/',
match_request_type => 'path',
match_request_method => [ 'get', 'put', 'delete' ],
allow => $server_ca_client_whitelist,
sort_order => 200,
path => $auth_conf,
require => File[$auth_conf],
}

puppet_authorization::rule { 'certificate_statuses':
ensure => $auth_conf_setting_ensure,
match_request_path => '/puppet-ca/v1/certificate_statuses/',
match_request_type => 'path',
match_request_method => 'get',
allow => $server_ca_client_whitelist,
sort_order => 200,
path => $auth_conf,
require => File[$auth_conf],
}
} else {
puppet_authorization::rule { 'certificate_status':
ensure => $auth_conf_setting_ensure,
match_request_path => '/puppet-ca/v1/certificate_status/',
match_request_type => 'path',
match_request_method => [ 'get', 'put', 'delete' ],
allow_unauthenticated => true,
sort_order => 200,
path => $auth_conf,
require => File[$auth_conf],
}

puppet_authorization::rule { 'certificate_statuses':
ensure => $auth_conf_setting_ensure,
match_request_path => '/puppet-ca/v1/certificate_statuses/',
match_request_type => 'path',
match_request_method => 'get',
allow_unauthenticated => true,
sort_order => 200,
path => $auth_conf,
require => File[$auth_conf],
}
}

$is_puppetserver2 = versioncmp($server_puppetserver_version, '5.0') < 0
$is_puppetserver5 = versioncmp($server_puppetserver_version, '5.0') >= 0

$auth_conf_puppetserver_2_settings_ensure = $is_puppetserver2 ? {
true => present,
default => absent,
}

$auth_conf_puppetserver_5_settings_ensure = $is_puppetserver5 ? {
true => present,
default => absent,
}

puppet_authorization::rule { 'puppetlabs file bucket file':
ensure => $auth_conf_puppetserver_5_settings_ensure,
match_request_path => '/puppet/v3/file_bucket_file',
match_request_type => 'path',
match_request_method => ['get', 'head', 'post', 'put'],
allow => '*',
sort_order => 500,
path => $auth_conf,
require => File[$auth_conf],
}

puppet_authorization::rule { 'puppetlabs file content':
ensure => $auth_conf_puppetserver_5_settings_ensure,
match_request_path => '/puppet/v3/file_content',
match_request_type => 'path',
match_request_method => ['get', 'post'],
allow => '*',
sort_order => 500,
path => $auth_conf,
require => File[$auth_conf],
}

puppet_authorization::rule { 'puppetlabs file metadata':
ensure => $auth_conf_puppetserver_5_settings_ensure,
match_request_path => '/puppet/v3/file_metadata',
match_request_type => 'path',
match_request_method => ['get', 'post'],
allow => '*',
sort_order => 500,
path => $auth_conf,
require => File[$auth_conf],
}

if $is_puppetserver2 or ($is_puppetserver5 and !$server_experimental) {
$auth_conf_experimental_ensure = absent
} else {
$auth_conf_experimental_ensure = present
}

puppet_authorization::rule { 'puppetlabs experimental':
ensure => $auth_conf_experimental_ensure,
match_request_path => '/puppet/experimental',
match_request_type => 'path',
allow_unauthenticated => true,
sort_order => 500,
path => $auth_conf,
require => File[$auth_conf],
}

puppet_authorization::rule { 'puppetlabs resource type':
ensure => $auth_conf_puppetserver_2_settings_ensure,
match_request_path => '/puppet/v3/resource_type',
match_request_type => 'path',
match_request_method => ['get', 'post'],
allow => '*',
sort_order => 500,
path => $auth_conf,
require => File[$auth_conf],
}

puppet_authorization::rule { 'puppetlabs file':
ensure => $auth_conf_puppetserver_2_settings_ensure,
match_request_path => '/puppet/v3/file',
match_request_type => 'path',
allow => '*',
sort_order => 500,
path => $auth_conf,
require => File[$auth_conf],
}

if versioncmp($server_puppetserver_version, '5.1') >= 0 {
$auth_conf_tasks_ensure = present
} else {
$auth_conf_tasks_ensure = absent
}

puppet_authorization::rule { 'puppet tasks information':
ensure => $auth_conf_tasks_ensure,
match_request_path => '/puppet/v3/tasks',
match_request_type => 'path',
allow => '*',
sort_order => 500,
path => $auth_conf,
require => File[$auth_conf],
content => template('puppet/server/puppetserver/conf.d/auth.conf.erb'),
}

$webserver_conf = "${server_puppetserver_dir}/conf.d/webserver.conf"
Expand Down
4 changes: 0 additions & 4 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
"name": "puppetlabs/apache",
"version_requirement": ">= 1.2.0 < 4.0.0"
},
{
"name": "puppetlabs/puppet_authorization",
"version_requirement": ">= 0.3.0 < 1.0.0"
},
{
"name": "puppetlabs/concat",
"version_requirement": ">= 1.0.0 < 5.0.0"
Expand Down
14 changes: 6 additions & 8 deletions spec/classes/puppet_server_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -896,10 +896,9 @@
with_value('0.0.0.0')
end

it { should contain_hocon_setting('authorization.allow-header-cert-info').
with_path('/etc/custom/puppetserver/conf.d/auth.conf').
with_setting('authorization.allow-header-cert-info').
with_value(true)
it { should contain_file('/etc/custom/puppetserver/conf.d/auth.conf').
with_content(/allow-header-cert-info: true/).
with({})
}
end

Expand All @@ -913,10 +912,9 @@
}"
end

it { should contain_hocon_setting('authorization.allow-header-cert-info').
with_path('/etc/custom/puppetserver/conf.d/auth.conf').
with_setting('authorization.allow-header-cert-info').
with_value(true)
it { should contain_file('/etc/custom/puppetserver/conf.d/auth.conf').
with_content(/allow-header-cert-info: true/).
with({})
}
end

Expand Down
Loading