t-vault-manager


Namet-vault-manager JSON
Version 0.1.19 PyPI version JSON
download
home_pagehttps://www.thoughtful.ai/
SummaryPackage for seamless interaction with the Bitwarden.
upload_time2025-01-16 23:07:53
maintainerNone
docs_urlNone
authorThoughtful
requires_python>=3.9
licenseNone
keywords t_vault
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ======================
T-Vault
======================

Package for seamless interaction with the Bitwarden and others Password Managers.

--------------

Installation
------------

.. code:: bash

   pip install t-vault-manager

--------------

Usage
-----

Login to Bitwarden
------------------

.. code:: python

   from t_vault import bw_login, bw_login_from_env
   from RPA.Robocorp.Vault import Vault

   if Config.LOCAL_RUN:
       bw_login_from_env()
   else:
       bw_login(**Vault().get_secret("bitwarden_credentials"))

To use ``bw_login_from_env()`` you need the following environment
variables set:

-  ``BW_PASSWORD``
-  ``BW_CLIENTID``
-  ``BW_CLIENTSECRET``

To use if you do not have those env vars set, you can use ``bw_login``:

.. code:: python

   bw_login(client_id, client_secret, password, username)

Getting Vault Items:
--------------------

There is no need of adding ``CREDENTIALS`` variable to ``config.py``
anymore.

You can get the a Vault Item like this:

.. code:: python

   from t_vault import bw_get_item

   vault_item = bw_get_item(item_name)

The method will return a `T -
Object <https://www.notion.so/T-Object-1900a37f5cb74a1e9ca5158e5957e4e2?pvs=21>`__
with the vault item data. 


Getting Attachments
-------------------

There is two ways to get an attachment:

.. code:: python

   downloaded_path = bw_get_item(item_name).get_attachment(attachment_name, file_path)

.. code:: python

   downloaded_path = bw_get_attachment(item_name, attachment_name, file_path)

in both methods, ``file_path`` is optional. If it is not set, it will
download to the ``cwd`` .

Updating passwords
------------------

There is two ways to reset a password with the lib:

.. code:: python

   from t_vault import bw_update_password

   new_password = bw_update_password(item_name, new_password)

.. code:: python

   from t_vault import bw_get_item
   new_password = bw_get_item(item_name).update_password(new_passord)

The ``new_password`` argument is optional, and if is not passed, the
library will generate a strong password for you.

Those methods returns the newly created password.

===============
Troubleshooting
===============

If you are getting the following error:
``Failed to login: You are already logged in as...`` it is probably a
problem with the CLI executable. A potential fix to this is to force the
library to download the latest version of the CLI (currently, by
default, the library will use a stable version of the executable). To do
this you can add the ``force_latest=True`` argument to the login
methods:

.. code:: python

   bw_login(client_id="...", client_secret="...", password="...", force_latest=True)

or

.. code:: python

   bw_login_from_env(force_latest=True)

=====================================
Replacing old credentials dictionary:
=====================================

Use this if you just want to replace the old credentials dictionary that
is in most AIAs:

.. code:: python

   from t_vault import bw_login, bw_get_item

   bw_login(**Vault().get_secret("bitwarden_credentials"))
   credentials = {k: bw_get_item(v).to_dict() for k, v in collection.items()}

            

Raw data

            {
    "_id": null,
    "home_page": "https://www.thoughtful.ai/",
    "name": "t-vault-manager",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "t_vault",
    "author": "Thoughtful",
    "author_email": "support@thoughtful.ai",
    "download_url": "https://files.pythonhosted.org/packages/eb/c9/0119f7deb708c0e2a66f95df4db24e7267a6f638460f7f7f529406badd58/t_vault_manager-0.1.19.tar.gz",
    "platform": null,
    "description": "======================\nT-Vault\n======================\n\nPackage for seamless interaction with the Bitwarden and others Password Managers.\n\n--------------\n\nInstallation\n------------\n\n.. code:: bash\n\n   pip install t-vault-manager\n\n--------------\n\nUsage\n-----\n\nLogin to Bitwarden\n------------------\n\n.. code:: python\n\n   from t_vault import bw_login, bw_login_from_env\n   from RPA.Robocorp.Vault import Vault\n\n   if Config.LOCAL_RUN:\n       bw_login_from_env()\n   else:\n       bw_login(**Vault().get_secret(\"bitwarden_credentials\"))\n\nTo use ``bw_login_from_env()`` you need the following environment\nvariables set:\n\n-  ``BW_PASSWORD``\n-  ``BW_CLIENTID``\n-  ``BW_CLIENTSECRET``\n\nTo use if you do not have those env vars set, you can use ``bw_login``:\n\n.. code:: python\n\n   bw_login(client_id, client_secret, password, username)\n\nGetting Vault Items:\n--------------------\n\nThere is no need of adding ``CREDENTIALS`` variable to ``config.py``\nanymore.\n\nYou can get the a Vault Item like this:\n\n.. code:: python\n\n   from t_vault import bw_get_item\n\n   vault_item = bw_get_item(item_name)\n\nThe method will return a `T -\nObject <https://www.notion.so/T-Object-1900a37f5cb74a1e9ca5158e5957e4e2?pvs=21>`__\nwith the vault item data. \n\n\nGetting Attachments\n-------------------\n\nThere is two ways to get an attachment:\n\n.. code:: python\n\n   downloaded_path = bw_get_item(item_name).get_attachment(attachment_name, file_path)\n\n.. code:: python\n\n   downloaded_path = bw_get_attachment(item_name, attachment_name, file_path)\n\nin both methods, ``file_path`` is optional. If it is not set, it will\ndownload to the ``cwd`` .\n\nUpdating passwords\n------------------\n\nThere is two ways to reset a password with the lib:\n\n.. code:: python\n\n   from t_vault import bw_update_password\n\n   new_password = bw_update_password(item_name, new_password)\n\n.. code:: python\n\n   from t_vault import bw_get_item\n   new_password = bw_get_item(item_name).update_password(new_passord)\n\nThe ``new_password`` argument is optional, and if is not passed, the\nlibrary will generate a strong password for you.\n\nThose methods returns the newly created password.\n\n===============\nTroubleshooting\n===============\n\nIf you are getting the following error:\n``Failed to login: You are already logged in as...`` it is probably a\nproblem with the CLI executable. A potential fix to this is to force the\nlibrary to download the latest version of the CLI (currently, by\ndefault, the library will use a stable version of the executable). To do\nthis you can add the ``force_latest=True`` argument to the login\nmethods:\n\n.. code:: python\n\n   bw_login(client_id=\"...\", client_secret=\"...\", password=\"...\", force_latest=True)\n\nor\n\n.. code:: python\n\n   bw_login_from_env(force_latest=True)\n\n=====================================\nReplacing old credentials dictionary:\n=====================================\n\nUse this if you just want to replace the old credentials dictionary that\nis in most AIAs:\n\n.. code:: python\n\n   from t_vault import bw_login, bw_get_item\n\n   bw_login(**Vault().get_secret(\"bitwarden_credentials\"))\n   credentials = {k: bw_get_item(v).to_dict() for k, v in collection.items()}\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Package for seamless interaction with the Bitwarden.",
    "version": "0.1.19",
    "project_urls": {
        "Homepage": "https://www.thoughtful.ai/"
    },
    "split_keywords": [
        "t_vault"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ebc90119f7deb708c0e2a66f95df4db24e7267a6f638460f7f7f529406badd58",
                "md5": "a1056307dad7b5b03f665c1f2299f8fe",
                "sha256": "39c1c2611b070272b057e969ee2b65e476ae8873f67ecf5a2d628331a9660f75"
            },
            "downloads": -1,
            "filename": "t_vault_manager-0.1.19.tar.gz",
            "has_sig": false,
            "md5_digest": "a1056307dad7b5b03f665c1f2299f8fe",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 10937,
            "upload_time": "2025-01-16T23:07:53",
            "upload_time_iso_8601": "2025-01-16T23:07:53.278169Z",
            "url": "https://files.pythonhosted.org/packages/eb/c9/0119f7deb708c0e2a66f95df4db24e7267a6f638460f7f7f529406badd58/t_vault_manager-0.1.19.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-16 23:07:53",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "t-vault-manager"
}
        
Elapsed time: 0.86632s