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

Refs #32383: Configurable client certificate authentication to Pulp #186

Merged
merged 1 commit into from
May 3, 2021
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
15 changes: 11 additions & 4 deletions manifests/apache.pp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@
# Pulp has a default for remote header. Here it's ensured that the end user
# can't send that header to spoof users.
$remote_user_environ_header = $pulpcore::remote_user_environ_name.regsubst(/^HTTP_/, '')

$api_default_request_headers = [
"unset ${remote_user_environ_header}",
"set ${remote_user_environ_header} \"%{SSL_CLIENT_S_DN_CN}s\" env=SSL_CLIENT_S_DN_CN",
]

$api_additional_request_headers = $pulpcore::api_client_auth_cn_map.map |String $cn, String $pulp_user| {
"set ${remote_user_environ_header} \"${pulp_user}\" \"expr=%{SSL_CLIENT_S_DN_CN} == '${cn}'\""
}

$api_directory = {
'path' => $api_path,
'provider' => 'location',
Expand All @@ -53,10 +63,7 @@
'params' => $api_proxy_params,
},
],
'request_headers' => [
"unset ${remote_user_environ_header}",
"set ${remote_user_environ_header} \"%{SSL_CLIENT_S_DN_CN}s\" env=SSL_CLIENT_S_DN_CN",
],
'request_headers' => $api_default_request_headers + $api_additional_request_headers,
}

# Static content is served by the whitenoise application. SELinux prevents
Expand Down
4 changes: 4 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@
# @param api_service_worker_timeout
# Timeout in seconds of the pulpcore-api gunicorn workers.
#
# @param api_client_auth_cn_map
# Mapping of certificate common name and Pulp user to authenticate to Pulp API.
#
# @example Default configuration
# include pulpcore
#
Expand Down Expand Up @@ -200,6 +203,7 @@
Integer[0] $api_service_worker_count = 1,
Integer[0] $content_service_worker_timeout = 90,
Integer[0] $api_service_worker_timeout = 90,
Hash[String[1], String[1]] $api_client_auth_cn_map = {},
) {
$settings_file = "${config_dir}/settings.py"

Expand Down
45 changes: 45 additions & 0 deletions spec/classes/pulpcore_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,51 @@
is_expected.to contain_service("pulpcore-worker@1.service").with_ensure(false)
end
end

context 'with API client auth common names' do
let :params do
{
'api_client_auth_cn_map': {'foreman.example.com' => 'admin'}
}
end

it do
is_expected.to contain_apache__vhost('pulpcore-https')
.with_directories([
{
'provider' => 'Directory',
'path' => '/var/lib/pulp/pulpcore_static',
'options' => ['-Indexes', '-FollowSymLinks'],
'allow_override' => ['None'],
},
{
'path' => '/pulp/content',
'provider' => 'location',
'proxy_pass' => [{
'url' => 'unix:///run/pulpcore-content.sock|http://pulpcore-content/pulp/content',
'params' => {'timeout' => '600', 'disablereuse' => 'on'},
}],
'request_headers' => [
'unset X-CLIENT-CERT',
'set X-CLIENT-CERT "%{SSL_CLIENT_CERT}s" env=SSL_CLIENT_CERT',
],
},
{
'path' => '/pulp/api/v3',
'provider' => 'location',
'proxy_pass' => [{
'url' => 'unix:///run/pulpcore-api.sock|http://pulpcore-api/pulp/api/v3',
'params' => {'timeout' => '600'},
}],
'request_headers' => [
'unset REMOTE_USER',
'set REMOTE_USER "%{SSL_CLIENT_S_DN_CN}s" env=SSL_CLIENT_S_DN_CN',
'set REMOTE_USER "admin" "expr=%{SSL_CLIENT_S_DN_CN} == \'foreman.example.com\'"',
],
}
])
end
end
end
end
end