I have been searching for a simple way to manage secrets on a repository, leveraging known tools. Then I came across git-secret for that purpose. It provides the following features:
$ sudo rpm install git-secret # (must be downloaded from git-secret.io if not on the repository)
$ gpg --gen-key # generate gpg key (fill in real name with a unique name, and the email with the email)
$ git secret init # to initialize the secret feature
$ git secret tell <email-from-the-user-gpg-key> # add a user so he can see the secrets
$ git secret add -i <file> # add the file that has the secret, and auto-adds to .gitignore also
$ git secret hide -d # encrypt/re-encrypt files (-d removes the file after the encryption is done)
$ git secret reveal # decrypt secret files
$ # he must also install git-secret
$ gpg --gen-key # generate gpg key (fill in real name with a unique name, and the email with the email)
$ gpg --armor --output key.txt --export <email-used-on-the-generated-key> # export the public key
$ # (send the key.txt file to the owner - so that he can enable this key to the repository)
$ # BELOW MUST BE DONE BY THE OWNER:
$ gpg --import key.txt # import the new user key
$ git secret tell <email-from-the-user-gpg-key> # add the new user with the email he used on the public key, so he can see the secrets
$ # re-encrypt the files:
$ git secret reveal # decrypt all files
$ git secret hide -d # re-encrypt the files (-d removes the raw ones after the encryption is done)
$ # add, commit and push to the repository
$ # he must clone the repository and enter the folder into where it was cloned
$ git pull
$ git secret reveal
# reveal all secrets first, then:
git secret remove -c <file> # this must be the raw file, NOT the `.secret`
# then, you must also remove <file> on .gitignore
IMPORTANT: To remove a revealed (raw) file with secrets from the filesystem (your current local copy), just use a simple rm
command. e.g.: rm <file>
$ git secret killperson their@email.com
$ # re-encrypt the files as explained above, and they won't be able to decrypt secrets anymore
$ # add, commit and push to the repository