
Security News
PyPI Expands Trusted Publishing to GitLab Self-Managed as Adoption Passes 25 Percent
PyPI adds Trusted Publishing support for GitLab Self-Managed as adoption reaches 25% of uploads
beyondtrust-bips-library
Advanced tools
Password Safe API integration written in Python, Abstract complexity of managing secrets with the API.
Password Safe API integration written in Python, Abstract complexity of managing secrets with the API
This library is compatible with Python >= v3.11.
# PyPI
pip install beyondtrust-bips-library
get_access_levels() - List all available access levelspost_access_levels_usergroupid_smartruleid(usergroupid, smartruleid, accesslevelid) - Assign access level to user group and smart ruletest_access_policy(system_id, account_id, duration_minutes) - Test access policy configurationget_usergroup_permissions(usergroup_id) - Get permissions for user groupset_usergroup_permissions(usergroup_id, permissions) - Set user group permissionsdelete_usergroup_permissions(usergroup_id) - Remove user group permissionslist_assets(workgroup_id, workgroup_name, limit, ...) - List assets with filteringget_asset_by_id(asset_id) - Get specific asset by IDget_asset_by_workgroup_name(workgroup_name, asset_name) - Find asset by workgroup and namelist_asset_attributes(asset_id) - List attributes for an assetsearch_assets(asset_name, dns_name, domain_name, ...) - Search assets by criteriacreate_asset() - Create new assetupdate_asset(asset_id) - Update existing assetdelete_asset_by_id(asset_id) - Delete asset by IDget_managed_systems(limit, offset, type, name) - List managed systems with filteringget_managed_system_by_id(managed_system_id) - Get specific managed systemget_managed_system_by_asset_id(asset_id) - Get managed system by asset IDget_managed_system_by_database_id(database_id) - Get managed system by database IDpost_managed_system_by_asset_id(**kwargs) - Create managed system for assetpost_managed_system_by_database_id(**kwargs) - Create managed system for databasepost_managed_system_by_workgroup_id(**kwargs) - Create managed system for workgroupput_managed_system_by_id(managed_system_id, **kwargs) - Update managed systemdelete_managed_system_by_id(managed_system_id) - Delete managed systemget_databases() - List all databasesget_database_by_id(database_id) - Get specific databaseget_databases_by_asset_id(asset_id) - Get databases for an assetpost_database_by_asset_id(asset_id, platform_id, port, ...) - Create database for assetput_database_by_id(database_id, **kwargs) - Update databasedelete_database_by_id(database_id) - Delete databaseget_secret(path) - Get single secret by pathget_secret_with_metadata(path) - Get secret with metadata by pathget_secrets(paths) - Get multiple secrets by pathsget_secrets_with_metadata(paths) - Get multiple secrets with metadataget_all_secrets_by_folder_path(folder_path) - Get all secrets in a folderget_file_secret_data(secret_id) - Download file secret contentlist_secrets(**filters) - List secrets with optional filteringlist_secrets_by_folder_id(folder_id) - List secrets in specific foldercreate_secret(title, folder_id, **kwargs) - Create new secret (normal/text/file)update_secret(secret_id, **kwargs) - Update existing secretdelete_secret_by_id(secret_id) - Delete secret by IDget_secret_by_id(secret_id) - Get secret details by IDcreate_safe(name, description) - Create new safe containerupdate_safe(safe_id, name, description) - Update safe informationget_by_id(safe_id) - Get safe by ID (inherited)delete_by_id(safe_id) - Delete safe by ID (inherited)list() - List all safes (inherited)list_folders(folder_name, folder_path, include_subfolders, ...) - List folders with filteringcreate_folder(name, parent_id, description, ...) - Create new folderget_secret(path) - Get managed account credential by pathget_secret_with_metadata(path) - Get credential with metadataget_secrets(paths) - Get multiple credentials by pathsget_secrets_with_metadata(paths) - Get multiple credentials with metadatacreate_request(system_id, account_id) - Request access to managed accountget_credential_by_request_id(request_id) - Get account credentialsrequest_check_in(request_id, reason) - Release managed accountget_managed_accounts(**kwargs) - Search and filter managed accountslist_by_managed_system(managed_system_id) - List accounts by systemlist_by_smart_rule_id(smart_rule_id) - List accounts by smart rulelist_by_quick_rule_id(quick_rule_id) - List accounts by quick rulecreate_managed_account(**kwargs) - Create new managed accountassign_attribute(managed_account_id, attribute_id) - Assign attribute to accountdelete_attribute(managed_account_id, attribute_id) - Remove attribute from accountdelete_all_attributes(managed_account_id) - Remove all attributes from accountget_credentials_by_request_id(request_id, type) - Get credentials for a requestget_credentials_by_alias_id(alias_id, request_id, type) - Get credentials by aliasget_users(username, include_inactive) - List/search usersget_user_by_id(user_id) - Get specific user detailsget_users_by_usergroup_id(usergroup_id) - Get users in grouppost_user_beyondinsight(user_name, first_name, email_address, ...) - Create BeyondInsight userpost_user_active_directory(user_name, forest_name, domain_name, ...) - Create AD user integrationpost_user_ldap(host_name, distinguished_name, ...) - Create LDAP userpost_user_application(user_name, access_policy_id) - Create application userpost_user_quarantine(user_id) - Quarantine user accountput_user_beyondinsight(user_id, **kwargs) - Update BeyondInsight userput_user_application(user_id, **kwargs) - Update application userdelete_user(user_id) - Delete user accountget_usergroups() - List all user groupsget_usergroup_by_id(usergroup_id) - Get specific user groupget_usergroups_by_name(name) - Find user groups by namepost_usergroups_beyondinsight(group_name, description, is_active, ...) - Create BeyondInsight grouppost_usergroups_entraid(description, group_name, client_id, ...) - Create Entra ID grouppost_usergroups_ad(group_name, domain_name, description, ...) - Create AD grouppost_usergroups_ldap(group_name, group_distinguished_name, ...) - Create LDAP groupdelete_usergroup_by_name(name) - Delete user groupget_roles(user_group_id, smart_rule_id) - Get roles for user group and smart ruleset_roles(user_group_id, smart_rule_id, roles, ...) - Set user group rolesdelete_roles(user_group_id, smart_rule_id) - Remove user group rolesget_sessions(status, user_id) - List active sessionspost_sessions_request_id(request_id, session_type, node_id) - Create session from requestpost_sessions_admin(session_type, host_name, user_name, ...) - Create admin sessionpost_session_lock_sessionid(session_id) - Lock specific sessionpost_session_lock_managed_account_id(managed_account_id) - Lock sessions for accountpost_session_lock_managed_system_id(managed_system_id) - Lock sessions for systempost_session_terminate_sessionid(session_id) - Terminate specific sessionpost_session_terminate_managedaccountid(managed_account_id) - Terminate account sessionspost_session_terminate_managedsystemid(managed_system_id) - Terminate system sessionsget_keystrokes_by_session_id(session_id) - Get keystrokes for sessionsearch_keystrokes(data, type) - Search keystroke datacreate_replay_session(session_id, record_key, protocol, ...) - Create session replayget_replay_session(replay_id, jpeg_scale, png_scale, ...) - Get replay session datacontrol_replay_session(replay_id, speed, offset, ...) - Control replay playbackget_by_id(replay_id) - Get replay by ID (inherited)delete_by_id(replay_id) - Delete replay by ID (inherited)get_requests(status, queue) - List requests with filteringpost_request(system_id, account_id, duration_minutes, ...) - Create access requestpost_request_alias(alias_id, duration_minutes, access_type, ...) - Create alias requestput_request_checkin(request_id, reason) - Check in active requestput_request_approve(request_id, reason) - Approve pending requestput_request_deny(request_id, reason) - Deny pending requestput_request_rotate_on_checkin(request_id) - Set password rotation on checkinget_request_sets(status) - Get request sets by statuspost_request_sets(access_types, system_id, account_id, ...) - Create request setpost_request_termination_managed_account_id(managed_account_id, reason) - Terminate account requestspost_request_termination_managed_system_id(managed_system_id, reason) - Terminate system requestspost_request_termination_user_id(userid, reason) - Terminate user requestscreate_isa_request(system_id, account_id, duration_minutes, ...) - Create ISA access requestlist_assets_by_smart_rule_id(smart_rule_id, limit, offset) - List assets in smart rulecreate_filter_asset_attribute(attribute_ids, title, category, ...) - Create attribute filter rulelist_smart_rules_by_user_group_id(user_group_id) - List smart rules for user grouprun_smart_rule(smart_rule_id, queue) - Execute smart ruleget_by_org_and_title(organization_id, title) - Get quick rule by organization and titledelete_by_org_and_title(organization_id, title) - Delete quick rulecreate_quick_rule(ids, title, category, ...) - Create new quick ruleadd_accounts_to_quick_rule(quick_rule_id, account_ids) - Add accounts to quick ruleoauth() - Perform OAuth authenticationsign_app_in() - Sign into API with credentialsget_api_access() - Get API access tokensign_app_out() - Sign out of API sessionsend_post_sign_app_in() - Send sign-in POST requestvalidate_input(parameter_name, parameter_value) - Validate authentication parametersget_certificate() - Get certificate dataget_certificate_key() - Get certificate private keyset_certificate_data_from_pfx_file(certificate_path, certificate_password) - Load certificate from PFX fileget_certificate_and_certificate_key(certificate_path, certificate_password) - Get both certificate and keylist_by_entity_type(entity_type_id) - List platforms by entity typelist() - List all platforms (inherited)get_by_id(platform_id) - Get platform by ID (inherited)create_attribute_type(name) - Create new attribute typeget_attributes_by_attribute_type_id(attribute_type_id) - Get attributes by typepost_attribute_by_attribute_type_id(attribute_type_id, short_name, long_name, ...) - Create attributeget_attributes_by_managed_account_id(managed_account_id) - Get account attributesget_attributes_by_managed_system_id(managed_system_id) - Get system attributespost_attribute_by_managed_account_id(managed_account_id, attribute_id) - Assign attribute to accountpost_attribute_by_managed_system_id(managed_system_id, attribute_id) - Assign attribute to systemdelete_attributes_by_managed_account_id(managed_account_id) - Remove all account attributesdelete_attributes_by_managed_system_id(managed_system_id) - Remove all system attributesget_address_group_by_id(address_group_id) - Get address group by IDget_address_group_by_name(address_group_name) - Get address group by namecreate_address_group(name) - Create new address groupupdate_address_group(address_group_id, name) - Update address groupget_aliases(state) - Get aliases by state (active/inactive)get_managed_account_apps(account_id) - Get applications for managed accountassign_app_to_managed_account(account_id, application_id) - Assign application to accountremove_app_from_managed_account(account_id, application_id) - Remove application from accountunassign_all_apps_from_managed_account(account_id) - Remove all applications from accountget_key_by_id(api_registration_id) - Get API key by registration IDrotate_api_key(api_registration_id) - Rotate API keycreate_api_registration(name, registration_type, access_token_duration, ...) - Create API registrationupdate_api_registration(registration_id, name, registration_type, ...) - Update API registrationadd_epm_application() - Add EPM application policyget_managed_account_propagation_actions(managed_account_id) - Get propagation actions for accountpost_managed_account_propagation_action_by_id(managed_account_id, propagation_action_id, smart_rule_id) - Add propagation actiondelete_managed_account_propagation_action(managed_account_id) - Remove all propagation actionsdelete_managed_account_propagation_action_by_id(managed_account_id, propagation_action_id) - Remove specific actionget_organization_by_id(organization_id) - Get organization by IDlist_organizations() - List all organizationsget_organization_by_name(organization_name) - Find organization by nameget_workgroup_by_id(workgroup_id) - Get workgroup by IDget_workgroup_by_name(workgroup_name) - Get workgroup by nameget_workgroups() - List all workgroupspost_workgroup(name, organization_id) - Create new workgroupcreate_functional_account() - Create functional account for automationlist_entitlements(group_ids) - List entitlements for groupsdownload(request_id) - Download subscription delivery contentWe strongly recommend you to use a virtual environment and install dependences from requirements.txt file.
Import secrets_safe_library
pip install -r ~/requirements.txt
By default urllib3 logs are not shown, If need to show them:
export URLLIB3_PROPAGATE=True
script example using library:
import os
import logging
from secrets_safe_library import secrets_safe, authentication, utils, managed_account
import requests
from requests.adapters import HTTPAdapter
from urllib3.util.retry import Retry
env = os.environ
LOGGER_NAME = "custom_logger"
logging.basicConfig(format = '%(asctime)-5s %(name)-15s %(levelname)-8s %(message)s',
level = logging.DEBUG)
# logger object is optional but is strongly recommended
logger = logging.getLogger(LOGGER_NAME)
TIMEOUT_CONNECTION_SECONDS = 30
TIMEOUT_REQUEST_SECONDS = 30
CERTIFICATE = env['CERTIFICATE']
CERTIFICATE_KEY = env['CERTIFICATE_KEY']
def main():
try:
with requests.Session() as session:
retry_strategy = Retry(
total=3,
backoff_factor=0.2,
status_forcelist=[400, 408, 500, 502, 503, 504],
)
adapter = HTTPAdapter(max_retries=retry_strategy)
session.mount("https://", adapter)
session.mount("http://", adapter)
certificate, certificate_key = utils.prepare_certificate_info(CERTIFICATE, CERTIFICATE_KEY)
authentication_obj = authentication.Authentication(
req=session,
timeout_connection=TIMEOUT_CONNECTION_SECONDS,
timeout_request=TIMEOUT_REQUEST_SECONDS,
api_url="https://example.com:443/BeyondTrust/api/public/v3",
client_id="<client_id>",
client_secret="<client_secret>",
certificate=certificate,
certificate_key=certificate_key,
verify_ca=True,
logger=None
)
# sign app in password safe API
get_api_access_response = authentication_obj.get_api_access()
if get_api_access_response.status_code == 200:
# instantiate secrets safe object
secrets_safe_obj = secrets_safe.SecretsSafe(authentication_obj, logger)
get_secrets_response = secrets_safe_obj.get_secrets(["oagrp/text,oagrp/credential"])
utils.print_log(logger, f"=> Retrive secrets: {get_secrets_response}", logging.DEBUG)
else:
print(f"Please check credentials, error {get_api_access_response.text}")
authentication_obj.sign_app_out()
except Exception as e:
utils.print_log(logger, f"Error: {e}", logging.ERROR)
# calling main method
main()
FAQs
Password Safe API integration written in Python, Abstract complexity of managing secrets with the API.
We found that beyondtrust-bips-library demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
PyPI adds Trusted Publishing support for GitLab Self-Managed as adoption reaches 25% of uploads

Research
/Security News
A malicious Chrome extension posing as an Ethereum wallet steals seed phrases by encoding them into Sui transactions, enabling full wallet takeover.

Security News
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.