ansible-collections / community.hashi_vault

Ansible collection for managing and working with HashiCorp Vault.
https://docs.ansible.com/ansible/devel/collections/community/hashi_vault/index.html
GNU General Public License v3.0
80 stars 59 forks source link

The default value of `token_validate` will change from `True` to `False` in version `4.0.0` #248

Closed briantist closed 1 year ago

briantist commented 2 years ago
SUMMARY

As a holdover from the original hashi_vault lookup, token auth does a lookup-self on the given token as a way to try to determine if the token is valid.

Later an option token_validate was added to control this (so that it could be turned off), because in some cases, tokens don't have permission to perform that operation.

But its default was set to true to match previous behavior.

However, this lookup is a largely unnecessary extra round-trip for everything that uses token auth, that's on by default.

The only real advantage of doing this lookup is that we can provide a more specific error message if this fails. Without this lookup, the token will attempt to be used for whatever operation is being performed, and if it's not valid, the failure returned will depend on the operation somewhat, and so it may look like a different error (permission denied for example).

The disadvantages of doing this "validation" are:


The only other area where this matters is in the vault_login lookup/module. Using token auth in vault_login returns the token itself (there is no login operation to perform), but it has to use lookup-self to get any additional information about the token, otherwise it will only return the token value (in the familiar structure).

So I have two options for vault_login:

  1. Let the default change (keep inheriting from the global definition)
  2. Change the default globally, but override the default in vault_login to be true.

~I am leaning toward option 1; the other information returned is the information least likely to be used, the option can be set explicitly, and there will be sufficient announcement of the change.~

After some testing, I will go with option 2. The issue is larger than just "extra" information, it's that with vault_login there is no "actual" operation to perform with a "token" login that will fail. So if you call vault_login with "token" auth and a bad/expired token, it will just return that (it will "succeed"). So I think validation defaulting to true for vault_login only makes sense.

ISSUE TYPE