1
0
mirror of https://github.com/vwxyzjn/portwarden synced 2025-12-06 01:33:18 +00:00

API-15 # Delete the Salt and use environment variable to generate the salt

This commit is contained in:
Costa Huang
2018-12-13 15:54:52 -05:00
parent b58840d612
commit 04d4b908db
4 changed files with 35 additions and 4 deletions

View File

@@ -1,2 +1,3 @@
vendor
Dockerfile
Dockerfile
salt.go

3
.gitignore vendored
View File

@@ -1,4 +1,5 @@
cmd/portwarden/portwarden_backup/*
vendor/*
**/*.portwarden
**/*.decrypted.zip
**/*.decrypted.zip
salt.go

View File

@@ -14,8 +14,6 @@ import (
)
const (
Salt = `,(@0vd<)D6c3:5jI;4BZ(#Gx2IZ6B>`
ErrMessageAuthenticationFailed = "cipher: message authentication failed"
ErrWrongBackupPassphrase = "wrong backup passphrase entered"
)

View File

@@ -0,0 +1,31 @@
package main
import (
"fmt"
"io/ioutil"
"log"
"os"
)
const (
Template = `package portwarden
const (
Salt = "%v"
)
`
)
func main() {
Salt := os.Getenv("Salt")
if len(Salt) == 0 {
log.Fatal("Salt not detected in Environment Variable `Salt`")
}
err := ioutil.WriteFile("./salt.go", []byte(fmt.Sprintf(Template, Salt)), 0644)
if err != nil {
if len(Salt) == 0 {
log.Fatalf("Error writing salt file: %v", err)
}
}
}