v1.8.0CLILatest
•2 min read

The CLI keeps your login and vault keys in the OS credential store

The CLI no longer keeps secrets in plain-text files. Its login token and saved vault keys now go to your operating system's credential store: Keychain on macOS, Credential Manager on Windows, and the Secret Service (libsecret) on Linux. Machines without one use ~/.apivault/secrets.json, readable only by you on macOS and Linux.

#Vault keys are saved per project

Each project has its own vault key, so the CLI now saves one per project. Run this in the project folder:

Bash
apivault config set vaultKey      # prompts, then saves it for this project
apivault config get vaultKey      # masked, and whether one is saved
apivault config delete vaultKey   # removes this project's saved key

run, env export and keys then find the key on their own. When you type a vault key at a prompt, the CLI offers to save it for the project.

To use an environment variable instead, put a reference in .apivault.json. The file holds only the variable's name, so it stays safe to commit:

Bash
apivault config set vaultKey '${env:APIVAULT_KEY_MY_APP}'

The CLI looks for a vault key in this order: --vault-key, APIVAULT_KEY, a ${env:NAME} reference in .apivault.json, the key saved for the project, then a prompt.

#Other changes

  • apivault config set vaultKey --global is refused, because vault keys belong to projects, and config set --local vaultKey accepts only a ${env:NAME} reference.
  • apivault config get vaultKey no longer prints a saved key in full.
  • apivault run no longer passes APIVAULT_KEY, APIVAULT_KEY_* variables, or the variable .apivault.json names to the command it starts.
  • A vault key typed at a prompt is asked for once per command, not once per secret.

#Upgrading from 1.7

The first time 1.8 runs, it moves your login token from ~/.apivault/token.json and your vault key from ~/.apivault/config.json into the credential store and removes them from those files. The old vault key is then tried on projects that need one; the first project it works for gets its own saved copy, and a project it fails for isn't tried again. Remove it with apivault config delete vaultKey --global.

A vault key in .apivault.json still works but prints a warning. apivault config set vaultKey moves it and removes it from the file. If that file was ever committed, change the project's vault key.

See Vault keys in the CLI docs.