:lock: Vaultix
A very simple elixir client that authenticates, reads, writes, and deletes secrets from HashiCorp's Vault. As listed on Vault Libraries. Forked from https://github.com/findmypast/vaultex.
Installation
The package can be installed as:
-
Add vaultix to your list of dependencies in
mix.exs:
def deps do
[{:vaultix, "~> 0.8"}]
end- Ensure vaultix is started before your application:
def application do
[applications: [:vaultix]]
endConfiguration
You can configure your vault endpoint with a single environment variable:
VAULT_ADDR
Or a single application variable:
:vaultix, :vault_addr
An example value for VAULT_ADDR is http://127.0.0.1:8200.
Alternatively the vault endpoint can be specified with environment variables:
VAULT_HOSTVAULT_PORTVAULT_SCHEME
Or application variables:
:vaultix, :host:vaultix, :port:vaultix, :scheme
These default to localhost, 8200, http respectively.
You can skip SSL certificate verification with :vaultix, vault_ssl_verify: true option
or VAULT_SSL_VERIFY=true environment variable.
Usage
To read a secret you must provide the path to the secret and the authentication backend and credentials you will use to login. See the Vaultix.Client.auth/2 docs for supported auth backends.
...
iex> Vaultix.Client.auth(:app_id, {app_id, user_id})
iex> Vaultix.Client.auth(:userpass, {username, password})
iex> Vaultix.Client.auth(:ldap, {username, password})
iex> Vaultix.Client.auth(:github, {github_token})
iex> Vaultix.Client.auth(:approle, {role_id, secret_id})
iex> Vaultix.Client.auth(:token, {token})
iex> Vaultix.Client.auth(:kubernetes, %{jwt: "jwt", role: "role"})
iex> Vaultix.Client.auth(:radius, %{username: "user", password: "password"})
...
iex> Vaultix.Client.read "secret/bar", :github, {github_token} #returns {:ok, %{"value" => bar"}}
...
iex> Vaultix.Client.write "secret/foo", %{"value" => "bar"}, :app_id, {app_id, user_id}
Releasing
To release you need to bump the version and add some changes to the change log, you can do this with:
mix eliver.bump