keyring backend plugin to retrieve credentials from environment variables.
Project description
keyrings.envvars is a keyring backend plugin for the keyring utility that provides credentials via environment variables.
Requirements
keyring >= 23.4.0
Python >= 3.9
Installation
You can install keyrings.envvars via pip from PyPI:
$ pip install keyrings.envvars
Usage
keyrings.envvars uses the following format for environment variables:
KEYRING_SERVICE_NAME_<n>=<service>
KEYRING_SERVICE_USERNAME_<n>=<username>
KEYRING_SERVICE_PASSWORD_<n>=<password>
Example for usage with pip credentials:
KEYRING_SERVICE_NAME_0=private-pypi-index.example.com
KEYRING_SERVICE_USERNAME_0=testusername
KEYRING_SERVICE_PASSWORD_0=testpassword
KEYRING_SERVICE_NAME_1=another-private-pypi-index.example.com
KEYRING_SERVICE_USERNAME_1=testusername
KEYRING_SERVICE_PASSWORD_1=testpassword
This can be used along with a requirements.txt containing appropriate --extra-index-url flags to avoid storing credentials in plain-text:
--extra-index-url https://private-pypi-index.example.com/simple
private-package==1.2.3
Note: Defining multiple identical credentials (service name and username) will result in the last defined password being returned as the environment variables are sorted by the keyring backend.
export KEYRING_SERVICE_NAME_0=https://private-pypi-index.example.com
export KEYRING_SERVICE_USERNAME_0=testusername
export KEYRING_SERVICE_PASSWORD_0=testpassword
export KEYRING_SERVICE_NAME_1=https://private-pypi-index.example.com
export KEYRING_SERVICE_USERNAME_1=testusername
export KEYRING_SERVICE_PASSWORD_1=testpassword_1
keyring get https://private-pypi-index.example.com testusername
testpassword_1
If there are multiple credentials defined for a service and no username is given when searching then None will be returned. For example, given the definitions above:
>>> import keyring
>>> cred = keyring.get_credential('https://private-pypi-index.example.com', None)
>>> print(cred)
None
Contributing
Contributions including suggestions, pull requests, etc. are very welcome. keyrings.envvars uses Conventional Commits format for commit messages.
Run nox before committing any changes.
License
Distributed under the terms of the MIT license, keyrings.envvars is free and open source software.
Issues
If you encounter any problems, please file an issue along with a detailed description.
Please read https://www.chiark.greenend.org.uk/~sgtatham/bugs.html before you file an issue.
Credits
This project was generated from @cjolowicz’s Hypermodern Python Cookiecutter template.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file keyrings_envvars-1.1.0.tar.gz
.
File metadata
- Download URL: keyrings_envvars-1.1.0.tar.gz
- Upload date:
- Size: 9.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 14e3522bec667f2b85aaa73731ebe062adcf0a72720f411427746f3863572b5e |
|
MD5 | 944ead7611721d301ce7d68072e58411 |
|
BLAKE2b-256 | 5a1255a300f3b8d86461809491415bba1483f7ca8ed578b84bb0b1774ef5b0a4 |
File details
Details for the file keyrings_envvars-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: keyrings_envvars-1.1.0-py3-none-any.whl
- Upload date:
- Size: 9.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17c934543cf3a0d8beba93042eeb130c411d10111d24949c0828bc2bfb193452 |
|
MD5 | ef88148263eeb8674aa4c0678806b88f |
|
BLAKE2b-256 | 2e72af2af759b5288a6edb62f5be8d465884638920e1d7e23ef9081de1b9dbd3 |