Replies: 4 comments
-
@KolesnichenkoDS You could achieve this through an IDocumentSessionListener. You'd get a chance to look at the events and potentially modify them just prior to the transaction being processed |
Beta Was this translation helpful? Give feedback.
-
@jeremydmiller thanks for the quick response! I'm not sure if that solves my issue. Please correct me if I'm wrong, but it seems to me that using UPD: Just to clarify, I don't want to automatically encrypt events, I want to pass an already encrypted event to Marten and automatically decrypt them before calling |
Beta Was this translation helpful? Give feedback.
-
+1 I have a similar need, but I'm using Inline Projections (currently).
However, as the author mentions, I can't find any hook where I can reload the event stream and rebuild the aggregate from unencrypted events... at least not anything very "built-in". I'm still fairly new to Marten, so I could be missing something. Is this something that could/should be done via the json serializer during deserialization? That feels smelly to me, but maybe that works. |
Beta Was this translation helpful? Give feedback.
-
@KolesnichenkoDS Shameless plug (I hope this isn't bad etiquette), but I threw together a library for encrypting/decrypting at the field/property level during JSON serialization/deserialization: https://github.com/Burwin/JsonCryption I'm not sure it solves all your issues, particularly because it sounds like you aren't using Marten to encrypt your events. I don't know how your project is set up, but if it is possible to leave all encryption/decryption to your JsonSerializer within Marten, then this might help. I haven't tested it with anything other than Inline Projections:
As you can see, I haven't tested the events themselves, but since they're encrypted/decrypted on serialization/deserialization, I'd expect they wouldn't be an issue (famous last words...). |
Beta Was this translation helpful? Give feedback.
-
I'm trying to implement GDPR-compliant personal data storage using Marten. To do so I want to encrypt personal data before saving it to event store and decrypt it before passing to aggregate's
Apply
method. I wasn't sure if there is some out of the box way to do something like this so I just copiedAggregationProjection
and added an additional parameter which is a function that changes event data. The result looks like this:InterceptingProjection.cs
The problem is that adding an inline aggregation projection to a projection collection relies on some private API that I cannot access from my extension method:
ProjectionCollectionExtensions.cs
And I don't know if there's any other way to get a proper
IAggregator<T>
instance from my extension method.Beta Was this translation helpful? Give feedback.
All reactions