Skip to main content

Python hvac cli wrapper: get kv from hashicorp vault by auth token or jwt.

Project description

vault-get

Python hvac cli wrapper: get kv from hashicorp vault by auth token or jwt.

Why

This tool helps when you don't have access to vanilla hashicorp vault binary and need only to retrieve kv from vault.

Usage

vault-get can be used to print kv secrets via token or jwt auth to stdout.

vault auth token

export VAULT_TOKEN=xxx
export VAULT_ADDRESS=https://vault.local

vault-get -a $VAULT_ADDRESS -m MyMountPoint -p my_secret_path -k my_secret_key
topsecret

jwt gitlab-ci

Check your vault authentication method to know auth path.

vault read auth/jwt-1
varables:
  CI_JWT_ROLE: role_gitlab_ci
  VAULT_JWT_PATH: jwt-1

job01:
  stage: test
  id_tokens:
    VAULT_ID_TOKEN:
      aud: $VAULT_ADDR
  before_script:
    - export MY_VALUE="$(vault-get -a $VAULT_ADDR -j $VAULT_ID_TOKEN -ap $VAULT_JWT_PATH -r $CI_JWT_ROLE -m MyMountPoint -p my_secret_path -k my_secret_key)"
  script:
    - echo $MY_VALUE

cli help

vault-get --help
usage: vault-get [-h] [-v] [-a VAULT_ADDRESS] [-ap AUTH_PATH] [-r JWT_AUTH_ROLE] [-j JWT] -m MOUNT_POINT -p SECRET_PATH -k SECRET_KEY

Vault get secret. Simple hvac wrapper used to pull from hvault. Print kv-secret from vault to stdout.

options:
  -h, --help            show this help message and exit
  -v, --verbose         Set logging level to DEBUG. Warning: secrets will be revealed.

Vault:
  If jwt-auth-role and jwt are not set uses $VAULT_TOKEN env variable for auth.

  -a VAULT_ADDRESS, --vault-address VAULT_ADDRESS
                        Vault address. Example "https://vault.local". Default="https://127.0.0.1"
  -ap AUTH_PATH, --auth-path AUTH_PATH
                        Vault auth method auth path. Example "jwt-test". Default="jwt"
  -r JWT_AUTH_ROLE, --jwt-auth-role JWT_AUTH_ROLE
                        Auth role for jwt auth. Used in pair with --jwt.
  -j JWT, --jwt JWT     JWT for jwt auth. Used in pair with --jwt-auth-role.

Get secret by path and key:
  Printout secret value by mount-point, secret-path and secret-key.

  -m MOUNT_POINT, --mount-point MOUNT_POINT
                        Vault mount point. Example "MyMountPoint".
  -p SECRET_PATH, --secret-path SECRET_PATH
                        Vault secret path. Example "my_super_secret"
  -k SECRET_KEY, --secret-key SECRET_KEY
                        Vault secret key. Example "access_token"

Usage 
vault-get -m MyMountPoint -p my_secret_path -k my_secret_key

Examples:
    Use $VAULT_ADDR and $VAULT_TOKEN to access vault and auth:
        vault-get -m MyMountPoint -p my_secret_path -k my_secret_key
    Use JWT auth method in gitlab-ci job:
        vault-get -a https://vault.local -j $CI_JOB_JWT -r role_gitlab_ci -m MyMountPoint -p my_secret_path -k my_secret_key

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

vault_get-0.0.1.post1.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

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

vault_get-0.0.1.post1-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file vault_get-0.0.1.post1.tar.gz.

File metadata

  • Download URL: vault_get-0.0.1.post1.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.3

File hashes

Hashes for vault_get-0.0.1.post1.tar.gz
Algorithm Hash digest
SHA256 5927545f44f83f3a77e511dc0d2ad42c7e7a6e51e36646445edff085c8995053
MD5 95b3a2296d95e9e42c94c894076c5aa0
BLAKE2b-256 d6aab9df107cdaf0970d860327efe4d0c0f6afa90ad0c3779e66fd8db2331d3d

See more details on using hashes here.

File details

Details for the file vault_get-0.0.1.post1-py3-none-any.whl.

File metadata

File hashes

Hashes for vault_get-0.0.1.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 ec696400e8205972a7fe4ad7954fba5d2d8404af58580a87a94974084185ce50
MD5 3ce3c92ced83cb492e06a4f171b5854f
BLAKE2b-256 789a7a5835765dd609f8934525108d4a9bb803f3046ded32350e36e231d77029

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