Skip to content
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

Merged
merged 3 commits into from
Jan 31, 2024

Conversation

cormacdalton
Copy link
Contributor

Handle payload path parameters and add tests cases

@@ -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

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

@@ -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

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?

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

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.

@@ -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] == '$' {

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

@cormacdalton cormacdalton merged commit 44c0e1d into Mastercard:master Jan 31, 2024
2 checks passed
@cormacdalton cormacdalton deleted the fix-encryption branch January 31, 2024 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants