Skip to content
Snippets Groups Projects
Commit b54ec0ec authored by Johan de Klerk's avatar Johan de Klerk
Browse files

Added encryption keys

parent 33fd5611
No related branches found
No related tags found
No related merge requests found
package encryption
import (
"encoding/json"
"gitlab.bob.co.za/bob-public-utils/bobgroup-go-utils/errors"
"gitlab.bob.co.za/bob-public-utils/bobgroup-go-utils/logs"
"gitlab.bob.co.za/bob-public-utils/bobgroup-go-utils/secrets_manager"
)
type EncryptionKeysSecret struct {
EncryptionKeysValue string `json:"EncryptionKeys"`
}
type EncryptionKeys struct {
FirebaseEncryptionKey string `json:"firebase_encryption_key"`
JWTEncryptionKey string `json:"jwt_encryption_key"`
}
func GetEncryptionKeys(secretID string, isDebug bool) (EncryptionKeys, error) {
encryptionKeysSecretString, _ := secrets_manager.GetSecret(secretID, isDebug)
var encryptionKeys EncryptionKeys
var encryptionKeysSecret EncryptionKeysSecret
err := json.Unmarshal([]byte(encryptionKeysSecretString), &encryptionKeysSecret)
if err == nil {
err = json.Unmarshal([]byte(encryptionKeysSecret.EncryptionKeysValue), &encryptionKeys)
}
return encryptionKeys, err
}
func GetJWTEncryptionKey(secretID string, isDebug bool) (string, error) {
encryptionKeys, err := GetEncryptionKeys(secretID, isDebug)
if err != nil {
logs.ErrorWithMsg("Could not get encryption keys from secret manager", err)
return "", errors.Error("failed to get encryption keys for login")
}
return encryptionKeys.JWTEncryptionKey, nil
}
func GetFirebaseCredentialsEncryptionKey(secretID string, isDebug bool) (string, error) {
encryptionKeys, err := GetEncryptionKeys(secretID, isDebug)
return encryptionKeys.FirebaseEncryptionKey, err
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment