my-secrets-safe-library


Namemy-secrets-safe-library JSON
Version 2.0 PyPI version JSON
download
home_pageNone
SummaryPassword Safe API integration written in Python, Abstract complexity of managing secrets with the API.
upload_time2024-09-07 14:51:40
maintainerNone
docs_urlNone
authorBeyondTrust Corporation
requires_python>=3.11
licenseMIT License Copyright (c) 2023 BeyondTrust Corporation Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords beyondtrust devops secrets secretssafe security
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Password Safe API integration
[![License](https://img.shields.io/badge/license-MIT%20-brightgreen.svg)](LICENSE)

Password Safe API integration written in Python, Abstract complexity of managing secrets with the API

## Python version compatibility
  
This library is compatible with Python >= v3.11.

## Install Package

```sh
# PyPI
pip install secrets-safe-library
```
## Arguments

### Retrieve Secrets
- api_url:
    - description: BeyondTrust Password Safe API URL.
    - type: string
    - required: True
- client_id:
    - description: API OAuth Client ID.
    - type: string
    - required: True
- client_secret:
    - description: API OAuth Client Secret.
    - type: string
    - required: True
- secret_list:
    - description: List of secrets ["path/title","path/title"] or managed accounts ["ms/ma","ms/ma"] to be retrieved, separated by a comma.
    - type: list
    - required: True
- certificate_path:
    - description: Password Safe API pfx Certificate Path. For use when authenticating using a Client Certificate.
    - type: string
    - required: False
- certificate_password:
    - description: Password Safe API pfx Certificate Password. For use when authenticating using a Client Certificate.
    - type: string
    - required: False
- verify_ca:
    - description: Indicates whether to verify the certificate authority on the Secrets Safe instance.
    - type: boolean 
    - default: True
    - required: False

## Methods
- get_secrets(self, paths)
	- Invoked for Managed Account or Secrets Safe secrets.
	- Returns a list of secrets in the requested order.
- get_secret(self, path)
	- Invoked for Managed Account or Secrets Safe secrets.
	- Returns the requested secret.

## Example of usage

We strongly recommend you to use a virtual environment and install dependences from requirements.txt file.

Import `secrets_safe_library`

```sh
pip install -r ~/requirements.txt
```

script example using library:
```python
import  os
import  logging
from  secrets_safe_library  import  secrets_safe, authentication, utils, managed_account
import requests
from retry_requests 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:
            req = retry(session, retries=3, backoff_factor=0.2, status_to_retry=(400,408,500,502,503,504))
            
            certificate, certificate_key = utils.prepare_certificate_info(CERTIFICATE, CERTIFICATE_KEY)
            
            authentication_obj = authentication.Authentication(
                req,
                TIMEOUT_CONNECTION_SECONDS,
                TIMEOUT_REQUEST_SECONDS,
                "https://example.com:443/BeyondTrust/api/public/v3",
                "<client_id>",
                "<client_secret>",
                certificate,
                certificate_key,
                True,
                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()
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "my-secrets-safe-library",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": null,
    "keywords": "beyondtrust, devops, secrets, secretssafe, security",
    "author": "BeyondTrust Corporation",
    "author_email": "support@beyondtrust.com",
    "download_url": "https://files.pythonhosted.org/packages/31/44/5946b81530dd9ea141fc6b988fb7aebfa3ba58c2d68d3fb985ba345d3f9b/my_secrets_safe_library-2.0.tar.gz",
    "platform": null,
    "description": "# Password Safe API integration\n[![License](https://img.shields.io/badge/license-MIT%20-brightgreen.svg)](LICENSE)\n\nPassword Safe API integration written in Python, Abstract complexity of managing secrets with the API\n\n## Python version compatibility\n  \nThis library is compatible with Python >= v3.11.\n\n## Install Package\n\n```sh\n# PyPI\npip install secrets-safe-library\n```\n## Arguments\n\n### Retrieve Secrets\n- api_url:\n    - description: BeyondTrust Password Safe API URL.\n    - type: string\n    - required: True\n- client_id:\n    - description: API OAuth Client ID.\n    - type: string\n    - required: True\n- client_secret:\n    - description: API OAuth Client Secret.\n    - type: string\n    - required: True\n- secret_list:\n    - description: List of secrets [\"path/title\",\"path/title\"] or managed accounts [\"ms/ma\",\"ms/ma\"] to be retrieved, separated by a comma.\n    - type: list\n    - required: True\n- certificate_path:\n    - description: Password Safe API pfx Certificate Path. For use when authenticating using a Client Certificate.\n    - type: string\n    - required: False\n- certificate_password:\n    - description: Password Safe API pfx Certificate Password. For use when authenticating using a Client Certificate.\n    - type: string\n    - required: False\n- verify_ca:\n    - description: Indicates whether to verify the certificate authority on the Secrets Safe instance.\n    - type: boolean \n    - default: True\n    - required: False\n\n## Methods\n- get_secrets(self, paths)\n\t- Invoked for Managed Account or Secrets Safe secrets.\n\t- Returns a list of secrets in the requested order.\n- get_secret(self, path)\n\t- Invoked for Managed Account or Secrets Safe secrets.\n\t- Returns the requested secret.\n\n## Example of usage\n\nWe strongly recommend you to use a virtual environment and install dependences from requirements.txt file.\n\nImport `secrets_safe_library`\n\n```sh\npip install -r ~/requirements.txt\n```\n\nscript example using library:\n```python\nimport  os\nimport  logging\nfrom  secrets_safe_library  import  secrets_safe, authentication, utils, managed_account\nimport requests\nfrom retry_requests import retry\n\nenv  =  os.environ\nLOGGER_NAME  =  \"custom_logger\"\n\nlogging.basicConfig(format  =  '%(asctime)-5s  %(name)-15s  %(levelname)-8s  %(message)s',\n\nlevel  =  logging.DEBUG)\n\n# logger object is optional but is strongly recommended\nlogger  =  logging.getLogger(LOGGER_NAME)\n\nTIMEOUT_CONNECTION_SECONDS = 30\nTIMEOUT_REQUEST_SECONDS = 30\n\nCERTIFICATE = env['CERTIFICATE']\nCERTIFICATE_KEY = env['CERTIFICATE_KEY']\n\ndef  main():\n    try:\n        with requests.Session() as session:\n            req = retry(session, retries=3, backoff_factor=0.2, status_to_retry=(400,408,500,502,503,504))\n            \n            certificate, certificate_key = utils.prepare_certificate_info(CERTIFICATE, CERTIFICATE_KEY)\n            \n            authentication_obj = authentication.Authentication(\n                req,\n                TIMEOUT_CONNECTION_SECONDS,\n                TIMEOUT_REQUEST_SECONDS,\n                \"https://example.com:443/BeyondTrust/api/public/v3\",\n                \"<client_id>\",\n                \"<client_secret>\",\n                certificate,\n                certificate_key,\n                True,\n                None)\n\n            # sign app in password safe API\n            get_api_access_response  =  authentication_obj.get_api_access()\n\n            if  get_api_access_response.status_code ==  200:\n                # instantiate secrets safe object\n                secrets_safe_obj  =  secrets_safe.SecretsSafe(authentication_obj, logger)\n\n                get_secrets_response  =  secrets_safe_obj.get_secrets([\"oagrp/text,oagrp/credential\"])\n                utils.print_log(logger, f\"=> Retrive secrets: {get_secrets_response}\", logging.DEBUG)\n            else:\n                print(f\"Please check credentials, error {get_api_access_response.text}\")\n            \n            authentication_obj.sign_app_out()\n\n    except  Exception  as  e:\n        utils.print_log(logger, f\"Error: {e}\", logging.ERROR)\n\n# calling main method\nmain()\n```\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2023 BeyondTrust Corporation  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Password Safe API integration written in Python, Abstract complexity of managing secrets with the API.",
    "version": "2.0",
    "project_urls": {
        "support": "https://www.beyondtrust.com/docs/index.htm#support"
    },
    "split_keywords": [
        "beyondtrust",
        " devops",
        " secrets",
        " secretssafe",
        " security"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b55530bbcfb8fc4247ed62b8722e2d34925bd2a0946da38f5b9f2789ae75df14",
                "md5": "9505dca88662d5a6461685e093238f40",
                "sha256": "652135f49418672677c6e5ec6a547cd148ef81b2747f706f33007dfca6944a6b"
            },
            "downloads": -1,
            "filename": "my_secrets_safe_library-2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9505dca88662d5a6461685e093238f40",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 14466,
            "upload_time": "2024-09-07T14:51:38",
            "upload_time_iso_8601": "2024-09-07T14:51:38.667134Z",
            "url": "https://files.pythonhosted.org/packages/b5/55/30bbcfb8fc4247ed62b8722e2d34925bd2a0946da38f5b9f2789ae75df14/my_secrets_safe_library-2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "31445946b81530dd9ea141fc6b988fb7aebfa3ba58c2d68d3fb985ba345d3f9b",
                "md5": "08fe1fadd00596f1e17d2cabaaa24304",
                "sha256": "9db0aa3cbef1845b77c789d5d3d071a54255154d76056c0aef6b45db34694097"
            },
            "downloads": -1,
            "filename": "my_secrets_safe_library-2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "08fe1fadd00596f1e17d2cabaaa24304",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 9326,
            "upload_time": "2024-09-07T14:51:40",
            "upload_time_iso_8601": "2024-09-07T14:51:40.131367Z",
            "url": "https://files.pythonhosted.org/packages/31/44/5946b81530dd9ea141fc6b988fb7aebfa3ba58c2d68d3fb985ba345d3f9b/my_secrets_safe_library-2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-07 14:51:40",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "my-secrets-safe-library"
}
        
Elapsed time: 4.60930s