CyberArk Application Access Manager Client Library for Python 3
Project description
pyAIM
CyberArk Application Access Manager Client Library for Python 3
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.
Table of Contents
- Install
- Usage
- Maintainer
- Contributing
- License
Install
Credential Provider (CLIPasswordSDK) Method
- CyberArk Application Access Manager Credential Provider installed locally.
Centralized Credential Provider (CCPPasswordREST) Method
- CyberArk Application Access Manager Centralized Credential Provider and AIMWebService
For information on how to install either of these providers, please refer to CyberArk's Application Access Manager Installation Guide or reach out to your assigned Customer Success Technical Advisor.
Windows
Install Latest Python 3
Install the Python 3 release for Windows
Install pyAIM via Pip
> pip3 install pyaim
Linux
Ubuntu/Debian
Install Latest Python 3
$ sudo apt install -y python3 python3-pip
Install pyAIM via Pip
$ pip3 install pyaim
RHEL/CentOS
Install Latest Python 3
RHEL
Follow the EPEL Documentation to ensure you have the EPEL Release repository available.
$ sudo yum install -y https://rhel7.iuscommunity.org/ius-release.rpm
$ sudo yum update
$ sudo yum install -y python36u python36u-libs python36u-devel python36u-pip
CentOS
$ sudo yum install -y https://centos7.iuscommunity.org/ius-release.rpm
$ sudo yum update
$ sudo yum install -y python36u python36u-libs python36u-devel python36u-pip
Install pyAIM via Pip
$ pip3 install pyaim
MacOS
No support provided yet.
Z/OS
pyAIM is untested on Z/OS but should work in theory.
Install Latest Python 3
Rocket Software has ported Python 2 and 3 for Z/OS
Install pyAIM via Pip
$ pip3 install pyaim
Usage
Check AIM Web Service - check_service()
⚠️ Important: In production mode (default), check_service() validates local configuration without making API calls to avoid generating CCP logs. For actual service health checks, use GetPassword() with test credentials.
Centralized Credential Provider (CCPPasswordREST) Method
Configuration Validation (No API Call)
from pyaim import CCPPasswordREST
# Validates configuration locally without contacting CCP
aimccp = CCPPasswordREST('https://ccp.cyberarkdemo.example', verify=True)
config_status = aimccp.check_service()
print(config_status)
# Output: "Configuration validated for ccp.cyberarkdemo.example/AIMWebService. Use GetPassword() to verify service health."
Production Health Check (Recommended)
from pyaim import CCPPasswordREST
aimccp = CCPPasswordREST('https://ccp.cyberarkdemo.example', verify=True)
# Health check using actual credential retrieval
try:
response = aimccp.GetPassword(
appid='monitoring_appid',
safe='health_check_safe',
object='health_check_account'
)
print("✓ CCP service is healthy and accessible")
print(f"Retrieved account: {response.get('Username', 'N/A')}")
except ConnectionError as e:
print(f"✗ CCP service unhealthy: {e}")
# Handle service down/unreachable scenario
except ValueError as e:
print(f"✗ Configuration error: {e}")
# Handle parameter validation errors
except Exception as e:
print(f"✗ CCP error: {e}")
# Handle other errors
Retrieve Account - GetPassword()
Credential Provider (CLIPasswordSDK) Method
Supported Parameters
Query Parameters
- appid (required)
- safe (required)
- folder (default: root)
- object (this or
usernamerequired) - username (this or
objectrequired) - address
- database
- policyid
- reason
- query_format (default: 1)
- connport
- sendhash (default: False)
- output (default: Password)
- delimiter (default: ,)
- dual_accounts (default: False)
For compatibility with Dual Accounts where you are referencing a VirtualUsername - use the username parameter and ensure dual_accounts=True.
Example
from pyaim import CLIPasswordSDK
aimcp = CLIPasswordSDK('/opt/CARKaim/sdk/clipasswordsdk')
response = aimcp.GetPassword(appid='appID',safe='safeName',object='objectName',output='PassProps.Username,Password',delimiter='|')
print('Full Response: {}'.format(response))
print('Username: {}'.format(response['PassProps.Username']))
print('Password: {}'.format(response['Password']))
Centralized Credential Provider (CCPPasswordREST) Method
Supported Parameters
CCPPasswordREST()
- url (required)
- verify (default: True) - SSL certificate verification. Accepts:
True- Use system's default certificate bundleFalse- Disable SSL verification (not recommended for production)/path/to/cert.pem- Path to custom certificate bundle file/path/to/cert/dir- Path to directory containing certificates (must be processed with c_rehash)
- cert (default: None)
- timeout (default: 30)
Query Parameters
- appid (required)
- safe (required)
- folder (default: root)
- object (this or
usernamerequired) - username (this or
objectrequired) - address
- database
- policyid
- reason
- query_format (default: exact)
- dual_accounts (default: False)
For compatibility with Dual Accounts where you are referencing a VirtualUsername - use the username parameter and ensure dual_accounts=True.
Example
from pyaim import CCPPasswordREST
# set verify=False to ignore SSL
aimccp = CCPPasswordREST('https://ccp.cyberarkdemo.example', 'AIMWebService', verify=True, timeout=10)
service_status = aimccp.check_service()
if service_status == 'SUCCESS: AIMWebService Found. Status Code: 200':
response = aimccp.GetPassword(appid='appid',safe='safe',object='objectName',reason='Reason message')
print('Full Python Object: {}'.format(response))
print('Username: {}'.format(response['Username']))
print('Password: {}'.format(response['Content']))
else:
raise Exception(service_status)
Example with Client Certificate Authentication
from pyaim import CCPPasswordREST
# 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
from pyaim import CCPPasswordREST
# set verify=False to ignore SSL
aimccp = CCPPasswordREST('https://ccp.cyberarkdemo.example', 'AIMWebServiceDEV', verify=True)
...
Example with Custom Certificate Bundle
from pyaim import CCPPasswordREST
# Use custom certificate bundle for SSL verification
aimccp = CCPPasswordREST('https://ccp.cyberarkdemo.example', verify='/path/to/custom-ca-bundle.pem')
# Or use a directory of certificates
aimccp = CCPPasswordREST('https://ccp.cyberarkdemo.example', verify='/etc/ssl/certs')
# Validate configuration
config_status = aimccp.check_service()
print(config_status)
# Actual credential retrieval
response = aimccp.GetPassword(appid='appid',safe='safe',object='objectName',reason='Reason message')
print('Username: {}'.format(response['Username']))
print('Password: {}'.format(response['Content']))
Health Check Best Practices
Why GetPassword() for Health Checks?
The GetPassword() method is the recommended approach for health checking because:
- No False Logs: Doesn't generate error logs in CCP with blank AppID/query fields
- Real Validation: Actually tests the full authentication and retrieval flow
- Production Ready: Uses legitimate credentials, avoiding synthetic health check calls
- Actionable Errors: Provides specific error messages for troubleshooting
Setting Up Health Check Accounts
Create a dedicated account in CCP for health monitoring:
- Create a safe called
health_check_safe(or similar) - Store a test account called
health_check_accountwith a known password - Create an AppID called
monitoring_appidwith read-only access to the safe - Use these credentials in your health check scripts
Benefits of this approach:
- Uses real CCP functionality
- Generates legitimate, filterable audit logs
- Provides accurate service status
- Allows alert suppression based on AppID if needed
Migration from Legacy check_service()
If upgrading from versions < 1.5.4 that relied on check_service() for actual health checks:
- Replace
check_service()calls withGetPassword()using test credentials - Set up dedicated health check AppID and safe (see above)
- Configure monitoring to catch
ConnectionErrorexceptions for service down alerts - Update alert filtering to use the new health check AppID instead of generic error patterns
Security Best Practices
SSL Certificate Configuration
Production Environments (Recommended)
# Use system's default certificate bundle (most secure)
aimccp = CCPPasswordREST('https://ccp.company.com', verify=True)
# Use custom CA bundle for internal certificates
aimccp = CCPPasswordREST('https://ccp.company.com', verify='/etc/ssl/certs/company-ca.pem')
# Use certificate directory (ensure proper permissions)
aimccp = CCPPasswordREST('https://ccp.company.com', verify='/etc/ssl/certs/')
Certificate File Security
File Permissions:
# Certificate files should be readable by application only
chmod 600 /path/to/cert.pem
chmod 600 /path/to/key.pem
# Certificate directories should have restricted access
chmod 755 /etc/ssl/certs/
chmod 600 /etc/ssl/certs/*
Important Security Notes:
- ⚠️ Never use
verify=Falsein production - this disables SSL certificate validation - 🔒 Protect private key files - ensure only the application user can read them
- 📋 Regular certificate rotation - monitor certificate expiration dates
- 🔐 Use client certificates for additional authentication when available
Troubleshooting SSL Issues
Common SSL Errors and Solutions:
-
Certificate Verification Failed
Error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed Solution: Use custom CA bundle or check certificate chain -
Certificate Path Issues
Error: Certificate path does not exist: /path/to/cert Solution: Verify file exists and has correct permissions -
Corporate Firewalls/Proxies
# For environments with corporate certificates aimccp = CCPPasswordREST( 'https://ccp.company.com', verify='/etc/ssl/certs/corporate-bundle.pem' )
AppID Security
Health Check AppID Configuration:
- Create dedicated AppID for monitoring (e.g.,
monitoring_appid) - Grant read-only access to health check safe only
- Use specific safe permissions rather than broad access
- Monitor AppID usage through CCP audit logs
- Rotate credentials according to security policy
Example Secure Setup:
# Production health check with dedicated, limited-privilege AppID
try:
response = aimccp.GetPassword(
appid='health_monitor_readonly', # Limited scope AppID
safe='monitoring_safe', # Dedicated safe for health checks
object='health_check_account', # Non-sensitive test account
reason='Automated health check' # Clear audit trail
)
# Service healthy
except ConnectionError as e:
# Log security-relevant connection issues
logger.error(f"CCP health check failed: {e}")
Maintainer
Contributing
Contributions are open! Check out CONTRIBUTING.md for more details!
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyaim-1.5.4.tar.gz.
File metadata
- Download URL: pyaim-1.5.4.tar.gz
- Upload date:
- Size: 18.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a3bbf18ba008f0b60d0858628a40af16075b6afedb14b019697d1d6372fbabb
|
|
| MD5 |
22a0aad9384dbf88cf74178ef45cc052
|
|
| BLAKE2b-256 |
3a009ff049c52f4e21dc07e2ca5b1bf2864bc791b8876a81637b774f779fcc89
|
File details
Details for the file pyaim-1.5.4-py3-none-any.whl.
File metadata
- Download URL: pyaim-1.5.4-py3-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3fdd196eb30e88dca92f292ef45ec3521b22eb4b6718493ddbddbd9cb99a2267
|
|
| MD5 |
dcebe423d7818807763eccb53eda9639
|
|
| BLAKE2b-256 |
1c5efb2023d1621ceb77352f348aebe96a16fb51edb68900847f795113c9beb3
|