Skip to content

Commit

Permalink
Fixes #72 Support for Custom Service Path (#75)
Browse files Browse the repository at this point in the history
* Fixes #72 Support for Custom Service Path

* Fixed linting errors
  • Loading branch information
infamousjoeg authored Feb 15, 2024
1 parent 00f313b commit 3a51256
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 48 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: infamousjoeg
51 changes: 27 additions & 24 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 18 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
This project simplifies the interaction between a Python 3 application or script and CyberArk's Application Access Manager's Credential Provider using the appropriate CLIPasswordSDK executable for the Operating System being used. By simplifying this process, developers are only required to change four (4) lines of code in their Python 3 applications and scripts to securely retrieve privileged secrets from CyberArk's Privileged Access Security (PAS) Core Solution as opposed to thirty or more (30+) without the use of this provided Client Library.

### New in Version 1.5.0: <!-- omit from toc -->
### New in Version 1.5.1: <!-- omit from toc -->

- Added support for `timeout` when intializing the CCPPasswordREST() class.
- Added support for `delimiter` parameter in `GetPassword()` method for Credential Provider (CLIPasswordSDK) method.
- Added support for Client Certificate Authentication in `GetPassword()` method for Centralized Credential Provider (CCPPasswordREST) method.
- Added support for custom service path during initialization of the CCPPasswordREST() class. [See documentation below for more details.](#example-with-custom-service-path)

## Table of Contents <!-- omit from toc -->

Expand Down Expand Up @@ -49,6 +47,7 @@ This project simplifies the interaction between a Python 3 application or script
- [Query Parameters](#query-parameters-1)
- [Example](#example-1)
- [Example with Client Certificate Authentication](#example-with-client-certificate-authentication)
- [Example with Custom Service Path](#example-with-custom-service-path)
- [Maintainer](#maintainer)
- [Contributing](#contributing)
- [License](#license)
Expand Down Expand Up @@ -214,7 +213,8 @@ For compatibility with Dual Accounts where you are referencing a `VirtualUsernam
```python
from pyaim import CCPPasswordREST

aimccp = CCPPasswordREST('https://ccp.cyberarkdemo.example', verify=True, timeout=10) # set verify=False to ignore SSL
# set verify=False to ignore SSL
aimccp = CCPPasswordREST('https://ccp.cyberarkdemo.example', 'AIMWebService', verify=True, timeout=10)

service_status = aimccp.check_service()

Expand All @@ -232,7 +232,19 @@ else:
```python
from pyaim import CCPPasswordREST

aimccp = CCPPasswordREST('https://ccp.cyberarkdemo.example', verify=True, cert=('/path/to/cert.pem', '/path/to/key.pem')) # set verify=False to ignore SSL
# set verify=False to ignore SSL
aimccp = CCPPasswordREST('https://ccp.cyberarkdemo.example', verify=True, cert=('/path/to/cert.pem', '/path/to/key.pem'))

...
```

##### Example with Custom Service Path

```python
from pyaim import CCPPasswordREST

# set verify=False to ignore SSL
aimccp = CCPPasswordREST('https://ccp.cyberarkdemo.example', 'AIMWebServiceDEV', verify=True)

...
```
Expand All @@ -241,8 +253,6 @@ aimccp = CCPPasswordREST('https://ccp.cyberarkdemo.example', verify=True, cert=(

[@infamousjoeg](https://github.com/infamousjoeg)

[![Buy me a coffee][buymeacoffee-shield]][buymeacoffee]

[buymeacoffee]: https://www.buymeacoffee.com/infamousjoeg
[buymeacoffee-shield]: https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png

Expand Down
26 changes: 18 additions & 8 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
This project simplifies the interaction between a Python 3 application or script and CyberArk's Application Access Manager's Credential Provider using the appropriate CLIPasswordSDK executable for the Operating System being used. By simplifying this process, developers are only required to change four (4) lines of code in their Python 3 applications and scripts to securely retrieve privileged secrets from CyberArk's Privileged Access Security (PAS) Core Solution as opposed to thirty or more (30+) without the use of this provided Client Library.

### New in Version 1.5.0: <!-- omit from toc -->
### New in Version 1.5.1: <!-- omit from toc -->

- Added support for `timeout` when intializing the CCPPasswordREST() class.
- Added support for `delimiter` parameter in `GetPassword()` method for Credential Provider (CLIPasswordSDK) method.
- Added support for Client Certificate Authentication in `GetPassword()` method for Centralized Credential Provider (CCPPasswordREST) method.
- Added support for custom service path during initialization of the CCPPasswordREST() class. [See documentation below for more details.](#example-with-custom-service-path)

## Table of Contents <!-- omit from toc -->

Expand Down Expand Up @@ -49,6 +47,7 @@ This project simplifies the interaction between a Python 3 application or script
- [Query Parameters](#query-parameters-1)
- [Example](#example-1)
- [Example with Client Certificate Authentication](#example-with-client-certificate-authentication)
- [Example with Custom Service Path](#example-with-custom-service-path)
- [Maintainer](#maintainer)
- [Contributing](#contributing)
- [License](#license)
Expand Down Expand Up @@ -214,7 +213,8 @@ For compatibility with Dual Accounts where you are referencing a `VirtualUsernam
```python
from pyaim import CCPPasswordREST

aimccp = CCPPasswordREST('https://ccp.cyberarkdemo.example', verify=True, timeout=10) # set verify=False to ignore SSL
# set verify=False to ignore SSL
aimccp = CCPPasswordREST('https://ccp.cyberarkdemo.example', 'AIMWebService', verify=True, timeout=10)

service_status = aimccp.check_service()

Expand All @@ -232,7 +232,19 @@ else:
```python
from pyaim import CCPPasswordREST

aimccp = CCPPasswordREST('https://ccp.cyberarkdemo.example', verify=True, cert=('/path/to/cert.pem', '/path/to/key.pem')) # set verify=False to ignore SSL
# set verify=False to ignore SSL
aimccp = CCPPasswordREST('https://ccp.cyberarkdemo.example', verify=True, cert=('/path/to/cert.pem', '/path/to/key.pem'))

...
```

##### Example with Custom Service Path

```python
from pyaim import CCPPasswordREST

# set verify=False to ignore SSL
aimccp = CCPPasswordREST('https://ccp.cyberarkdemo.example', 'AIMWebServiceDEV', verify=True)

...
```
Expand All @@ -241,8 +253,6 @@ aimccp = CCPPasswordREST('https://ccp.cyberarkdemo.example', verify=True, cert=(

[@infamousjoeg](https://github.com/infamousjoeg)

[![Buy me a coffee][buymeacoffee-shield]][buymeacoffee]

[buymeacoffee]: https://www.buymeacoffee.com/infamousjoeg
[buymeacoffee-shield]: https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png

Expand Down
11 changes: 6 additions & 5 deletions pyaim/aimccp.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
class CCPPasswordREST:
"""Class for interacting with CyberArk's CCP REST API."""

def __init__(self, base_uri, verify=True, cert=None, timeout=30):
def __init__(self, base_uri, service_path="AIMWebService", verify=True, cert=None, timeout=30): # pylint: disable=too-many-arguments

# Declare Init Variables
self._base_uri = base_uri.rstrip('/').replace('https://','')
self._service_path = service_path
self._headers = {'Content-Type': 'application/json'}
self._timeout = timeout

Expand All @@ -28,7 +29,7 @@ def __init__(self, base_uri, verify=True, cert=None, timeout=30):
def check_service(self):
"""Checks that the AIM Web Service is available."""
try:
url = '/AIMWebService/v1.1/aim.asmx'
url = f'/{self._service_path}/v1.1/aim.asmx'
conn = http.client.HTTPSConnection(
self._base_uri, context=self._context, timeout=self._timeout)
conn.request("GET", url, headers=self._headers)
Expand All @@ -37,12 +38,12 @@ def check_service(self):
conn.close()

if status_code != 200:
raise ConnectionError('ERROR: AIMWebService Not Found.')
raise ConnectionError(f'ERROR: {self._service_path} Not Found.')

except Exception as e:
raise Exception(e) # pylint: disable=raise-missing-from,broad-exception-raised

return f"SUCCESS: AIMWebService Found. Status Code: {status_code}"
return f"SUCCESS: {self._service_path} Found. Status Code: {status_code}"

def GetPassword(self, appid=None, safe=None, folder=None, object=None, # pylint: disable=redefined-builtin,invalid-name,disable=too-many-arguments,too-many-locals
username=None, address=None, database=None, policyid=None,
Expand Down Expand Up @@ -83,7 +84,7 @@ def GetPassword(self, appid=None, safe=None, folder=None, object=None, # pylint:
# Urlify parameters for GET Request
params = urllib.parse.urlencode(var_filtered)
# Build URL for GET Request
url = f"/AIMWebService/api/Accounts?{params}"
url = f"/{self._service_path}/api/Accounts?{params}"

try:
conn = http.client.HTTPSConnection(
Expand Down
2 changes: 1 addition & 1 deletion pyaim/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
is intended to be reused in multiple places.
"""

__version__ = '1.5.0'
__version__ = '1.5.1'
8 changes: 6 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
packages=setuptools.find_packages(),
classifiers=[
"Programming Language :: Python :: 3 :: Only",
"Development Status :: 4 - Beta",
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
Expand All @@ -52,7 +52,11 @@
"identity",
"pam",
"pim",
"pas"
"pas",
"ccp",
"cp",
"credential provider",
"identity security"
],
project_urls={
'Bug Reports': 'https://github.com/infamousjoeg/pyaim/issues/new?assignees=&labels=&template=bug_report.md&title=',
Expand Down

0 comments on commit 3a51256

Please sign in to comment.