DKNet

Redact sensitive values

Part of DKNet.EfCore.AuditLogs. Use capture attributes from DKNet.EfCore.Abstractions.Attributes on an audited entity. In the Quick Start, add these properties to Item:

[DKNet.EfCore.Abstractions.Attributes.SensitiveData]
public string? Notes { get; set; }

[DKNet.EfCore.Abstractions.Attributes.IgnoreAuditLog]
public string? DebugText { get; set; }

[DKNet.EfCore.Abstractions.Attributes.AuditLog]
public DateTimeOffset TokenExpiryUtc { get; set; }

Capture skips ignored properties, redacts declared sensitive or encrypted values, and otherwise applies the selected property policy.

[IgnoreAuditLog] on the class excludes the entire entity; on a property it omits that field. [AuditLog] on the class enables opt-in entity capture; on a property it bypasses name-based redaction, but never [SensitiveData] or an attribute named EncryptedAttribute.

⚙️ Configuration reference

Option Type Default Effect
behaviour AuditLogBehaviour IncludeAllAuditedEntities Capture all audited entities except ignored ones; OnlyAttributedAuditedEntities additionally requires class-level [AuditLog].
propertyPolicy AuditPropertyPolicy RedactSensitive Capture non-ignored fields with sensitive values replaced; OnlyAttributedProperties selects only [AuditLog] properties.

Pass these arguments to AddEfCoreAuditHook<TDbContext> or AddEfCoreAuditLogs<TDbContext, TPublisher>. Each such call registers singleton options; later option registrations can affect other contexts too.

🧱 Where it fits

Withhold sensitive properties from unauthorised callers is separate, opt-in API response filtering. Audit capture ignores [SensitiveData] role arguments and always redacts declared-sensitive values.

⚠️ Gotchas & limits