From 16fdf0e28fa55d0d710bf3cf9a8d1e77d7f0c6c5 Mon Sep 17 00:00:00 2001 From: Benoit Bayszczak Date: Fri, 28 Aug 2020 17:22:07 +0200 Subject: [PATCH] [credential_plugin/hashivault] add approle_auth_path in inputs --- awx/main/credential_plugins/hashivault.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/awx/main/credential_plugins/hashivault.py b/awx/main/credential_plugins/hashivault.py index 38fce5501d..a61c80ecf4 100644 --- a/awx/main/credential_plugins/hashivault.py +++ b/awx/main/credential_plugins/hashivault.py @@ -41,11 +41,11 @@ base_inputs = { 'secret': True, 'help_text': _('The Secret ID for AppRole Authentication') }, { - 'id': 'auth_path', - 'label': _('Path to Auth'), + 'id': 'approle_auth_path', + 'label': _('Path to Approle Auth'), 'type': 'string', 'multiline': False, - 'help_text': _('The path where the Authentication method is mounted e.g, approle') + 'help_text': _('The path where the AppRole Authentication method is mounted e.g, approle') } ], 'metadata': [{ @@ -53,6 +53,12 @@ base_inputs = { 'label': _('Path to Secret'), 'type': 'string', 'help_text': _('The path to the secret stored in the secret backend e.g, /some/secret/') + }, { + 'id': 'auth_path', + 'label': _('Path to Auth'), + 'type': 'string', + 'multiline': False, + 'help_text': _('The path where the Authentication method is mounted e.g, approle') }], 'required': ['url', 'secret_path'], } @@ -119,7 +125,11 @@ def handle_auth(**kwargs): def approle_auth(**kwargs): role_id = kwargs['role_id'] secret_id = kwargs['secret_id'] - auth_path = kwargs.get('auth_path') or 'approle' + # we first try to use the 'auth_path' from the metadata + # if not found we try to fetch the 'approle_auth_path' from inputs + # if not found we use the default value 'approle' + auth_path = \ + kwargs.get('auth_path', kwargs.get('approle_auth_path', "approle")) url = urljoin(kwargs['url'], 'v1') cacert = kwargs.get('cacert', None)