Skip to main content

1password support for xonsh

Project description

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

# 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 --build or twine

Credits

This package was created with xontrib template.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xontrib_1password-0.3.1.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xontrib_1password-0.3.1-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file xontrib_1password-0.3.1.tar.gz.

File metadata

  • Download URL: xontrib_1password-0.3.1.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for xontrib_1password-0.3.1.tar.gz
Algorithm Hash digest
SHA256 8bd9f65f0fc73aa8da013bbf3147e5da33bc14c00b6c97c41b80eb56cdbbfcb1
MD5 567bb0d4f16e332d06a8c0d3a654c416
BLAKE2b-256 fbf6621fd9c8f4d83644cbcda855842ad01e68c8c7c151ce32671dc522d0682b

See more details on using hashes here.

File details

Details for the file xontrib_1password-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for xontrib_1password-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 92e0b4402063d8a3662b5a7db1d6794ca8b97f3c3915e0ad4d8b7803da43f406
MD5 638a5a30fb38843d0194f6cf5b1d83de
BLAKE2b-256 ef2cb72b60dbe66d6a443238e7513ebfe315db085dcabb4ccb8fa3f27ea65a54

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page