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

Fixes #13402 allow user defined key retrieval from CYBR #13411

Merged
merged 5 commits into from Apr 13, 2023

Conversation

infamousjoeg
Copy link
Contributor

@infamousjoeg infamousjoeg commented Jan 6, 2023

SUMMARY

An enhancement request was made for the CyberArk Central Credential Provider Lookup to support user-defined key retrieval instead of the hardcoded Content retrieval which equates to a password or key value. This would allow users to specify other values to use, such as Username, Address, Port, Database, etc.

This PR adds a string field to the CyberArk Central Credential Provider Lookup credential plugin metadata for Object Property to be defined by the user. If no value is provided, the default value is Content which falls in line with behavior prior to this PR.

related #13402
related #5743

ISSUE TYPE
  • New or Enhanced Feature
COMPONENT NAME
  • UI
AWX VERSION
awx: 0.1.dev32738+gc34509f
ADDITIONAL INFORMATION

Screenshots from testing:
image
image
image

@obaranov
Copy link
Contributor

I verified the fix with the docker development environment. Everything works correctly except this moment: #13411 (comment)

@obaranov
Copy link
Contributor

Tested with the empty and missing object_property key. Eveything looks good.

@fosterseth fosterseth merged commit 11d5e5c into ansible:devel Apr 13, 2023
14 checks passed
john-westcott-iv pushed a commit that referenced this pull request May 17, 2023
* Fixed #13402 allow user defined key retrieval from CYBR

* Add default value to object_property

* Raise ValueError if object_property not in response

* Raise KeyError instead of ValueError
@infamousjoeg infamousjoeg deleted the add-addtl-key-support-cyberark branch August 28, 2023 14:56
@nielskroon
Copy link

nielskroon commented Oct 26, 2023

NB issue #14606 created for below

Using AWX 23.3.0 and trying to fetch the 'Address' via Central Credential Provider version 12.6 I encounter a key error.
Content and UserName works flawlessly BTW and using PowerShell or on another instance (same versions) we can reproduce this error (and Address field in the JSON response is there and has the proper value).

Please reopen this issue.

How to reproduce with a Credential Type "VMware vCenter" aiming at a self managed safe:

{
  "reason": "no particular",
  "object_query": "Safe=XXXXXX_Self;Object=awx-vcenter-test",
  "object_property": "Address",
  "object_query_format": "Exact"
}

Test button in credential edit page will show a Key Error, and playbook in debug mode using this credential in debug mode fails with this message:

Traceback (most recent call last):
  File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/awx/main/tasks/jobs.py", line 528, in run
    credential.credential_type.inject_credential(credential, env, self.safe_cred_env, args, private_data_dir)
  File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/awx/main/models/credential/__init__.py", line 455, in inject_credential
    getattr(builtin_injectors, credential.credential_type.namespace)(credential, injected_env, private_data_dir)
  File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/awx/main/models/credential/injectors.py", line 71, in vmware
    env['VMWARE_HOST'] = cred.get_input('host', default='')
  File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/awx/main/models/credential/__init__.py", line 279, in get_input
    return self._get_dynamic_input(field_name)
  File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/awx/main/models/credential/__init__.py", line 313, in _get_dynamic_input
    return input_source.get_input_value()
  File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/awx/main/models/credential/__init__.py", line 1258, in get_input_value
    return backend(**backend_kwargs)
  File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/awx/main/credential_plugins/aim.py", line 115, in aim_backend
    raise KeyError('Property {} not found in object'.format(object_property))
KeyError: 'Property Address not found in object'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants