mirror of
https://github.com/ansible/awx.git
synced 2026-01-18 13:11:19 -03:30
Use proper headers to auth with Vault
Reading examples at https://learn.hashicorp.com/vault/getting-started/apis show needing to use `X-Vault-Token` header, instead of `Authorization`. Without this header, the vault server would return a 400 status with an error message of "missing client token". With this change AWX is now able to interface with the Hashicorp backend.
This commit is contained in:
parent
686d4fe26f
commit
b3c264bf21
@ -102,7 +102,7 @@ def kv_backend(**kwargs):
|
||||
request_kwargs['verify'] = create_temporary_fifo(cacert.encode())
|
||||
|
||||
sess = requests.Session()
|
||||
sess.headers['Authorization'] = 'Bearer {}'.format(token)
|
||||
sess.headers['X-Vault-Token'] = token
|
||||
|
||||
if api_version == 'v2':
|
||||
if kwargs.get('secret_version'):
|
||||
@ -157,7 +157,7 @@ def ssh_backend(**kwargs):
|
||||
request_kwargs['json']['valid_principals'] = kwargs['valid_principals']
|
||||
|
||||
sess = requests.Session()
|
||||
sess.headers['Authorization'] = 'Bearer {}'.format(token)
|
||||
sess.headers['X-Vault-Token'] = token
|
||||
# https://www.vaultproject.io/api/secret/ssh/index.html#sign-ssh-key
|
||||
request_url = '/'.join([url, secret_path, 'sign', role]).rstrip('/')
|
||||
resp = sess.post(request_url, **request_kwargs)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user