Skip to content

A wrapper for the hvac module giving a simpler interface

License

Notifications You must be signed in to change notification settings

alexeyantropov/thvac

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

thvac

The Teensy Hvac is a wrapper for the hvac module giving a simpler interface. Thvac works only with token auth and kv2 secret engine.

How to use

import thvac

client = thvac.Client('https://vault:8200', 'token')

if not mount_create('mountpoint'):
    raise Exception('Oops')

client.secret_write('mountpoint', 'path/to', {'password': 'fish})

if client.secret_get('mountpoint', 'path/to')['password] == 'fish':
    client.secret_write('mountpoint', 'path/to', {'password': 'herring', 'fish': 'was here'})

Class Client(url, token)

Creates a new client.

Client.token_renew()

Renews the client token.

Return: bool.

Client.secret_get(mount_point, path)

Returns: dict() with the secret data. If smth is wrong it always returns an empty dict().

Client.secret_write(mount_point, path, secret)

Secret should be a dict().

Returns: bool. False only if an error has happended.

Client.mount_list()

Lists all mountpoints list.

Returns: set().

Client.mount_create(mount_point)

Creates a new kv2 mountpoint.

Returns: bool, it always is True if there isn't any error.

WTF?

I use hvac in my everyday work and the official client basically provides a lot of bricks for building youown local client for your tasks and evironment. And it's OK.

However I recon there is a little problem and I want to code a tiny client using hvac (not bare Vault API) with a simplier to use interface based on my expirience with Vault and hvac.

Developing and testing environment

All assets and docs for developing and testing in the 'develop' folder. It uses docker-compose, the Vault docker image, and the Python image.

It is runned and developed on python 3.9 but I sure that another python version aren't a problem.

About

A wrapper for the hvac module giving a simpler interface

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published