summaryrefslogtreecommitdiff
path: root/internal/configuration/helpers.go
diff options
context:
space:
mode:
authorJames Elliott <james-d-elliott@users.noreply.github.com>2023-10-18 05:39:11 +1100
committerGitHub <noreply@github.com>2023-10-18 04:39:11 +1000
commit5446efb48a6e031080dbd22b418f023aa8efd6e5 (patch)
tree900afb1b2856ef14c87d088fe33d8a1a8b35f56b /internal/configuration/helpers.go
parent8ab5126818ac6b71c900516bf86c5655ea690cd8 (diff)
fix(configuration): deprecated secrets not mapped (#6150)
This fixes an issue where a deprecated configuration options when used as a secret are not mapped like the other configuration sources are. It should be noted no previous secret key has been deprecated so this fixes an issue that had no practical replication, however it fixes a future issue preemptively. Signed-off-by: James Elliott <james-d-elliott@users.noreply.github.com>
Diffstat (limited to 'internal/configuration/helpers.go')
-rw-r--r--internal/configuration/helpers.go18
1 files changed, 16 insertions, 2 deletions
diff --git a/internal/configuration/helpers.go b/internal/configuration/helpers.go
index 57e00fa43..db4450727 100644
--- a/internal/configuration/helpers.go
+++ b/internal/configuration/helpers.go
@@ -7,7 +7,7 @@ import (
"github.com/authelia/authelia/v4/internal/utils"
)
-func getEnvConfigMap(keys []string, prefix, delimiter string) (keyMap map[string]string, ignoredKeys []string) {
+func getEnvConfigMap(keys []string, prefix, delimiter string, ds map[string]Deprecation) (keyMap map[string]string, ignoredKeys []string) {
keyMap = make(map[string]string)
for _, key := range keys {
@@ -21,6 +21,12 @@ func getEnvConfigMap(keys []string, prefix, delimiter string) (keyMap map[string
}
}
+ for key := range ds {
+ if IsSecretKey(key) {
+ ignoredKeys = append(ignoredKeys, ToEnvironmentSecretKey(key, prefix, delimiter))
+ }
+ }
+
for _, deprecation := range deprecations {
if !deprecation.AutoMap {
continue
@@ -32,7 +38,7 @@ func getEnvConfigMap(keys []string, prefix, delimiter string) (keyMap map[string
return keyMap, ignoredKeys
}
-func getSecretConfigMap(keys []string, prefix, delimiter string) (keyMap map[string]string) {
+func getSecretConfigMap(keys []string, prefix, delimiter string, ds map[string]Deprecation) (keyMap map[string]string) {
keyMap = make(map[string]string)
for _, key := range keys {
@@ -43,6 +49,14 @@ func getSecretConfigMap(keys []string, prefix, delimiter string) (keyMap map[str
}
}
+ for key := range ds {
+ if IsSecretKey(key) {
+ originalKey := strings.ToUpper(strings.ReplaceAll(key, constDelimiter, delimiter)) + constSecretSuffix
+
+ keyMap[prefix+originalKey] = key
+ }
+ }
+
return keyMap
}