secrets-safe-library-diego


Namesecrets-safe-library-diego JSON
Version 1.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-30 16:43:29
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": "secrets-safe-library-diego",
    "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/90/fd/c2deec464a8da5d843bf010f023579aeb17bb9e1f757ade1a6d68f0a7f7b/secrets_safe_library_diego-1.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": "1.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": "87a2ab1f218398a1a413dbd466a811e25d44908aa96322c18048c480e40520f9",
                "md5": "6f38470581066d4a21a04b8b8d506f2c",
                "sha256": "be394de0720fd01a085e7c71fd07390b5b7e4840982bc5548460ffc09c70578d"
            },
            "downloads": -1,
            "filename": "secrets_safe_library_diego-1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6f38470581066d4a21a04b8b8d506f2c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 15000,
            "upload_time": "2024-09-30T16:43:27",
            "upload_time_iso_8601": "2024-09-30T16:43:27.493794Z",
            "url": "https://files.pythonhosted.org/packages/87/a2/ab1f218398a1a413dbd466a811e25d44908aa96322c18048c480e40520f9/secrets_safe_library_diego-1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "90fdc2deec464a8da5d843bf010f023579aeb17bb9e1f757ade1a6d68f0a7f7b",
                "md5": "ed704b4109da27b3e5d90d507cc5e6fd",
                "sha256": "546e06ad8005d8b08dd5392c6536e18c66a2ac922878f9e99597b392b22195d4"
            },
            "downloads": -1,
            "filename": "secrets_safe_library_diego-1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "ed704b4109da27b3e5d90d507cc5e6fd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 12032,
            "upload_time": "2024-09-30T16:43:29",
            "upload_time_iso_8601": "2024-09-30T16:43:29.864035Z",
            "url": "https://files.pythonhosted.org/packages/90/fd/c2deec464a8da5d843bf010f023579aeb17bb9e1f757ade1a6d68f0a7f7b/secrets_safe_library_diego-1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-30 16:43:29",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "secrets-safe-library-diego"
}
        
Elapsed time: 2.00265s