revert: secrets as []byte instead of string

Signed-off-by: Jan Larwig <jan@larwig.com>
This commit is contained in:
Jan Larwig
2025-11-16 22:38:42 +01:00
parent aaf1889b97
commit 810f629ee8
16 changed files with 42 additions and 40 deletions
+1 -1
View File
@@ -294,7 +294,7 @@ func getBasicAuthHeader(preferEmailToUser bool, basicAuthPassword string) Header
Claim: claim,
Prefix: "Basic ",
BasicAuthPassword: &SecretSource{
Value: basicAuthPassword,
Value: []byte(basicAuthPassword),
},
},
},
+2 -2
View File
@@ -369,7 +369,7 @@ var _ = Describe("Legacy Options", func() {
Claim: "user",
Prefix: "Basic ",
BasicAuthPassword: &SecretSource{
Value: basicAuthSecret,
Value: []byte(basicAuthSecret),
},
},
},
@@ -409,7 +409,7 @@ var _ = Describe("Legacy Options", func() {
Claim: "email",
Prefix: "Basic ",
BasicAuthPassword: &SecretSource{
Value: basicAuthSecret,
Value: []byte(basicAuthSecret),
},
},
},
+1 -1
View File
@@ -581,7 +581,7 @@ injectResponseHeaders:
Values: []HeaderValue{
{
SecretSource: &SecretSource{
Value: "secret",
Value: []byte("secret"),
},
},
},
+2 -2
View File
@@ -3,8 +3,8 @@ package options
// SecretSource references an individual secret value.
// Only one source within the struct should be defined at any time.
type SecretSource struct {
// Value expects a base64 encoded string value.
Value string `yaml:"value,omitempty"`
// Value expects a base64 encoded []byte
Value []byte `yaml:"value,omitempty"`
// FromEnv expects the name of an environment variable.
FromEnv string `yaml:"fromEnv,omitempty"`
+1 -1
View File
@@ -11,7 +11,7 @@ import (
func GetSecretValue(source *options.SecretSource) ([]byte, error) {
switch {
case len(source.Value) > 0 && source.FromEnv == "" && source.FromFile == "":
return []byte(source.Value), nil
return source.Value, nil
case len(source.Value) == 0 && source.FromEnv != "" && source.FromFile == "":
return []byte(os.Getenv(source.FromEnv)), nil
case len(source.Value) == 0 && source.FromEnv == "" && source.FromFile != "":
+1 -1
View File
@@ -31,7 +31,7 @@ var _ = Describe("GetSecretValue", func() {
It("returns the correct value from the string value", func() {
value, err := GetSecretValue(&options.SecretSource{
Value: "secret-value-1",
Value: []byte("secret-value-1"),
})
Expect(err).ToNot(HaveOccurred())
Expect(string(value)).To(Equal("secret-value-1"))