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

pulp_webserver: Add support for TLS configuration #325

Closed
wants to merge 1 commit into from

Conversation

Spredzy
Copy link
Contributor

@Spredzy Spredzy commented Jun 9, 2020

Enable HTTPS by default when deploying a new pulp server. One can either
specify the value of the certificate and the key. Or, if none available,
can have the installer generating them.

Support has been added for both nginx and apache.

fixes #6845
fixes #6847

@pulpbot
Copy link
Member

pulpbot commented Jun 9, 2020

Attached issue: https://pulp.plan.io/issues/6845

Attached issue: https://pulp.plan.io/issues/6847

@Spredzy Spredzy force-pushed the add_ssl_support branch 2 times, most recently from 0d10467 to 02c96e7 Compare June 9, 2020 13:48
@fao89 fao89 requested a review from bmbouter June 9, 2020 14:03
@Spredzy Spredzy force-pushed the add_ssl_support branch 3 times, most recently from 5843eca to a91ca59 Compare June 10, 2020 12:34
CHANGES/6845.feature Outdated Show resolved Hide resolved
Copy link
Member

@mdellweg mdellweg left a comment

Choose a reason for hiding this comment

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

This is a breaking change, because we (by default) disable the api on port 80. I think, this is the behaviour an end use would want. So can you please add a .removal changelog entry?

Since pulp_webserver_disable_https is False by default, i believe our molecule tests are already executing the new code paths. But i would be glad to see some additional tests, that the api (status page) is really accessible via https and that port 80 is redirected there.

roles/pulp_webserver/tasks/generate_tls_certificates.yml Outdated Show resolved Hide resolved
roles/pulp_webserver/tasks/main.yml Outdated Show resolved Hide resolved
@Spredzy Spredzy force-pushed the add_ssl_support branch 2 times, most recently from 2238b57 to 3740243 Compare June 19, 2020 10:02
@Spredzy
Copy link
Contributor Author

Spredzy commented Jun 19, 2020

@mdellweg I have a question regarding your last comment - Not surre I fully grasp it.

This is a breaking change, because we (by default) disable the api on port 80. I think, this is the behaviour an end use would want. So can you please add a .removal changelog entry?

This doesn't enable api on port 80 per se. (Not more that it was already reachable on port 80 before this PR through nginx proxying). So not sure which removal is required here. For user this change "should" be transparent and if they keep reaching http they will be automatically re-routed to https.

Could you provide me with more details on what you meant in the above ? (And thanks for the reviews)

@Spredzy Spredzy force-pushed the add_ssl_support branch 2 times, most recently from be915c8 to 636cf65 Compare June 19, 2020 10:34
@mdellweg
Copy link
Member

I believe, you need to adjust the content_origin setting (found in multiple places).

Copy link
Member

@mikedep333 mikedep333 left a comment

Choose a reason for hiding this comment

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

Thank you for working on this! This is a lot of work I can tell, but see comments.

Comment on lines +21 to +39
describe http('http://localhost/pulp/api/v3/status',
ssl_verify: false) do
its('status') { should eq 301 }
end
end

describe http('http://localhost/pulp/api/v3/status',
ssl_verify: false, max_redirects: 1) do
its('status') { should eq 200 }
its('body') { should match /database_connection/ }
end
end

describe http('https://localhost/pulp/api/v3/status',
ssl_verify: false) do
its('status') { should eq 200 }
its('body') { should match /database_connection/ }
end
end
Copy link
Member

Choose a reason for hiding this comment

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

These will fail due to this bug:
https://pulp.plan.io/issues/6586

It's been bugging me for a while, but other devs do not want privileged containers, so it is non-trivial to fix.

roles/pulp_webserver/handlers/main.yml Show resolved Hide resolved
roles/pulp_webserver/tasks/generate_tls_certificates.yml Outdated Show resolved Hide resolved
roles/pulp_webserver/README.md Show resolved Hide resolved
roles/pulp_webserver/defaults/main.yml Outdated Show resolved Hide resolved
roles/pulp_webserver/tasks/generate_tls_certificates.yml Outdated Show resolved Hide resolved
Comment on lines +17 to +9
- name: Generate CA key
openssl_privatekey:
path: '{{ pulp_webserver_tls_folder }}/root.key'
Copy link
Member

Choose a reason for hiding this comment

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

I'm concerned about what happens with these modules if a user runs the installer, replaces the key files on disk in the same filepaths with their desired keys, and then re-runs the installer:
https://docs.ansible.com/ansible/latest/modules/openssl_privatekey_module.html

Please note that the module regenerates private keys if they don’t match the module’s options. In particular, if you provide another passphrase (or specify none), change the keysize, etc., the private key will be regenerated. If you are concerned that this could overwrite your private key, consider using the backup option.

Copy link
Contributor Author

@Spredzy Spredzy Jul 2, 2020

Choose a reason for hiding this comment

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

In a general approach, I would say don't do that. If this is what you want to do, use the installer to do it and re-run the installer with pulp_webserver_ssl_cert and pulp_webserver_ssl_key. If you don't yet says you want TLS then yes what you have described will happen. But I feel like it is doing it by design, rightfully.

If you think this is wrong. We can condition this whole block into the conditional non-existence off those 2 files.
And add a pulp_webserver_force_regenerate_certificate or something similar if one really really wants to do it.

Copy link
Member

Choose a reason for hiding this comment

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

I agree. If the keys are managed by ansible, do not even think about messing around by hand.

Comment on lines +63 to +59
- name: Cleanup CSR files
file:
path: '{{ pulp_webserver_tls_folder }}/{{ item }}'
state: absent
loop:
- root.csr
- pulp_webserver.csr
Copy link
Member

Choose a reason for hiding this comment

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

This will fail idempotency with the task that generates them above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Might be addressed by #325 (comment) based on the option chosen

roles/pulp_webserver/tasks/main.yml Outdated Show resolved Hide resolved
@mikedep333
Copy link
Member

mikedep333 commented Jun 19, 2020

@mdellweg @Spredzy The problem we have this that often Pulp needs to return an absolute URL for certain plugins. So content_origin sets the canonical beginning of the URL, including http or https.
https://github.com/pulp/pulp_installer/blob/master/playbooks/example-use/group_vars/all#L18

So if content_origin is one protocol, and the user accesses on the other protocol, they will be redirected to the other at some point.

That said, I thought pulp-api could be accessed at port 80 via the webserver.

@mdellweg
Copy link
Member

And therefore the user should reconfigure her/his clients to the new protocol, but must reset content_origin, which is a breaking change.

@Spredzy Spredzy force-pushed the add_ssl_support branch 3 times, most recently from 3ac5c42 to f4818ee Compare July 2, 2020 09:18
Enable HTTPS by default when deploying a new pulp server. One can either
specify the value of the certificate and the key. Or, if none available,
can have the installer generating them.

Support has been added for both nginx and apache.

fixes #6845
fixes #6847
@Spredzy
Copy link
Contributor Author

Spredzy commented Jul 2, 2020

@mdellweg I have addressed/answered all comments in this PR. I'll let you make this PR cross the finish line. And work out the details. Thanks very much for volunteering for it and hopefully it won't be a nightmare <3

@mdellweg
Copy link
Member

mdellweg commented Jul 7, 2020

@mikedep333 To the content_origin problem: Yes, the user is redirected to use https, but if we constantly give him new urls starting with http://, he will make one unencrypted call (probably including credentials) before getting redirected again. Therefore, i think we need to create those addresses with https in mind.

@mdellweg mdellweg mentioned this pull request Jul 7, 2020
@dkliban
Copy link
Member

dkliban commented Jul 8, 2020

Closing in favor of #356 which is an extension of this work.

@dkliban dkliban closed this Jul 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants