-
Notifications
You must be signed in to change notification settings - Fork 23
CI: Avoid leaking credentials in container image builds #937
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
707d65b
Revert "Don't verify Apt repo CA initially when using HTTPS in contai…
markgoddard 5d50522
Revert "Add package repository credentials to container image build"
markgoddard c794383
Add Ansible Galaxy roles and collections to .gitignore
markgoddard 6dd2e7f
Add a playbook to deploy an authenticating Pulp proxy
markgoddard 9f940b7
Use authenticating Pulp proxy during container image builds
markgoddard 74e87c5
CI: Avoid hitting Dockerhub rate limits
markgoddard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
# See roles/pulp_auth_proxy/README.md for details. | ||
|
||
- name: Deploy Pulp auth proxy | ||
hosts: container-image-builders | ||
gather_facts: false | ||
tasks: | ||
- import_role: | ||
name: pulp_auth_proxy | ||
vars: | ||
pulp_auth_proxy_url: "{{ stackhpc_repo_mirror_url }}" | ||
pulp_auth_proxy_username: "{{ stackhpc_repo_mirror_username }}" | ||
pulp_auth_proxy_password: "{{ stackhpc_repo_mirror_password }}" | ||
pulp_auth_proxy_conf_path: "{{ base_path }}/containers/pulp_proxy" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Pulp Auth Proxy | ||
|
||
There is currently no practical, secure way to provide credentials for | ||
accessing Ark's authenticated package repositories from within a Kolla build. | ||
Docker provides [build | ||
secrets](https://docs.docker.com/build/building/secrets/), but these must be | ||
explicitly requested for each RUN statement, making them challenging to use in | ||
Kolla. | ||
|
||
This role deploys an Nginx container that runs as a reverse proxy, injecting an | ||
HTTP basic authentication header into requests. | ||
|
||
Because this proxy bypasses Pulp's authentication, it must not be exposed to | ||
any untrusted environment. | ||
|
||
## Role variables | ||
|
||
* `pulp_auth_proxy_pulp_url`: URL of the Pulp server to proxy requests to. | ||
* `pulp_auth_proxy_username`: Username of the Pulp server to proxy requests to. | ||
* `pulp_auth_proxy_password`: Password of the Pulp server to proxy requests to. | ||
* `pulp_auth_proxy_conf_path`: Path to a directory in which to write Nginx | ||
configuration. | ||
* `pulp_auth_proxy_listen_ip`: IP address on the Docker host on which to | ||
listen. Default is `127.0.0.1`. | ||
* `pulp_auth_proxy_listen_port`: Port on the Docker host on which to listen. | ||
Default is 80. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
pulp_auth_proxy_url: | ||
pulp_auth_proxy_username: | ||
pulp_auth_proxy_password: | ||
pulp_auth_proxy_conf_path: | ||
pulp_auth_proxy_listen_ip: 127.0.0.1 | ||
pulp_auth_proxy_listen_port: 80 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
- name: "Ensure {{ pulp_auth_proxy_conf_path }} exists" | ||
ansible.builtin.file: | ||
path: "{{ pulp_auth_proxy_conf_path }}" | ||
state: directory | ||
mode: 0700 | ||
become: true | ||
|
||
- name: Ensure pulp_proxy.conf is templated | ||
ansible.builtin.template: | ||
src: pulp_proxy.conf.j2 | ||
dest: "{{ pulp_auth_proxy_conf_path }}/pulp_proxy.conf" | ||
mode: 0600 | ||
become: true | ||
register: pulp_proxy_conf | ||
|
||
- name: Ensure pulp_proxy container is running | ||
community.docker.docker_container: | ||
name: pulp_proxy | ||
image: nginx:stable-alpine | ||
ports: | ||
- "{{ pulp_auth_proxy_listen_ip }}:{{ pulp_auth_proxy_listen_port }}:80" | ||
restart_policy: "no" | ||
restart: "{{ pulp_proxy_conf is changed }}" | ||
volumes: | ||
- "{{ pulp_auth_proxy_conf_path }}/pulp_proxy.conf:/etc/nginx/conf.d/default.conf:ro" |
17 changes: 17 additions & 0 deletions
17
etc/kayobe/ansible/roles/pulp_auth_proxy/templates/pulp_proxy.conf.j2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
server { | ||
listen {{ pulp_auth_proxy_listen_port }}; | ||
server_name pulp_proxy; | ||
location / { | ||
proxy_pass {{ pulp_auth_proxy_url }}; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
proxy_set_header Host {{ pulp_auth_proxy_url | urlsplit('hostname') }}; | ||
# The important part: add basic auth header | ||
proxy_set_header Authorization "Basic {{ (pulp_auth_proxy_username ~ ':' ~ pulp_auth_proxy_password) | b64encode }}"; | ||
proxy_pass_header Authorization; | ||
# See https://stackoverflow.com/questions/25329941/nginx-caching-proxy-fails-with-ssl23-get-server-hellosslv3-alert-handshake-fail/25330027#25330027 | ||
proxy_ssl_server_name on; | ||
proxy_ssl_protocols TLSv1.2; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
features: | ||
- | | ||
Adds a custom playbook (``pulp-auth-proxy.yml``) for deploying an | ||
authenticating proxy for Pulp. This can be used when building container | ||
images to avoid leaking credentials for package repositories into the built | ||
images or their metadata. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😬
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not ideal, but necessary with connection=local and ansible_python_interpreter=/usr/bin/python3.