vaultex v0.4.0 Vaultex.Client
Provides a functionality to authenticate and read from a vault endpoint.
Link to this section Summary
Functions
Authenticates with vault using a tuple. This can be executed before attempting to read secrets from vault
Reads a secret from vault given a path
Writes a secret to Vault given a path
Link to this section Functions
Link to this function
auth(method, credentials)
Authenticates with vault using a tuple. This can be executed before attempting to read secrets from vault.
Parameters
- method: Auth backend to use for authenticating, can be one of
:approle, :app_id, :userpass, :github
- credentials: A tuple used for authentication depending on the method,
{role_id, secret_id}
for :approle,{app_id, user_id}
for:app_id
,{username, password}
for:userpass
,{github_token}
for:github
Examples
iex> Vaultex.Client.auth(:app_id, {app_id, user_id})
{:ok, :authenticated}
iex> Vaultex.Client.auth(:userpass, {username, password})
{:error, ["Something didn't work"]}
iex> Vaultex.Client.auth(:github, {github_token})
{:ok, :authenticated}
Link to this function
read(key, auth_method, credentials)
Reads a secret from vault given a path.
Parameters
- key: A String path to be used for querying vault.
- auth_method and credentials: See Vaultex.Client.auth
Examples
iex> Vaultex.Client.read "secret/foo", :app_id, {app_id, user_id}
{:ok, %{"value" => "bar"}}
iex> Vaultex.Client.read "secret/baz", :userpass, {username, password}
{:error, ["Key not found"]}
iex> Vaultex.Client.read "secret/bar", :github, {github_token}
{:ok, %{"value" => "bar"}}
Link to this function
start_link()
Link to this function
write(key, value, auth_method, credentials)
Writes a secret to Vault given a path.
Parameters
- key: A String path where the secret will be written.
- value: A String => String map that will be stored in Vault
- auth_method and credentials: See Vaultex.Client.auth
Examples
iex> Vaultex.Client.write "secret/foo", %{"value" => "bar"}, :app_id, {app_id, user_id}
:ok