-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix encryption and decryption #15
Conversation
encryption/encryption.go
Outdated
@@ -28,23 +32,48 @@ func encryptPayloadPath(jsonPayload *gabs.Container, jsonPathIn string, jsonPath | |||
Kid: config.GetEncryptionKeyFingerprint(), | |||
Cty: "application/json", | |||
} | |||
|
|||
payload, err := jwe.Encrypt(config, jsonPayload.String(), joseHeader) | |||
var payloadPath *gabs.Container |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please provide an initialisation to this variable
encryption/encryption.go
Outdated
@@ -28,23 +32,48 @@ func encryptPayloadPath(jsonPayload *gabs.Container, jsonPathIn string, jsonPath | |||
Kid: config.GetEncryptionKeyFingerprint(), | |||
Cty: "application/json", | |||
} | |||
|
|||
payload, err := jwe.Encrypt(config, jsonPayload.String(), joseHeader) | |||
var payloadPath *gabs.Container |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this variable used in this code?
encryption/encryption.go
Outdated
return jsonPayload | ||
} | ||
|
||
func decryptPayloadPath(jsonPayload *gabs.Container, jsonPathIn string, jsonPathOut string, config jwe.JWEConfig) *gabs.Container { | ||
inJsonObject := jsonPayload.Path(jsonPathIn).Data().(string) | ||
var inJsonObject string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please movie lines 66-76 to a separate function.
encryption/encryption.go
Outdated
@@ -57,9 +86,17 @@ func decryptPayloadPath(jsonPayload *gabs.Container, jsonPathIn string, jsonPath | |||
if jsonPathOut == "$" { | |||
jsonPayload = jsonDecryptedPayload | |||
} else { | |||
jsonPayload.DeleteP(jsonPathIn) | |||
jsonPayload.Set(jsonDecryptedPayload, jsonPathOut) | |||
if jsonPathOut[0] == '$' { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this If statement is duplicate, please consider to implement a helper function for it
Handle payload path parameters and add tests cases