SecretAgent đŸ•ĩī¸

Elixir CICoverage StatusHex DocsHex.pm VersionLicense

An Elixir library to manage secrets, with the possibily to watch for their changes on filesystem.

Thereafter, watched secrets are the secrets read from the filesystem, while in-memory secrets are secrets which do not have a corresponding file.

As per the recommandation of the EEF Security Workgroup, secrets are passed around as closures.

Installation

def deps do
  [
    {:secret_agent, "~> 0.8"}
  ]
end

Usage

  1. Establish the list of initial secrets:

     secrets =
       %{
         "credentials" => [value: "super-secret"],
         "secret.txt" => [
           directory: "path/to/secrets/directory",
           init_callback: fn wrapped_secret-> do_something_with_secret(wrapped_secret) end,
           callback: fn wrapped_secret-> do_something_with_secret(wrapped_secret) end
         ],
         "sub/path/secret.txt" => [
           directory: "path/to/secrets/directory"
         ]
       }

    â„šī¸ When using the :directory option, the name of the secret is the name of the file to watch in the directory. The secret will be loaded from the file upon startup. It this option is not set, the secret is considered to be an in-memory secret.

    â„šī¸ The :init_callback option specifies a callback that will be invoked the first time the watched secret is read from disk. Default to a function with no effect.

    â„šī¸ The :callback option specifies a callback that will be invoked each time the watched secret has been updated on disk. Default to a function with no effect.

    â„šī¸ The :value option specifies the initial value of the secret (default to nil for in-memory secrets). Supersed the value from the file if the :directory option has been set.

    👉 You can add in-memory secrets dynamically with SecretAgent.put_secret/3.