feat: improve security
This commit is contained in:
parent
99fb97dff3
commit
5b16cef525
8 changed files with 181 additions and 46 deletions
28
secrets.go
Normal file
28
secrets.go
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/zalando/go-keyring"
|
||||
)
|
||||
|
||||
const (
|
||||
serviceName = "workctl"
|
||||
keySSHPassword = "ssh-password"
|
||||
keyRDPPassword = "rdp-password"
|
||||
)
|
||||
|
||||
func getSecret(key string) (string, error) {
|
||||
val, err := keyring.Get(serviceName, key)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return val, nil
|
||||
}
|
||||
|
||||
func setSecret(key, value string) error {
|
||||
if value == "" {
|
||||
return fmt.Errorf("secret cannot be empty")
|
||||
}
|
||||
return keyring.Set(serviceName, key, value)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue