vaultex v0.2.1 Vaultex.Client
Provides a functionality to authenticate and read from a vault endpoint.
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
Functions
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
:app_id, :userpass, :github
- credentials: A tuple used for authentication depending on the method,
{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}
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"}}