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

hashi_vault mTLS support #28

Open
levonet opened this issue Dec 15, 2020 · 9 comments
Open

hashi_vault mTLS support #28

levonet opened this issue Dec 15, 2020 · 9 comments
Labels
enhancement New feature or request

Comments

@levonet
Copy link

levonet commented Dec 15, 2020

SUMMARY

Currently, the lookup plugin does not support authorization for a client certificate.

ISSUE TYPE
  • Feature Idea
COMPONENT NAME

community.general/plugins/lookup/hashi_vault.py

ADDITIONAL INFORMATION
- debug:
    msg: "{{ lookup('community.general.hashi_vault', 'secret/hola:value', url='https://myvault:8200', token=vault_token,
      ca_cert='/cert/path/ca.crt', tls_key='/cert/path/client.key', tls_cert='/cert/path/client.crt') }}"

It may make sense to add an alias tls_ca for ca_cert to use parameters with names appropriate to the sense.

@ansibullbot

This comment has been minimized.

@ansibullbot

This comment has been minimized.

@ansibullbot

This comment has been minimized.

@levonet
Copy link
Author

levonet commented Dec 15, 2020

It may be more correct to name parameters as client_key and client_cert,
similar to ansible.builtin.uri.

@gundalow gundalow transferred this issue from ansible-collections/community.general Dec 15, 2020
@gundalow gundalow changed the title community.general.hashi_vault mTLS support hashi_vault mTLS support Dec 15, 2020
@gundalow
Copy link
Contributor

@levonet Thank you for this feature request, and thinking about consistency with ansible-builtin.uri

FYI we now have a dedicated collection called community.hash_vault, so I've moved this issue #28

@briantist
Copy link
Collaborator

Hi @levonet , thanks and welcome! Could you clarify whether you're looking for support for client cert verification on the vault server listener, or the cert auth method?

@levonet
Copy link
Author

levonet commented Dec 17, 2020

I want to use something like client cert verification. I didn't quite understand how tls_client_ca_file works.
The signed certificate and CA can be defined via tls_cert_file. And key in tls_key_file.

But on the ansible side, I want to use a client key and a temporary certificate signed by CA.

@briantist
Copy link
Collaborator

tls_client_ca is the CA cert used to determine is a presented client cert is valid.

tls_cert_file and tls_key_file are not related to client cert validation, I think. They are the keypair used to serve vault over TLS (so tls_cert_file is the cert you'd see in your browser if you connected to the vault server, for example).

I think (based on the description of tls_require_and_verify_client_cert) that if you don't provide tls_client_ca_file in your configuration, then client certs are validated against the CAs available on the server's system.

This plugin wouldn't be able to take and pass in a CA for client cert validation, as it's just making a request to a running vault server, not changing that server's TCP listener configuration. And it wouldn't be much of a validation if servers let you tell them which CAs to use to validate the certs you send in, as then the client can make every cert valid :)

The current ca_cert parameter is used for verifying that the certificate presented by the vault server is valid.


So as far as I can tell this request is not too difficult to implement, but the tests will be a bit tricky to fit into the existing test suite imo.

If I were to implement this it would be post 1.0.0 release of this collection, and probably after some considerable refactoring of the tests to make implementation easier. It's definitely something I think we should support.

If you'd like to implement please feel free to put up a PR!

@briantist briantist added the enhancement New feature or request label Dec 18, 2020
@levonet
Copy link
Author

levonet commented Dec 20, 2020

I want to do two-way authentication, like in Docker for example.
Thanks for the hint about tls_require_and_verify_client_cert.

This plugin wouldn't be able to take and pass in a CA for client cert validation, as it's just making a request to a running vault server, not changing that server's TCP listener configuration. And it wouldn't be much of a validation if servers let you tell them which CAs to use to validate the certs you send in, as then the client can make every cert valid :)

I understand that. But without CA private key, it is not possible to sign a client certificate. mTLS is here only at the channel level and should not contact the service directly.
I want to try this design with mTLS because in my architecture it is much easier to automatically create a temporary client certificate than to manage access tokens manually.

If you'd like to implement please feel free to put up a PR!
Maybe we will do it ourselves.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants