dolittle / Runtime

Runtime for Dolittle
https://dolittle.io
MIT License
14 stars 10 forks source link

GDPR redaction support #776

Closed mhelleborg closed 1 day ago

mhelleborg commented 1 day ago

Summary

Runtime support for GDPR redactions. This adds support for redacting personal data from previously committed events.

Redactions are scoped to a single artifact-type (EventTypeId) and an EventSourceId.

It will recognize events with the correct GUID prefix "de1e7e17-bad5-da7a" that match the event payload and is valid.

    public class Event
    {
        public required string EventId { get; init; }
        public required string EventAlias { get; init; }

        /// <summary>
        /// The properties that will be redacted, and the replacement values.
        /// Can be null, in which case the properties will be redacted with a default value
        /// </summary>
        public required Dictionary<string, object?> RedactedProperties { get; init; }

        public required string RedactedBy { get; init; }
        public required string Reason { get; init; }

        public bool IsValid => !string.IsNullOrWhiteSpace(EventId)
                               && !string.IsNullOrWhiteSpace(EventAlias)
                               && RedactedProperties.Count > 0
                               && !string.IsNullOrWhiteSpace(RedactedBy)
                               && !string.IsNullOrWhiteSpace(Reason);
    }

Any valid redactions will then be performed in the same transaction as it writes the new events. Replays of these events will then return the updated version of the event, with the redactions performed.

Added