Skip to content

Commit

Permalink
Clientside guardrails
Browse files Browse the repository at this point in the history
  • Loading branch information
mhelleborg committed Oct 16, 2024
1 parent eeb8ee1 commit 5934c75
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Source/Events/Redaction/PersonalDataRedactedForEvent.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Dolittle. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;

Expand All @@ -10,9 +11,14 @@ namespace Dolittle.SDK.Events.Redaction;
/// Event that triggers redaction of the given personal data
/// It will target the given event type and redact the properties specified within the EventSourceId of the event
/// </summary>
[EventType("de1e7e17-bad5-da7a-fad4-fbc6ec3c0ea5")]
[EventType(PersonalDataRedactedId)]
public class PersonalDataRedactedForEvent
{
/// <summary>
/// This is recognized by the runtime, and triggers redaction of the selected personal data
/// </summary>
public const string PersonalDataRedactedId = "de1e7e17-bad5-da7a-fad4-fbc6ec3c0ea5";
private static readonly Guid _id = Guid.Parse(PersonalDataRedactedId);
public string EventId { get; init; }
public string EventAlias { get; init; }
public Dictionary<string, object?> RedactedProperties { get; init; }
Expand Down Expand Up @@ -54,6 +60,12 @@ public static bool TryCreate<TEvent>(string reason, string redactedBy,
return false;
}

if (eventType.Id.Equals(_id))
{
error = "Cannot create redaction event for redaction event";
return false;
}

var redactedFields = RedactedType<TEvent>.RedactedProperties;
if (redactedFields.Count == 0)
{
Expand Down

0 comments on commit 5934c75

Please sign in to comment.