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.

varables:
  CI_JWT_ROLE: role_gitlab_ci

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 -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.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-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: vault_get-0.0.1.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.tar.gz
Algorithm Hash digest
SHA256 bf7ef23c4578475dcba25845b452f8a7f8a5d855f105d926964994b22e8e5e05
MD5 e1c8579e2eeaa17e9f5b3b614611c130
BLAKE2b-256 b5f21736bb0dff14cb5931f8be0b5d0e0d976977cf4239117a144612ba45d959

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vault_get-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.3

File hashes

Hashes for vault_get-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6feeb7c44d087dd20d5275146f5b6c78944b3f4bff244df9707e9d4bc132359b
MD5 08aaf9bf0724bafc108d3d0dc4bb455a
BLAKE2b-256 1f2b9f29432064b7440d3d4827d0469b6f63fd9a5ab23e412a69985b89b2647f

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