1password support for xonsh shell. This approach ensures your sensitive information remains secure while being easily accessible in your xonsh shell.
If you like the idea click ⭐ on the repo and tweet.
Installation
To install use pip:
xpip install xontrib-1password
# or: xpip install -U git+https://github.com/drmikecrowe/xontrib-1password
The xontrib will get loaded automatically.
Usage
For maximum security, enable your secrets dynamically using the command below when required. You may also enable permanently and expose your secrets at all times in your Run Control (RC) file:
$XONTRIB_1PASSWORD_ENABLED = True
Store your passwords in 1Password and setup op CLI locally.
Then:
mykey = OnePass("op://path/my/key")
echo @(mykey)
# my-key-value
$MYKEY = OnePass("op://path/my/key")
echo $MYKEY
# my-key-value
env | grep MYKEY
# MYKEY=my-key-value
Good to know
Disabling
To disable autoloading:
$XONTRIBS_AUTOLOAD_DISABLED = ["1password", ]
To turn off:
$XONTRIB_1PASSWORD_ENABLED = False
$MYKEY = OnePass("op://path/my/key")
$MYKEY
# op://path/my/key
Get certain key
Because of the URL is basically op://<Vault>/<title>/<field> to find this, here's the commands you can use to determine these fields:
op item list --format json | jq '.[].title | select(. | contains("OpenAI"))'
# "OpenAI-API-Key"
op item get OpenAI-API-Key --format json | jq '.fields[] | select(.type == "CONCEALED") | .label'
# "api-key"
Debug mode
$XONTRIB_1PASSWORD_DEBUG = True
Cache
You can set $XONTRIB_1PASSWORD_CACHE to string:
not_empty(default) - cache not empty values.all- cache all values.off- disable caching.
Known issues
Slowing down reading environment variables
If you disable cache (i.e. $XONTRIB_1PASSWORD_CACHE='off') in case of $MYVAR = OnePass(...) every time the shell read the env variables list the value will be requested from OnePassword and it takes time.
Development
- activate pre-commit hooks
# install pre-commit plugins and activate the commit hook
pre-commit install
pre-commit autoupdate
Releasing your package
- Bump the version of your package.
- Create a GitHub release (The release notes are automatically generated as a draft release after each push).
- And publish with
poetry publish --buildortwine
Credits
This package was created with xontrib template.
Metadata
Release files for xontrib-1password 0.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| xontrib_1password-0.3.2.tar.gz | 4.7 kB | Without provenance | Details for xontrib_1password-0.3.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| xontrib_1password-0.3.2-py3-none-any.whl | Python 3 | none | any | Details for xontrib_1password-0.3.2-py3-none-any.whl |
Total release size: 10.4 kB
Release files / xontrib_1password-0.3.2.tar.gz
| Download URL | xontrib_1password-0.3.2.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fc171689c014a946a0a5bee10bd7fbb16882b256c120c111f83e9f2fd6aed9f7
|
|
BLAKE2b-256 checksum How to use checksums |
dfee6308a9474c0f391ce2b2f1c22c9b0c4bb9f10e80a11ad6b9c54177ebc93a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.23
|
Release files / xontrib_1password-0.3.2-py3-none-any.whl
| Download URL | xontrib_1password-0.3.2-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
51e84b7ae070a7c02d4d612b5c4ad563ada1e3e5c5eb820fb87b4fc40eb2bb8c
|
|
BLAKE2b-256 checksum How to use checksums |
f25dbe1fdc0e86c7ba5dc9db3ef04c0fcece2f4970ec5c47f110f851c145b89e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.23
|
Security for xontrib-1password 0.3.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.