Skip to content
Draft
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
1 change: 1 addition & 0 deletions src/roles/foreman/defaults/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ foreman_database_ssl_mode: disable
foreman_database_ssl_ca:
foreman_database_ssl_ca_path: /etc/foreman/db-ca.crt

foreman_name: "{{ ansible_facts['fqdn'] }}"
foreman_url: "http://{{ ansible_facts['fqdn'] }}:3000"

# Puma threads calculation:
Expand Down
3 changes: 3 additions & 0 deletions src/roles/foreman/templates/settings.yaml.j2
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
---
:foreman_url: {{ foreman_url }}

:hosts:
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs cnames

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which makes me wonder, right now the parameter is --certificate-cname, but in reality this is not about certificates (only) [and we already identified that "cname" is wtong]

so should the parameter be something like --alternative-server-name

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with the over-all principle here in a parameter that is above but feeds into certificates. Since naming is fun, other ideas:

--server-alias (how Apache defines it)
--server-name-alias
--subject-alternative-name (from certificates but still tied to that concept)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like --server-alias.

- {{ foreman_name }}

:ssl_certificate: /etc/foreman/client_cert.pem
:ssl_ca_file: /etc/foreman/katello-default-ca.crt
:ssl_priv_key: /etc/foreman/client_key.pem
Expand Down
3 changes: 2 additions & 1 deletion src/vars/base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ foreman_ca_certificate: "{{ server_ca_certificate }}"
foreman_client_key: "{{ client_key }}"
foreman_client_certificate: "{{ client_certificate }}"
foreman_plugins: "{{ enabled_features | features_to_foreman_plugins }}"
foreman_url: "https://{{ ansible_facts['fqdn'] }}"
foreman_name: "{{ ansible_facts['fqdn'] }}"
foreman_url: "https://{{ foreman_name }}"

httpd_server_ca_certificate: "{{ server_ca_certificate }}"
httpd_client_ca_certificate: "{{ client_ca_certificate }}"
Expand Down
10 changes: 8 additions & 2 deletions tests/foreman_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
]

@pytest.fixture(scope="module")
def foreman_status_curl(server):
return server.run(f"curl --header 'X-FORWARDED-PROTO: https' --silent --write-out '%{{stderr}}%{{http_code}}' http://{FOREMAN_HOST}:{FOREMAN_PORT}/api/v2/ping")
def foreman_status_curl(server, server_fqdn):
return server.run(f"curl --header 'X-FORWARDED-PROTO: https' --silent --write-out '%{{stderr}}%{{http_code}}' http://{server_fqdn}:{FOREMAN_PORT}/api/v2/ping")

@pytest.fixture(scope="module")
def foreman_status(foreman_status_curl):
Expand Down Expand Up @@ -78,3 +78,9 @@ def test_foreman_recurring_services_exist(server, instance):
def test_foreman_delivery_method_setting(foremanapi):
delivery_method_setting = foremanapi.list('settings', search='name=delivery_method')
assert delivery_method_setting[0]['value'] == 'smtp'


def test_foreman_host_injection(server):
cmd = server.run(f"curl --header 'X-FORWARDED-PROTO: https' --silent --write-out '%{{stderr}}%{{http_code}}' --resolve evil.hackers.test:{FOREMAN_PORT}:127.0.0.1 http://evil.hackers.test:{FOREMAN_PORT}/api/v2/ping")
assert cmd.succeeded
assert cmd.stderr == '403'
Loading