Skip to main content

Utilize 1Password vault data with Python decorators and context managers. Driven by the 1Password CLI interface. 🐍🔐

Project description

The Transformer

Passsssword

Utilize 1Password vault data with Python decorators and context managers. Driven by the 1Password CLI interface. 🐍🔐

ChecksAndTesting codecov Release pypi python version license pre-commit black mypy

Introduction

Passsssword is a Python-based utility designed to securely use your 1Password vault data right within your Python scripts. Utilizing Python decorators and context managers, the project interfaces with the 1Password CLI to automatically fetch and inject sensitive data, such as passwords or API-keys.

Passsssword offers two features:

  1. Decorator (decjector): Apply this decorator to any Python function to inject sensitive data automatically securely before its execution. The temporary .env file containing these variables is safely deleted after the function runs.

  2. Context Manager (contextor): This sets up a secure temporary environment for your code to run in, injecting the necessary passwords,etc. and ensuring their secure deletion afterward.

Setup

Requirements

  1. Python 3.8 - 3.11
  2. 1Password CLI

Installation Steps

  1. Clone the Repository:

    git clone https://github.com/chrislemke/passsssword.git
    
  2. Navigate to Project Directory:

    cd Passsssword
    
  3. Install Required Packages:

    pip install -r requirements.txt
    
  4. Set Up .env.op File: Create an .env.op file either in the project directory or one of its parent directories. This file will store the 1Password vault item paths, looking like this

     API_KEY = op://MyVault/MyItem/MyAPIKey
     ...
    
  5. Sign in to 1Password CLI: Make sure you've signed into your 1Password account through the CLI.

    op signin <your-domain>
    

Usage

Using the decjector Decorator

To auto-inject the API-key automatically into your Python function, simply apply the decjector decorator:

from Passsssword import decjector

@decjector
def sensitive_function():
    api_key = os.environ.get('API_KEY')
    # Your function logic here

sensitive_function()

The decjector decorator will securely fetch API_KEY from your 1Password vault and make it available within sensitive_function.

Using the contextor Context Manager

You can also use the contextor context manager in a with statement:

from Passsssword import contextor

with contextor():
    api_key = os.environ.get('API_KEY')
    # Your function logic here

Within the with block, any sensitive data from your 1Password vault specified in .env.op will be accessible as environment variables.

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

passsssword-0.1.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

passsssword-0.1.0-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file passsssword-0.1.0.tar.gz.

File metadata

  • Download URL: passsssword-0.1.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.12.0 Darwin/23.1.0

File hashes

Hashes for passsssword-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4f0e05ceceffcb4ce1216fab3b727ea0468bbf3db9e2128f73794c927e5b6be4
MD5 1afac52011642e06e4271f49bbcf12a9
BLAKE2b-256 a5951df98ce702bfad789cee172ab0ba3873d842c09aec1a49914b2ea050bfff

See more details on using hashes here.

File details

Details for the file passsssword-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: passsssword-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.12.0 Darwin/23.1.0

File hashes

Hashes for passsssword-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 02e28dd164bc95e328611f585525888a571aa3f30fd6b648852dcae975daa85d
MD5 bc31a5b724feac90ec2c6e0353ffe9bd
BLAKE2b-256 86ce5022868c07d1807fbbf8c133c93b50fd103291a105e284ddfc770671536c

See more details on using hashes here.

Supported by

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