Skip to content

Commit

Permalink
Remove JSON pre-processing for "SECRET:*" values
Browse files Browse the repository at this point in the history
  • Loading branch information
debovema committed Jan 15, 2019
1 parent 98a1d79 commit 410ae00
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 24 deletions.
8 changes: 1 addition & 7 deletions engine/appconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"os"

"github.com/project-flogo/core/app"
"github.com/project-flogo/core/engine/secret"
"github.com/project-flogo/core/support"
)

Expand Down Expand Up @@ -58,13 +57,8 @@ func LoadAppConfig(flogoJson string, compressed bool) (*app.Config, error) {
}
}

updated, err := secret.PreProcessConfig(jsonBytes)
if err != nil {
return nil, err
}

appConfig := &app.Config{}
err = json.Unmarshal(updated, &appConfig)
err := json.Unmarshal(jsonBytes, &appConfig)
if err != nil {
return nil, err
}
Expand Down
17 changes: 0 additions & 17 deletions engine/secret/config.go
Original file line number Diff line number Diff line change
@@ -1,26 +1,9 @@
package secret

import (
"regexp"
"strings"
)

func PreProcessConfig(appJson []byte) ([]byte, error) {

// For now decode secret values
re := regexp.MustCompile("SECRET:[^\\\\\"]*")
for _, match := range re.FindAll(appJson, -1) {
decodedValue, err := resolveSecretValue(string(match))
if err != nil {
return nil, err
}
appstring := strings.Replace(string(appJson), string(match), decodedValue, -1)
appJson = []byte(appstring)
}

return appJson, nil
}

func resolveSecretValue(encrypted string) (string, error) {
encodedValue := string(encrypted[7:])
decodedValue, err := GetSecretValueHandler().DecodeValue(encodedValue)
Expand Down

0 comments on commit 410ae00

Please sign in to comment.