sypher provides you to store your credentials and secrets as encrypted in your repository.
go get github.com/sertangulveren/sypher/sypherThe gen command as below will create your credentials under the sypher folder in your working directory:
sypher genIt will be generate your credentials as below:
sypher
├── master.enc
└── master.keyYou can provide names to generator.
For example:
sypher gen development test productionThe program will generate files as below:
sypher
├── development.enc
├── development.key
├── production.enc
├── production.key
├── test.enc
└── test.keyYou can ignore your key files manually with the .gitignore file or use the gitignore command. This command will generate or modify your .gitignore file.
sypher gitignoreUse edit command to make changes on your credentials.
In this case, sypher will launch an editor(vim by default) with your decrypted credentials.
When you save the changes and close the editor, sypher immediately reads your new credentials and writes it to encrypted credential file in your project.
For example:
sypher edit productionTo use another editor like Visual Studio Code:
EDITOR=code sypher edit productionInstead of using key files in your cloud or development environment, you should set the SYPHER_MASTER_KEY environment variable.
In your program, all your need to do is to import sypher.
package main
import "github.com/sertangulveren/sypher"
func main() {
// loads sypher/master.enc with sypher/master.key OR SYPHER_MASTER_KEY.
sypher.Load()
awsKey := sypher.Get("AWS_SECRET_KEY")
//...
}Example for production:
package main
import (
"github.com/sertangulveren/sypher"
"os"
)
func main() {
// APP_ENV=production
// SYPHER_MASTER_KEY=abcd...
// production.key application has no production.key
// loads sypher/production.enc with SYPHER_MASTER_KEY.
sypher.Load(
sypher.Config{Name: os.Getenv("APP_ENV")},
)
awsKey := sypher.Get("AWS_SECRET_KEY")
//...
}- Embed on building.
- Get it ready to be used.
- Missing tests should be done.
- Code quality improvements.
- ...