eca icon indicating copy to clipboard operation
eca copied to clipboard

Allow for API keys to be provided via external tools

Open skuro opened this issue 1 year ago • 3 comments

In the same spirit of e.g. ANSIBLE_VAULT_PASSWORD_FILE, allow API keys to be provided through external commands, lifting the requirement to leave sensitive content in plain text in the ECA configuration file(s).

To upvote this issue, give it a thumbs up. See this list for the most upvoted issues.

skuro avatar Aug 26 '25 13:08 skuro

@skuro don't you think the support for env var is not enough? via keyEnv or just the default <PROVIDER>_API_KEY? https://eca.dev/models/

ericdallo avatar Aug 26 '25 13:08 ericdallo

I can confirm that it does indeed work for my use case! I just had to walk the extra mile, let me walk you through my setup.

My "normal" workflow involves both SOPS to encrypt keys & passwords as well as direnv to load the SOPS secrets as env vars. This means that I usually just have a secrets file which is encrypted with sops, plus the following content in my .envrc which loads all the sops encrypted variables into the current env:

use_sops() {
    local path=${1:-$PWD/secrets}
    eval "$(sops -d "$path" | direnv dotenv bash /dev/stdin)"
    watch_file "$path"
}

export SOPS_PGP_FP="<my GPG key>"

use_sops

As a result, as soon as I cd into my project folders, I first get asked for the password of my GPG key (unless that's already known by the gpg-agent), then my env is populated with my super secret values. I see that when I run M-x eca, the cwd of the eca server is the folder containing the current buffer. I then ensured that a) the gpg-agent had already the key password in memory and b) I run M-x eca from a buffer file placed in the project root and bingo! it magically worked. One last experiment will be to see what happens when I run M-x eca after the gpg-agent forgot the password, I would expect something to blow up since I won't be able to input my password -- we shall see.

As per now, everything work and thanks for all the magic! ❤️

skuro avatar Aug 26 '25 14:08 skuro

Interesting workflow; glad you made it work. Thank you!

ericdallo avatar Aug 26 '25 14:08 ericdallo