mirror of
https://github.com/oauth2-proxy/oauth2-proxy.git
synced 2026-10-22 04:32:02 +02:00
revert: secrets as []byte instead of string
Signed-off-by: Jan Larwig <jan@larwig.com>
This commit is contained in:
@@ -294,7 +294,7 @@ func getBasicAuthHeader(preferEmailToUser bool, basicAuthPassword string) Header
|
||||
Claim: claim,
|
||||
Prefix: "Basic ",
|
||||
BasicAuthPassword: &SecretSource{
|
||||
Value: basicAuthPassword,
|
||||
Value: []byte(basicAuthPassword),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -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),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -581,7 +581,7 @@ injectResponseHeaders:
|
||||
Values: []HeaderValue{
|
||||
{
|
||||
SecretSource: &SecretSource{
|
||||
Value: "secret",
|
||||
Value: []byte("secret"),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -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"`
|
||||
|
||||
@@ -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 != "":
|
||||
|
||||
@@ -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"))
|
||||
|
||||
Reference in New Issue
Block a user