Hello, Temporal community,
I am working on a way to encrypt and decrypt only certain fields of workflow payload. For that I’m using custom struct tags in Go and reflect pkg to loop through struct fields. For now only string and [’]byte fields are encrypted. Here is the signature:
func encryptFields(obj interface{}, key []byte) (map[string]interface{}, error)
It is used in the method below:
func (dc *CryptDataConverter) ToPayload(value interface{}) (*commonpb.Payload, error)
after I return map[string]interface{} I convert it back to original type.
Encryption works fine, but on the decryption side I have an issue.
So here is the signature of data-converter interface:
func (dc *CryptDataConverter) FromPayload(payload *commonpb.Payload, valuePtr interface{}) error {
payload.Data is a slice of bytes that contain the input (with already encrypted fields).
The problem is I don’t know how to use valuePtr to unmarshal it to object, which I can pass in to
func decryptFields(obj interface{}, key []byte) (map[string]interface{}, error)
method.
Any suggestions/recommendations would be appreciated. Thanks!