Skip to content

mackenzie-3spread/bws-dotenv-gen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bws-dotenv-gen

CLI tool that generates a .env file using key-value pairs retrieved from Bitwarden Secrets

Notes

  • This utilizes the bws CLI instead of BWS SDK Language Python as it reduces dependencies and simplifies installation and usage.
  • Currently supports bws CLI v1.0.0
  • Tested on Apple Silicon and Debian Bookworm
  • This is a very basic tool, feel free to scrap it for parts and implement it directly into your project

Requirements

  • Python 3
  • Bash Environemtn (or alternative)
  • bws CLI v1.0.0 (in PATH)
  • bws Machine Account token

Installation and Setup

Download BWS CLI and add to path

  • Download .zip of bws CLI v1.0.0
  • Unzip the archive
    • unzip bws-macos-universal-1.0.0zip
  • Add bws to your PATH
    • cp -R bws /usr/local/bin

Clone bws-dotenv-gen

Create machine account

Create an access token

Add your Secrets

Usage

  • Enter downloaded bws-dotenv-gen directory
    • cd bws-dotenv-gen/src
  • Add keys to template.env (make sure the keys in this file match those in bws)
    • echo "PROXMOX_API_KEY=" >> template.env
    • echo "DEBIAN1_ROOT_PASSWORD=" >> template.env
    • echo "CHATGPT_API_KEY=" >> template.env
  • Run bws-dotenv-gen
    • python3 main.py
  • Enter your bws token at prompt
  • Check .env for the generated dotenv file
    • cat .env
    • PROXMOX_API_KEY=CCE2F4FD-AD40-4B6F-A5ED-C8549FF251CF
    • DEBIAN1_ROOT_PASSWORD=3spre4di$dA835t
    • CHATGPT_API_KEY=62A8117C-4A60-4E21-B51C-460BBF4C9107

Notes about how this works

  • bws_client grabs all secrets your machine account has access to and checks them against the keys in template.env
  • Currently this reads a template.env from ../src and puts the .env in ../.env
    • You will very likely want to adjust the directories used to match your needs
  • The script will error out if no template.env is found, but will not error out if not all keys in template.env are found in bws, the unfound keys will be left blank in the .env

About

CLI tool that generates a .env file using key-value pairs retrieved from Bitwarden Secrets

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages