{ "info": { "author": "Sanhe Hu", "author_email": "husanhe@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Operating System :: MacOS", "Operating System :: Microsoft :: Windows", "Operating System :: Unix", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6" ], "description": ".. image:: https://readthedocs.org/projects/pysecret/badge/?version=latest\n :target: https://pysecret.readthedocs.io/index.html\n :alt: Documentation Status\n\n.. image:: https://travis-ci.org/MacHu-GWU/pysecret-project.svg?branch=master\n :target: https://travis-ci.org/MacHu-GWU/pysecret-project?branch=master\n\n.. image:: https://codecov.io/gh/MacHu-GWU/pysecret-project/branch/master/graph/badge.svg\n :target: https://codecov.io/gh/MacHu-GWU/pysecret-project\n\n.. image:: https://img.shields.io/pypi/v/pysecret.svg\n :target: https://pypi.python.org/pypi/pysecret\n\n.. image:: https://img.shields.io/pypi/l/pysecret.svg\n :target: https://pypi.python.org/pypi/pysecret\n\n.. image:: https://img.shields.io/pypi/pyversions/pysecret.svg\n :target: https://pypi.python.org/pypi/pysecret\n\n.. image:: https://img.shields.io/badge/STAR_Me_on_GitHub!--None.svg?style=social\n :target: https://github.com/MacHu-GWU/pysecret-project\n\n------\n\n\n.. image:: https://img.shields.io/badge/Link-Document-blue.svg\n :target: https://pysecret.readthedocs.io/index.html\n\n.. image:: https://img.shields.io/badge/Link-API-blue.svg\n :target: https://pysecret.readthedocs.io/py-modindex.html\n\n.. image:: https://img.shields.io/badge/Link-Source_Code-blue.svg\n :target: https://pysecret.readthedocs.io/py-modindex.html\n\n.. image:: https://img.shields.io/badge/Link-Install-blue.svg\n :target: `install`_\n\n.. image:: https://img.shields.io/badge/Link-GitHub-blue.svg\n :target: https://github.com/MacHu-GWU/pysecret-project\n\n.. image:: https://img.shields.io/badge/Link-Submit_Issue-blue.svg\n :target: https://github.com/MacHu-GWU/pysecret-project/issues\n\n.. image:: https://img.shields.io/badge/Link-Request_Feature-blue.svg\n :target: https://github.com/MacHu-GWU/pysecret-project/issues\n\n.. image:: https://img.shields.io/badge/Link-Download-blue.svg\n :target: https://pypi.org/pypi/pysecret#files\n\n\nWelcome to ``pysecret`` Documentation\n==============================================================================\n\n.. contents::\n :local:\n\n``pysecret`` is a library to ease your life dealing with secret information.\n\nFor example, **if you have a database connection information, so you can't include it in your source code, but you want to easily and securely access it**, then ``pysecret`` is the library for you. It provides several options out of the box:\n\n**Features**:\n\n1. access secret in environment variable from commandline, shell scripts, or Python.\n2. access secret in json file from Python.\n3. use AWS Key Management Service or AWS Secret Manager to access your secret info.\n\nFor large file or binary data encryption, I highly recommend you to use AWS Key Management Service and AWS Secret Manager to fetch your encryption key, then use `windtalker `_ library to encrypt it.\n\n\n\nLoad Data From Environment\n------------------------------------------------------------------------------\n\nThe idea is: put your secret information in ``~/.bashrc_pysecret`` file.\n\n.. code-block:: bash\n\n # content of ~/.bashrc_pysecret file\n export DB_SECRET_MY_DB_PASSWORD=\"mypassword\"\n ...\n\nAnd put ``source ~/.bashrc_pysecret`` into your ``~/.bashrc`` / ``~/.bash_profile`` / ``.zshrc`` ...\n\n**Whenever you need your secret info**:\n\n1. Your interactive command line interface gives you easy access to those secrets.\n2. You can put ``source ~/.bashrc_pysecret`` in your CI / CD scripts.\n3. pysecret allows you to load secret value in python code. By doing this:\n\n.. code-block:: python\n\n >>> from pysecret import EnvSecret\n >>> env = EnvSecret()\n >>> env.load_pysecret_script()\n >>> env.get(\"DB_SECRET_MY_DB_PASSWORD\")\n mypassword\n\n**You can write your secret to** ``~/.bashrc_pysecret`` **file in a pythonic way**:\n\n.. code-block:: python\n\n from pysecret import EnvSecret\n\n env = EnvSecret()\n\n # will create ~/.bashrc_pysecret file if not exists\n # will update ~/.bashrc_pysecret file too\n # if you don't want to update ~/.bashrc_pysecret file, just set .set(..., temp=True)\n env.set(\"DB_SECRET_MYDB_HOST\", \"123.456.789.000\")\n env.set(\"DB_SECRET_MYDB_USERNAME\", \"username\")\n env.set(\"DB_SECRET_MYDB_PASSWORD\", \"password\")\n\n\nLoad Data From Json File\n------------------------------------------------------------------------------\n\nThe idea is, put your secret info in a json file and load info from it. You can create it manually by your own, or do it in pythonic way:\n\n.. code-block:: python\n\n from pysecret import JsonSecret, get_home_path\n\n SECRET_FILE = get_home_path(\".pysecret.json\")\n js = JsonSecret.new(secret_file=SECRET_FILE)\n\n # construct / update secret json file\n js.set(\"mydb.host\": \"123.456.789.000\")\n js.set(\"mydb.username\": \"username\")\n js.set(\"mydb.password\": \"password\")\n\nor you can just create ``$HOME/.pysecret.json`` includes:\n\n.. code-block:: python\n\n {\n \"mydb\": {\n \"host\": \"123.456.789.000\",\n \"username\": \"username\",\n \"password\": \"password\n }\n }\n\n**Load secret safely**:\n\n.. code-block:: python\n\n host = js.get(\"mydb.host\")\n username = js.get(\"mydb.username\")\n password = js.get(\"mydb.password\")\n\n\nAWS Key Management Service and Secret Manager Integration\n------------------------------------------------------------------------------\n\n**Encrypt your secret and Read secret value using AWS Secret Manager with ``pysecret`` is super easy**.\n\nFirst, let's create a aws secret:\n\n.. code-block:: python\n\n from pysecret import AWSSecret\n\n aws_profile = \"my_aws_profile\"\n aws = AWSSecret(profile_name=aws_profile)\n\n secret_id = \"my-example-secret\"\n secret_data = dict(\n host=\"www.example.com\",\n port=1234,\n database=\"mydatabase\",\n username=\"admin\",\n password=\"mypassword\",\n metadata=dict(\n creator=\"Alice\",\n )\n )\n aws.deploy_secret(name=secret_id, secret_data=secret_data)\n\nNow open your AWS Console https://console.aws.amazon.com/secretsmanager/home?region=us-east-1#/secret?name=my-example-secret (Replace us-east-1 to your region), you should be able to see the new AWS Secret has been created.\n\nNow let's retrive the secret value\n\n.. code-block:: python\n\n >>> aws.get_secret_value(secret_id=\"my-example-secret\", key=\"password\")\n mypassword\n >>> aws.get_secret_value(secret_id=\"my-example-secret\", key=\"metadata.creator\")\n Alice\n\n**Use KMS Key to encrypt and decrypt text is easy**\n\n.. code-block:: python\n\n >>> from pysecret import AWSSecret\n >>> aws_profile = \"my_aws_profile\"\n >>> kms_key_id = \"abcd1234-ab12-ab12-ab12-abcd1234abcd\"\n\n >>> aws = AWSSecret(profile_name=aws_profile)\n >>> secret = \"Hello World\"\n >>> encrypted_text = aws.kms_encrypt(kms_key_id, secret)\n >>> decrypted_text = aws.kms_decrypt(encrypted_text)\n >>> assert secret != encrypted_text\n True\n >>> assert secret == decrypted_text\n True\n\n\n.. _install:\n\nInstall\n------------------------------------------------------------------------------\n\n``pysecret`` is released on PyPI, so all you need is:\n\n.. code-block:: console\n\n $ pip install pysecret\n\nTo upgrade to latest version:\n\n.. code-block:: console\n\n $ pip install --upgrade pysecret\n\n", "description_content_type": "", "docs_url": null, "download_url": "https://pypi.python.org/pypi/pysecret/0.0.4#downloads", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/MacHu-GWU/", "keywords": "", "license": "MIT", "maintainer": "Unknown", "maintainer_email": "", "name": "pysecret", "package_url": "https://pypi.org/project/pysecret/", "platform": "Windows", "project_url": "https://pypi.org/project/pysecret/", "project_urls": { "Download": "https://pypi.python.org/pypi/pysecret/0.0.4#downloads", "Homepage": "https://github.com/MacHu-GWU/" }, "release_url": "https://pypi.org/project/pysecret/0.0.4/", "requires_dist": [ "click", "superjson (>=0.0.13)", "sphinx (==1.8.1) ; extra == 'docs'", "sphinx-rtd-theme ; extra == 'docs'", "sphinx-jinja ; extra == 'docs'", "sphinx-copybutton ; extra == 'docs'", "docfly (>=0.0.17) ; extra == 'docs'", "rstobj (>=0.0.5) ; extra == 'docs'", "pygments ; extra == 'docs'", "pytest (==3.2.3) ; extra == 'tests'", "pytest-cov (==2.5.1) ; extra == 'tests'" ], "requires_python": "", "summary": "utility tool that load secret information safely.", "version": "0.0.4" }, "last_serial": 5960999, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "5a744dea1018f8ce201bbc3c00fdad3c", "sha256": "b436a9cdb6bf76c766f2fa549b21e8eb5b82ade7ddc35e238e4b5fbc07024d1b" }, "downloads": -1, "filename": "pysecret-0.0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "5a744dea1018f8ce201bbc3c00fdad3c", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 5690, "upload_time": "2019-04-09T15:11:05", "url": "https://files.pythonhosted.org/packages/d9/0d/ef653d6efa242849415289a2405f17a826e180a66b379fa590e8b68e941a/pysecret-0.0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9781477b2ff6358c6bbe1cfeb563300e", "sha256": "4ae80d854ebd93d5527f00649f80f36d9c7d86a09496e174dbf5afabb1e90aa3" }, "downloads": -1, "filename": "pysecret-0.0.1.tar.gz", "has_sig": false, "md5_digest": "9781477b2ff6358c6bbe1cfeb563300e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6652, "upload_time": "2019-04-09T15:11:08", "url": "https://files.pythonhosted.org/packages/18/d2/1e17f9896a853e91e799fcd8e3e4ca72f79f38c9a9ac51882e92af97f9f5/pysecret-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "29aa9a6cec56ef245717c48bc3a5d18b", "sha256": "a60dbd7ff7dc69eafde42a8a59b458e4963e8c22f222af6fd13fc9d07603a909" }, "downloads": -1, "filename": "pysecret-0.0.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "29aa9a6cec56ef245717c48bc3a5d18b", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 52911, "upload_time": "2019-04-11T03:41:32", "url": "https://files.pythonhosted.org/packages/ad/05/71bf825a06d71c8f4155491f0d824d1ae4916da4435478e6f9a696a191e5/pysecret-0.0.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "abe19293da6ef88784983edc5a10fb05", "sha256": "2deb6845ac727be6e21df10d6eb136c67380701ffda8a2981c237c2376081e8d" }, "downloads": -1, "filename": "pysecret-0.0.2.tar.gz", "has_sig": false, "md5_digest": "abe19293da6ef88784983edc5a10fb05", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 28929, "upload_time": "2019-04-11T03:41:33", "url": "https://files.pythonhosted.org/packages/96/5f/af1c293245108291067e29154e043e49c5af0afa9d23ffbc53e33d9f502f/pysecret-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "8e210b19190eacca888bc2dae8cc25ae", "sha256": "4c3a4e7aa950e6bcdad8a277d0f3c907d17b95423c744b25d4bdcf53cbf55e4e" }, "downloads": -1, "filename": "pysecret-0.0.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "8e210b19190eacca888bc2dae8cc25ae", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 53210, "upload_time": "2019-05-09T18:54:24", "url": "https://files.pythonhosted.org/packages/cd/9f/8a79d77ff971d7a93b19b4749470d18ccfd48d32b5796ed20600aa5309f9/pysecret-0.0.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d11e5f6c87310b7768bab77125fb572c", "sha256": "eb2e4abfcbeafbb7407f6f7e41c01c0cfb348114d09b63e6c39c2b3608f3483f" }, "downloads": -1, "filename": "pysecret-0.0.3.tar.gz", "has_sig": false, "md5_digest": "d11e5f6c87310b7768bab77125fb572c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 29303, "upload_time": "2019-05-09T18:54:26", "url": "https://files.pythonhosted.org/packages/a3/27/4b4730701753703ffa2192dbf773615d9c35b990cf5dc3fa3dde951238fd/pysecret-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "2dabdb17effd7eef64dde0b12a21695c", "sha256": "9e52e2e5ee8ead27e732a5f9d8d5cdb8be6acdc3bebacd23432a6eeff7e2bc14" }, "downloads": -1, "filename": "pysecret-0.0.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "2dabdb17effd7eef64dde0b12a21695c", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 54697, "upload_time": "2019-10-11T16:03:37", "url": "https://files.pythonhosted.org/packages/03/2b/bc2f0b418bd781d8bccbd10989834dad601461e12f726442fbf8ff7f66db/pysecret-0.0.4-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "45005c37f00f71e9cd5279e2eb8ac5e1", "sha256": "2de76d8a934a18ccb1edf9acfa6705cf773bd132c1a77c8d217d110ed8de12bf" }, "downloads": -1, "filename": "pysecret-0.0.4.tar.gz", "has_sig": false, "md5_digest": "45005c37f00f71e9cd5279e2eb8ac5e1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 31316, "upload_time": "2019-10-11T16:03:41", "url": "https://files.pythonhosted.org/packages/e5/5e/7a3c5dad4f68e4d76f11707a95f8d87248061e01f1c100dcbfd28cf28185/pysecret-0.0.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "2dabdb17effd7eef64dde0b12a21695c", "sha256": "9e52e2e5ee8ead27e732a5f9d8d5cdb8be6acdc3bebacd23432a6eeff7e2bc14" }, "downloads": -1, "filename": "pysecret-0.0.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "2dabdb17effd7eef64dde0b12a21695c", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 54697, "upload_time": "2019-10-11T16:03:37", "url": "https://files.pythonhosted.org/packages/03/2b/bc2f0b418bd781d8bccbd10989834dad601461e12f726442fbf8ff7f66db/pysecret-0.0.4-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "45005c37f00f71e9cd5279e2eb8ac5e1", "sha256": "2de76d8a934a18ccb1edf9acfa6705cf773bd132c1a77c8d217d110ed8de12bf" }, "downloads": -1, "filename": "pysecret-0.0.4.tar.gz", "has_sig": false, "md5_digest": "45005c37f00f71e9cd5279e2eb8ac5e1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 31316, "upload_time": "2019-10-11T16:03:41", "url": "https://files.pythonhosted.org/packages/e5/5e/7a3c5dad4f68e4d76f11707a95f8d87248061e01f1c100dcbfd28cf28185/pysecret-0.0.4.tar.gz" } ] }