Keyring backend reading password data from Bitwarden
This projects implement Keyring to be able to read secrets from Bitwarden, an open source multiplatform cloud/self-hostable password manager.
This backend assumes that it will be used in the context of a CLI application, and that it can communicate with the user using
stderr. We could implement an additional backend for use in a library assuming that everything is already unlocked, or another one using
pinentry to ask the user.
There's currently a solved bug in Twine that's keeping keyring and thus this lib from being used. If you plan to use this for Twine, either wait for a twine release or install from master:
pip install git+https://github.com/pypa/twine
This project uses the official bitwarden CLI under the hood, because there's no simple official Python bitwarden lib. Here are the installation instructions as of October 2018 and the link to the up to date instructions
You can install the Bitwarden CLI multiple different ways:
If you already have the Node.js runtime installed on your system, you can install the CLI using NPM. NPM makes it easy to keep your installation updated and should be the preferred installation method if you are already using Node.js.
npm install -g @bitwarden/cli
Natively packaged versions of the CLI are provided for each platform which have no requirements on installing the Node.js runtime. You can obtain these from the downloads section in the Bitwarden documentation.
Other Package Managers
choco install bitwarden-cli
brew install bitwarden-cli
sudo snap install bw
Installation and configuration
pip install bitwarden-keyring
The Python packaging ecosystem can be quite a mess.
Because of this, it's likely that your setup and my setup are nothing alike. Keyring supports a configuration file with an option allowing to explicitely define the path to a backend. You may need that for your installation, or maybe not.
Use as a normal keyring backend. It is installed with priority 10 so it's likely going to be selected first.
If you want to use it with twine, good news, you're already set. Just make sure that this package is installed in the same location as twine.
bitwarden-keyring will automatically ask for credentials when needed. If you don't want to unlock your vault every time, export the vault session to your environment (use
bw unlock and follow the instructions, or launch
export BW_SESSION=$(bw unlock --raw)).
bitwarden-keyring will try to select an appropriate credential based on the given service name, but as of now, it can't use the normal bitwarden url match mechanism. This is likely to change when bitwarden releases a new version of the CLI thanks to this issue.
In order to know if one needs to login or just unlock the vault,
bitwarden-keyring reads the internal datastore of
bitwarden-cli, so as any private API, it may change without notice.
bitwarden-keyring was only tested with:
- macOS, using the
- ubuntu, using the
bitwarden-keyring only works in the context of a CLI application with access to standard inputs and output. If you need something that either reads silently or using another method of communication, the best is probably to make another backend and most of the functions ca be reused.
bitwarden-keyring is published under the terms of the MIT License.
The name Bitwarden is most probably the property of 8bit Solutions LLC.
Contributions and Code of Conduct
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size bitwarden_keyring-0.2.1-py2.py3-none-any.whl (7.4 kB)||File type Wheel||Python version py2.py3||Upload date||Hashes View hashes|
|Filename, size bitwarden-keyring-0.2.1.tar.gz (6.1 kB)||File type Source||Python version None||Upload date||Hashes View hashes|
Hashes for bitwarden_keyring-0.2.1-py2.py3-none-any.whl