class
AesGcmAuditFieldEncryptor
Ensamblado: EricksonLopez.Auditingpublic sealed class AesGcmAuditFieldEncryptor : IAuditFieldEncryptor
Implementa: IAuditFieldEncryptor
Implements authenticated AES-256-GCM field-level encryption and GDPR Art. 17 crypto-shredding using an `IAuditCryptoKeyProvider`.
Miembros (5)
constructorAesGcmAuditFieldEncryptor
public AesGcmAuditFieldEncryptor(IAuditCryptoKeyProvider keyProvider)
Initializes a new instance of the `AesGcmAuditFieldEncryptor` class.
- keyProvider: IAuditCryptoKeyProvider
- The cryptographic key provider managing per-subject AES-256 keys.
methodDecryptAsync
public async ValueTask<string> DecryptAsync(string ciphertext, string subjectId, CancellationToken cancellationToken = default)
Decrypts an `ENC:v1:` ciphertext field value using the cryptographic key associated with `subjectId`, or returns `[SHREDDED]` if the subject's key has been permanently destroyed.
- ciphertext: string
- The `ENC:v1:` ciphertext value to decrypt.
- subjectId: string
- The tenant or subject identifier whose encryption key is used.
- cancellationToken: CancellationToken
- A token to monitor for cancellation requests.
Retorna: The decrypted plaintext value, or `[SHREDDED]` if the key was destroyed.
methodEncryptAsync
public async ValueTask<string> EncryptAsync(string plaintext, string subjectId, CancellationToken cancellationToken = default)
Encrypts a plaintext field value using the cryptographic key associated with `subjectId`.
- plaintext: string
- The plaintext field value to encrypt.
- subjectId: string
- The tenant or subject identifier whose encryption key is used.
- cancellationToken: CancellationToken
- A token to monitor for cancellation requests.
Retorna: The authenticated ciphertext payload formatted with the `ENC:v1:` envelope prefix.
fieldEnvelopePrefix
public const string EnvelopePrefix
Specifies the prefix prepended to all encrypted field payloads.
fieldShreddedPlaceholder
public const string ShreddedPlaceholder
Specifies the placeholder returned when attempting to decrypt a field whose subject key has been shredded.
class
AmbientAuditTimeProvider
Ensamblado: EricksonLopez.Auditing.Abstractionspublic sealed class AmbientAuditTimeProvider : IAuditTimeProvider
Implementa: IAuditTimeProvider
Provides ambient or UTC timestamps with support for deterministic time-freezing scopes in testing and transactions.
Miembros (4)
methodBeginScope
public static IDisposable BeginScope(DateTimeOffset frozenUtc)
Begins a time scope where `GetUtcNow` returns the specified frozen timestamp until disposed.
- frozenUtc: DateTimeOffset
- The deterministic UTC timestamp to freeze.
Retorna: A disposable scope that restores the previous ambient time upon disposal.
methodGetUtcNow
public DateTimeOffset GetUtcNow()
Gets the current deterministic audit timestamp in UTC.
Retorna: The current UTC timestamp.
methodTryGetAmbientTime
public static bool TryGetAmbientTime(out DateTimeOffset frozenUtc)
Attempts to retrieve the active frozen ambient UTC timestamp if a deterministic time scope is currently active.
- frozenUtc: out DateTimeOffset
- When this method returns `true`, contains the active frozen UTC timestamp; otherwise, `default`.
Retorna: `true` if an ambient time scope is currently active; otherwise, `false`.
propertyInstance
public static AmbientAuditTimeProvider Instance { get; }
Gets the singleton instance of `AmbientAuditTimeProvider`.
record
AuditAction
Ensamblado: EricksonLopez.Auditing.Abstractionspublic readonly record struct AuditAction(string Code)
Represents an operation executed by an actor on a resource.
Miembros (29)
constructorAuditAction
public AuditAction(string Code)
Initializes a new instance of AuditAction.
- Code: string
- A short code identifying the action.
methodToString
public override string ToString()
Inherits documentation from base type or interface.
propertyCode
public string Code { get; init; }
A short code identifying the action.
fieldAccountLockedOut
public static readonly AuditAction AccountLockedOut
Represents an action where an account was locked out due to security policy enforcement.
fieldApprove
public static readonly AuditAction Approve
Represents an action where a resource or request was approved.
fieldBreakGlassActivated
public static readonly AuditAction BreakGlassActivated
Represents an action where emergency break-glass access was activated.
fieldCancel
public static readonly AuditAction Cancel
Represents an action where a pending operation was cancelled.
fieldCreate
public static readonly AuditAction Create
Represents an action where a new resource was created.
fieldDelete
public static readonly AuditAction Delete
Represents an action where an existing resource was deleted or soft-deleted.
fieldDownload
public static readonly AuditAction Download
Represents an action where a file or resource was downloaded.
fieldExport
public static readonly AuditAction Export
Represents an action where data was exported outside the system boundary.
fieldGenesisBootstrap
public static readonly AuditAction GenesisBootstrap
Represents an action where root `GENESIS` system bootstrap seeding occurred.
fieldGrantPermission
public static readonly AuditAction GrantPermission
Represents an action where a permission or role was assigned.
fieldImpersonationEnded
public static readonly AuditAction ImpersonationEnded
Represents an action where a delegated support or impersonation session ended.
fieldImpersonationStarted
public static readonly AuditAction ImpersonationStarted
Represents an action where a delegated support or impersonation session started.
fieldLogin
public static readonly AuditAction Login
Represents an action where a user authenticated into the system.
fieldLogout
public static readonly AuditAction Logout
Represents an action where a user explicitly ended their session.
fieldMfaDisabled
public static readonly AuditAction MfaDisabled
Represents an action where multi-factor authentication was disabled.
fieldMfaEnrolled
public static readonly AuditAction MfaEnrolled
Represents an action where multi-factor authentication was enrolled.
fieldMfaVerified
public static readonly AuditAction MfaVerified
Represents an action where a multi-factor authentication challenge was verified.
fieldPlaneSwitched
public static readonly AuditAction PlaneSwitched
Represents an action where a principal switched active security execution planes or organizational scopes.
fieldRead
public static readonly AuditAction Read
Represents an action where a resource was accessed or read.
fieldReject
public static readonly AuditAction Reject
Represents an action where a resource or request was rejected.
fieldRestore
public static readonly AuditAction Restore
Represents an action where a resource was restored after soft-deletion.
fieldRevokePermission
public static readonly AuditAction RevokePermission
Represents an action where a permission or role was revoked.
fieldSecretRotated
public static readonly AuditAction SecretRotated
Represents an action where a cryptographic key, credential, or secret was rotated.
fieldSend
public static readonly AuditAction Send
Represents an action where a resource was sent or dispatched.
fieldTokenRevoked
public static readonly AuditAction TokenRevoked
Represents an action where an authentication token, API key, or session was revoked.
fieldUpdate
public static readonly AuditAction Update
Represents an action where an existing resource was updated.
record
AuditActor
Ensamblado: EricksonLopez.Auditing.Abstractionspublic sealed record AuditActor(AuditActorType Type, string Id, string? DisplayName)
Represents the authenticated identity that performed an audited action.
Miembros (6)
constructorAuditActor
public AuditActor(AuditActorType Type, string Id, string? DisplayName = null)
Initializes a new instance of AuditActor.
- Type: AuditActorType
- The classification category of the actor.
- Id: string
- The stable identifier of the actor.
- DisplayName: string?
- The optional human-readable label for the actor.
propertyDisplayName
public string? DisplayName { get; init; }
The optional human-readable label for the actor.
propertyId
public string Id { get; init; }
Gets the stable identifier of the actor.
propertyType
public AuditActorType Type { get; init; }
The classification category of the actor.
fieldAnonymous
public static readonly AuditActor Anonymous
Gets a predefined actor representing an anonymous or unauthenticated principal.
fieldSystem
public static readonly AuditActor System
Gets a predefined actor representing the hosting system process.
enum
AuditActorType
Ensamblado: EricksonLopez.Auditing.Abstractionspublic enum AuditActorType : byte
Specifies the classification of the entity that performed an audited action.
Miembros (6)
fieldAnonymous
Anonymous = 6
Specifies an unauthenticated or unidentifiable principal.
fieldIntegration
Integration = 5
Specifies an external integration or third-party system.
fieldScheduledJob
ScheduledJob = 4
Specifies an automated scheduled job or background worker.
fieldService
Service = 3
Specifies an external service acting via service-to-service authentication.
fieldSystemProcess
SystemProcess = 2
Specifies an internal system process with no human identity.
fieldUser
User = 1
Specifies an authenticated human user.
record
AuditChange
Ensamblado: EricksonLopez.Auditing.Abstractionspublic sealed record AuditChange(string Field, string? OldValue, string? NewValue, bool IsRedacted)
Represents a single field-level state change captured during an audited action.
Miembros (6)
constructorAuditChange
public AuditChange(string Field, string? OldValue, string? NewValue, bool IsRedacted = false)
Initializes a new instance of AuditChange.
- Field: string
- The name of the modified property or field.
- OldValue: string?
- The value before the change, or `null` for newly created resources.
- NewValue: string?
- The value after the change, or `null` for deleted resources.
- IsRedacted: bool
- A value indicating whether the actual values were withheld by sensitivity policies.
methodRedacted
public static AuditChange Redacted(string field)
Creates a redacted change entry for a sensitive field with suppressed values.
- field: string
- The name of the sensitive field that was modified.
Retorna: A new `AuditChange` instance with `AuditChange.IsRedacted` set to `true`.
propertyField
public string Field { get; init; }
The name of the modified property or field.
propertyIsRedacted
public bool IsRedacted { get; init; }
A value indicating whether the actual values were withheld by sensitivity policies.
propertyNewValue
public string? NewValue { get; init; }
The value after the change, or `null` for deleted resources.
propertyOldValue
public string? OldValue { get; init; }
The value before the change, or `null` for newly created resources.
class
AuditConfiguration
Ensamblado: EricksonLopez.Auditingpublic sealed class AuditConfiguration
Represents runtime configuration options for the auditing pipeline.
Miembros (13)
propertyBatchChannelCapacity
public int BatchChannelCapacity { get; set; }
Gets or sets the maximum number of records buffered in the batch channel before applying backpressure.
propertyBatchFlushInterval
public TimeSpan BatchFlushInterval { get; set; }
Gets or sets the maximum duration to wait before flushing a partially filled batch.
propertyBatchSize
public int BatchSize { get; set; }
Gets or sets the maximum number of records persisted per batch flush operation.
propertyCriticalActionCodes
public HashSet<string> CriticalActionCodes { get; }
Gets the set of action codes for which store failures must always propagate regardless of `DefaultFailureBehavior`.
propertyDefaultFailureBehavior
public AuditFailureBehavior DefaultFailureBehavior { get; set; }
Gets or sets the default failure handling behavior when the audit store fails.
propertyEnableIntegrityChain
public bool EnableIntegrityChain { get; set; }
Gets or sets a value indicating whether HMAC chain integrity verification is enabled globally.
propertyEnableSecurityAlerts
public bool EnableSecurityAlerts { get; set; }
Gets or sets a value indicating whether real-time security alerting via `SecurityAlertAuditStoreDecorator` is enabled.
propertyEncryptedFields
public HashSet<string> EncryptedFields { get; }
Gets the set of field names whose change values must be encrypted using authenticated AES-256-GCM via `IAuditCryptoKeyProvider` to support GDPR Art. 17 Crypto-Shredding.
propertyEntityActorResolution
public EntityAuditActorResolution EntityActorResolution { get; set; }
Gets or sets how `IEntityAuditStamper` resolves the stamped actor identifier during active delegated impersonation. Defaults to `EntityAuditActorResolution.EffectiveOperator` (`ImpersonatorId ?? ActorId`).
propertyFailClosedOnImpersonation
public bool FailClosedOnImpersonation { get; set; }
Gets or sets a value indicating whether delegated support impersonation records always enforce fail-closed persistence regardless of `DefaultFailureBehavior`. Defaults to `true`.
propertyGlobalFieldDenylist
public HashSet<string> GlobalFieldDenylist { get; }
Gets the global set of field names always excluded from change tracking records across all types.
propertyMaxStringLength
public int MaxStringLength { get; set; }
Gets or sets the maximum allowed string length for change values.
propertySanitizeContextMetadata
public bool SanitizeContextMetadata { get; set; }
Gets or sets a value indicating whether sensitive secret keys inside `AuditContext.Metadata` are automatically redacted to `[REDACTED]`. Defaults to `true`.
record
AuditContext
Ensamblado: EricksonLopez.Auditing.Abstractionspublic sealed record AuditContext(TenantId TenantId, string Source, string? CorrelationId, string? CausationId, string? RequestId, string? IpAddress, string? UserAgent, string? IdempotencyKey, IReadOnlyDictionary<string, string>? Metadata)
Encapsulates technical execution context metadata for an audited action.
Miembros (16)
constructorAuditContext
public AuditContext(TenantId TenantId, string Source, string? CorrelationId = null, string? CausationId = null, string? RequestId = null, string? IpAddress = null, string? UserAgent = null, string? IdempotencyKey = null, IReadOnlyDictionary<string, string>? Metadata = null)
Initializes a new instance of AuditContext.
- TenantId: TenantId
- The tenant identifier scoping the audit record.
- Source: string
- The application or service component that generated the audit record.
- CorrelationId: string?
- The optional correlation identifier linking related operations across services.
- CausationId: string?
- The optional identifier of the direct causal event or command.
- RequestId: string?
- The optional transport-level request identifier.
- IpAddress: string?
- The optional network IP address of the originating client.
- UserAgent: string?
- The optional user agent string from the originating client request.
- IdempotencyKey: string?
- The optional idempotency key preventing duplicate writes during concurrent retries.
- Metadata: IReadOnlyDictionary<string, string>?
- The optional ambient key-value metadata propagated from `AuditScope` or enrichers.
methodAnonymizeIp
public static string? AnonymizeIp(string? ipAddress)
Anonymizes the specified IP address for privacy compliance.
- ipAddress: string?
- The IP address string to anonymize.
Retorna: The anonymized IP address string, or `null` if input is `null`, white-space, or invalid.
propertyCausationId
public string? CausationId { get; init; }
The optional identifier of the direct causal event or command.
propertyCorrelationId
public string? CorrelationId { get; init; }
The optional correlation identifier linking related operations across services.
propertyExecutionPlane
public AuditExecutionPlane ExecutionPlane { get; init; }
Gets the security execution plane in which the audited action occurred. Defaults to `AuditExecutionPlane.Unspecified`.
propertyIdempotencyKey
public string? IdempotencyKey { get; init; }
The optional idempotency key preventing duplicate writes during concurrent retries.
propertyIpAddress
public string? IpAddress { get; init; }
The optional network IP address of the originating client.
propertyMetadata
public IReadOnlyDictionary<string, string>? Metadata { get; init; }
The optional ambient key-value metadata propagated from `AuditScope` or enrichers.
propertyOrganizationId
public string? OrganizationId { get; init; }
Gets the optional hierarchical sub-tenant organization, company, or workspace identifier scoping the operation.
propertyRequestId
public string? RequestId { get; init; }
The optional transport-level request identifier.
propertySource
public string Source { get; init; }
Gets the application or service component that generated the audit record.
propertyTenantId
public TenantId TenantId { get; init; }
The tenant identifier scoping the audit record.
propertyUserAgent
public string? UserAgent { get; init; }
The optional user agent string from the originating client request.
fieldBootstrapTenantId
public static readonly TenantId BootstrapTenantId
Gets the reserved tenant identifier for deterministic system bootstrap and root genesis initialization events.
fieldControlPlaneTenantId
public static readonly TenantId ControlPlaneTenantId
Gets the reserved tenant identifier for SaaS control-plane operations not bound to a customer tenant.
fieldSystemTenantId
public static readonly TenantId SystemTenantId
Gets the reserved tenant identifier for system-level or platform-wide events.
class
AuditCursorToken
Ensamblado: EricksonLopez.Auditing.Abstractionspublic static class AuditCursorToken
Provides methods for encoding and decoding composite pagination cursor tokens.
Miembros (2)
methodCreate
public static string Create(DateTimeOffset occurredAt, Guid id)
Creates a base64-encoded continuation token containing the occurred_at timestamp and unique identifier.
- occurredAt: DateTimeOffset
- The occurrence timestamp of the record.
- id: Guid
- The unique identifier of the record.
Retorna: A base64-encoded continuation token string.
methodTryParse
public static bool TryParse(string? token, out DateTimeOffset occurredAt, out Guid id)
Attempts to parse a base64-encoded continuation token into its timestamp and identifier components.
- token: string?
- The continuation token to parse.
- occurredAt: out DateTimeOffset
- When this method returns, contains the parsed occurrence timestamp if parsing succeeded; otherwise, the default value.
- id: out Guid
- When this method returns, contains the parsed record identifier if parsing succeeded; otherwise, an empty identifier.
Retorna: `true` if the token was parsed successfully; otherwise, `false`.
enum
AuditExecutionPlane
Ensamblado: EricksonLopez.Auditing.Abstractionspublic enum AuditExecutionPlane : byte
Specifies the isolated security execution plane in which an audited operation occurred.
Miembros (5)
fieldBootstrap
Bootstrap = 4
Specifies the deterministic system initialization, migration, or root genesis seeding plane (`BOOTSTRAP`).
fieldControl
Control = 2
Specifies the SaaS platform operator and cross-tenant administration plane (`CONTROL`).
fieldService
Service = 3
Specifies the machine-to-machine or non-human service principal execution plane (`M2M`).
fieldTenant
Tenant = 1
Specifies the customer or tenant operational execution plane (`TENANT`).
fieldUnspecified
Unspecified = 0
Specifies that no explicit execution plane classification was assigned.
class
AuditExecutionPlaneExtensions
Ensamblado: EricksonLopez.Auditing.Abstractionspublic static class AuditExecutionPlaneExtensions
Provides wire-format serialization and parsing helpers for `AuditExecutionPlane`.
Miembros (2)
methodToWireCode
public static string ToWireCode(this AuditExecutionPlane plane)
Converts the specified `AuditExecutionPlane` to its canonical uppercase wire code.
- plane: this AuditExecutionPlane
- The execution plane value to convert.
Retorna: The canonical wire code (`UNSPECIFIED`, `TENANT`, `CONTROL`, `M2M`, or `BOOTSTRAP`).
methodTryParseWireCode
public static bool TryParseWireCode(string? raw, out AuditExecutionPlane plane)
Attempts to parse a wire code string into an `AuditExecutionPlane` value.
- raw: string?
- The raw wire code string to parse.
- plane: out AuditExecutionPlane
- When this method returns, contains the parsed `AuditExecutionPlane` if parsing succeeded; otherwise, `AuditExecutionPlane.Unspecified`.
Retorna: `true` if `raw` was successfully parsed; otherwise, `false`.
enum
AuditFailureBehavior
Ensamblado: EricksonLopez.Auditingpublic enum AuditFailureBehavior
Specifies the failure handling policy when persisting an audit record fails.
Miembros (3)
fieldDeferred
Deferred = 3
Enqueues the record for deferred processing via a resilient background mechanism.
fieldFailClosed
FailClosed = 1
Propagates the store exception to the caller, blocking the business operation.
fieldFailOpen
FailOpen = 2
Suppresses the store exception and allows the business operation to proceed.
class
AuditFieldComparer
Ensamblado: EricksonLopez.Auditingpublic static class AuditFieldComparer
Provides deterministic comparison of original and current property values to detect auditable mutations.
Miembros (1)
methodAreDifferent
public static bool AreDifferent(object? originalValue, object? currentValue)
Determines whether the original and current values of an audited field differ.
- originalValue: object?
- The value prior to mutation.
- currentValue: object?
- The value after mutation.
Retorna: `true` if the values differ and should be recorded in the audit trail; otherwise, `false`.
enum
AuditFieldSensitivity
Ensamblado: EricksonLopez.Auditingpublic enum AuditFieldSensitivity
Specifies how sensitive field values are handled in change tracking records.
Miembros (5)
fieldEncrypt
Encrypt = 4
Encrypts the field value using authenticated AES-256-GCM with the subject or tenant key managed by `IAuditCryptoKeyProvider` to support GDPR Art. 17 Crypto-Shredding.
fieldExclude
Exclude = 1
Excludes the field entirely from change tracking records.
fieldHash
Hash = 3
Replaces the field value with its SHA-256 cryptographic digest to support equality comparison without revealing plaintext.
fieldInclude
Include = 0
Records the field value without modification.
fieldRedact
Redact = 2
Records the field name but replaces the value with a redaction indicator.
class
AuditId
Ensamblado: EricksonLopez.Auditingpublic static class AuditId
Provides factory methods for generating time-ordered unique identifiers.
Miembros (1)
methodNewId
public static Guid NewId()
Creates a new time-ordered unique identifier conforming to UUIDv7.
Retorna: A new time-ordered `Guid` identifier.
record
AuditImpersonation
Ensamblado: EricksonLopez.Auditing.Abstractionspublic sealed record AuditImpersonation(string ImpersonatorId, string Justification, string? TicketReference, string? SessionId, AuditActorType ImpersonatorType, string? ImpersonatorDisplayName)
Represents non-repudiable delegated execution or support impersonation metadata attached to an `AuditRecord`.
Miembros (9)
constructorAuditImpersonation
public AuditImpersonation(string ImpersonatorId, string Justification, string? TicketReference = null, string? SessionId = null, AuditActorType ImpersonatorType = AuditActorType.User, string? ImpersonatorDisplayName = null)
Initializes a new instance of AuditImpersonation.
- ImpersonatorId: string
- The stable identifier of the real operator executing the action on behalf of the target `AuditActor`.
- Justification: string
- The mandatory human-readable reason justifying the delegated or impersonated access.
- TicketReference: string?
- The optional verified support ticket or change-management reference authorizing the session.
- SessionId: string?
- The optional bounded impersonation session identifier.
- ImpersonatorType: AuditActorType
- The actor classification of the impersonating operator. Defaults to `AuditActorType.User`.
- ImpersonatorDisplayName: string?
- The optional human-readable display name of the impersonating operator.
methodForSupportSession
public static AuditImpersonation ForSupportSession(string impersonatorId, string ticketReference, string justification, string? sessionId = null, string? impersonatorDisplayName = null)
Creates a delegated support impersonation context requiring both a verified support ticket reference and an explicit justification.
- impersonatorId: string
- The identifier of the platform support operator.
- ticketReference: string
- The verified support ticket reference authorizing access.
- justification: string
- The explicit operational justification for the session.
- sessionId: string?
- The optional bounded impersonation session identifier.
- impersonatorDisplayName: string?
- The optional display name of the support operator.
Retorna: A validated `AuditImpersonation` instance.
methodValidateTarget
public void ValidateTarget(AuditActor targetActor, AuditSecurityClassification targetClassification = AuditSecurityClassification.Standard)
Validates that the impersonation context satisfies security ceiling and anti-self-impersonation invariants for the target actor.
- targetActor: AuditActor
- The impersonated target actor.
- targetClassification: AuditSecurityClassification
- The security classification of the target account or operation.
propertyImpersonatorDisplayName
public string? ImpersonatorDisplayName { get; init; }
The optional human-readable display name of the impersonating operator.
propertyImpersonatorId
public string ImpersonatorId { get; init; }
Gets the stable identifier of the real operator executing the action on behalf of the target actor.
propertyImpersonatorType
public AuditActorType ImpersonatorType { get; init; }
The actor classification of the impersonating operator. Defaults to `AuditActorType.User`.
propertyJustification
public string Justification { get; init; }
Gets the mandatory human-readable reason justifying the delegated or impersonated access.
propertySessionId
public string? SessionId { get; init; }
Gets the optional bounded impersonation session identifier.
propertyTicketReference
public string? TicketReference { get; init; }
Gets the optional verified support ticket or change-management reference authorizing the session.
record
AuditIntegrityVerificationResult
Ensamblado: EricksonLopez.Auditing.Abstractionspublic sealed record AuditIntegrityVerificationResult(bool IsValid, int VerifiedCount, Guid? FirstFailedRecordId, string? FailureReason)
Represents the outcome of an audit chain cryptographic verification operation.
Miembros (5)
constructorAuditIntegrityVerificationResult
public AuditIntegrityVerificationResult(bool IsValid, int VerifiedCount, Guid? FirstFailedRecordId = null, string? FailureReason = null)
Initializes a new instance of AuditIntegrityVerificationResult.
- IsValid: bool
- A value indicating whether all audit records in the range passed integrity verification.
- VerifiedCount: int
- The total number of audit records evaluated during verification.
- FirstFailedRecordId: Guid?
- The identifier of the first record that failed verification, if any; otherwise, `null`.
- FailureReason: string?
- A description of the failure reason if verification failed; otherwise, `null`.
propertyFailureReason
public string? FailureReason { get; init; }
A description of the failure reason if verification failed; otherwise, `null`.
propertyFirstFailedRecordId
public Guid? FirstFailedRecordId { get; init; }
The identifier of the first record that failed verification, if any; otherwise, `null`.
propertyIsValid
public bool IsValid { get; init; }
A value indicating whether all audit records in the range passed integrity verification.
propertyVerifiedCount
public int VerifiedCount { get; init; }
The total number of audit records evaluated during verification.
class
AuditLogger<TCategoryName>
Ensamblado: EricksonLopez.Auditingpublic sealed class AuditLogger<TCategoryName> : IAuditLogger<TCategoryName>
Implementa: IAuditLogger<TCategoryName>
Provides an implementation of `IAuditLogger<TCategoryName>` that constructs, enriches, and appends `AuditRecord` instances.
Miembros (2)
constructorAuditLogger
public AuditLogger(IAuditStore store, IAuditActorProvider actorProvider, IAuditContextProvider? contextProvider = null, IEnumerable<IAuditEnricher>? enrichers = null, TimeProvider? timeProvider = null)
Initializes a new instance of the `AuditLogger<TCategoryName>` class.
- store: IAuditStore
- The store used to persist audit records.
- actorProvider: IAuditActorProvider
- The provider to resolve the current actor.
- contextProvider: IAuditContextProvider?
- The optional provider to resolve ambient context.
- enrichers: IEnumerable<IAuditEnricher>?
- The optional sequence of enrichers to augment audit records before persistence.
- timeProvider: TimeProvider?
- The optional deterministic `TimeProvider`. Defaults to `TimeProvider.System` when `null`.
methodLogAsync
public async ValueTask LogAsync(AuditAction action, AuditResource resource, AuditOutcome outcome, CancellationToken cancellationToken = default)
Logs an audit event asynchronously.
- action: AuditAction
- The operation that was executed.
- resource: AuditResource
- The target resource on which the operation was performed.
- outcome: AuditOutcome
- The observable result of the operation.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation.
class
AuditMerkleTree
Ensamblado: EricksonLopez.Auditing.Abstractionspublic static class AuditMerkleTree
Provides deterministic, second-preimage-resistant binary SHA-256 Merkle tree root computation and constant-time batch integrity verification for sealed audit batches.
Miembros (2)
methodComputeRoot
public static string? ComputeRoot(IReadOnlyList<string> recordHashes)
Computes the deterministic binary SHA-256 Merkle root over an ordered sequence of audit record hashes.
- recordHashes: IReadOnlyList<string>
- The ordered sequence of non-empty record integrity hashes.
Retorna: The lowercase 64-character hexadecimal SHA-256 Merkle root, or `null` if `recordHashes` is empty.
methodVerifyRoot
public static bool VerifyRoot(IReadOnlyList<string> recordHashes, string? expectedMerkleRoot)
Verifies in constant time whether the recomputed Merkle root for the specified ordered hashes matches the expected sealed Merkle root.
- recordHashes: IReadOnlyList<string>
- The ordered sequence of record integrity hashes in the batch.
- expectedMerkleRoot: string?
- The expected sealed 64-character hexadecimal Merkle root.
Retorna: `true` if the batch hashes are non-empty and match `expectedMerkleRoot`; otherwise, `false`.
enum
AuditOutcome
Ensamblado: EricksonLopez.Auditing.Abstractionspublic enum AuditOutcome : byte
Specifies the observable result of an audited action.
Miembros (5)
fieldCancelled
Cancelled = 4
Specifies that the action was cancelled before completion.
fieldDenied
Denied = 3
Specifies that the action was rejected due to insufficient permissions.
fieldFailure
Failure = 2
Specifies that the action failed due to a runtime or validation error.
fieldPartial
Partial = 5
Specifies that the action completed partially with mixed results.
fieldSuccess
Success = 1
Specifies that the action completed successfully.
record
AuditQuery
Ensamblado: EricksonLopez.Auditing.Abstractionspublic sealed record AuditQuery
Represents filtering and keyset pagination parameters for querying persisted audit records.
Miembros (17)
propertyActionCode
public string? ActionCode { get; init; }
Gets the optional action code filter.
propertyActorId
public string? ActorId { get; init; }
Gets the optional actor identifier filter.
propertyContinuationToken
public string? ContinuationToken { get; init; }
Gets the optional keyset continuation cursor indicating the exact page cutoff point from the previous page.
propertyCorrelationId
public string? CorrelationId { get; init; }
Gets the optional correlation identifier filter.
propertyExecutionPlane
public AuditExecutionPlane? ExecutionPlane { get; init; }
Gets the optional security execution plane filter.
propertyFrom
public DateTimeOffset? From { get; init; }
Gets the optional earliest occurrence timestamp filter, inclusive.
propertyImpersonatorId
public string? ImpersonatorId { get; init; }
Gets the optional delegated support or impersonating operator identifier filter.
propertyIncludeTotalCount
public bool IncludeTotalCount { get; init; }
Gets a value indicating whether the query should compute and return the total count of matching records in `AuditQueryResult.TotalCount`. Defaults to `false` to preserve $O(1)$ keyset pagination performance.
propertyOrganizationId
public string? OrganizationId { get; init; }
Gets the optional sub-tenant organization or company identifier filter.
propertyOutcome
public AuditOutcome? Outcome { get; init; }
Gets the optional outcome status filter.
propertyPageSize
public int PageSize { get; init; }
Gets the maximum number of records to return in a single page.
propertyResourceId
public string? ResourceId { get; init; }
Gets the optional resource identifier filter.
propertyResourceType
public string? ResourceType { get; init; }
Gets the optional resource type filter.
propertySecurityClassification
public AuditSecurityClassification? SecurityClassification { get; init; }
Gets the optional security criticality classification filter.
propertySortDirection
public AuditSortDirection SortDirection { get; init; }
Gets the chronological sort direction for the query. Defaults to `AuditSortDirection.Ascending`.
propertyTenantId
public required TenantId TenantId { get; init; }
Gets the tenant identifier scoping the query.
propertyTo
public DateTimeOffset? To { get; init; }
Gets the optional latest occurrence timestamp filter, inclusive.
record
AuditQueryResult
Ensamblado: EricksonLopez.Auditing.Abstractionspublic sealed record AuditQueryResult(IReadOnlyList<AuditRecord> Records, string? NextPageToken, bool HasMore, long? TotalCount)
Represents the paginated results of an audit record query operation.
Miembros (5)
constructorAuditQueryResult
public AuditQueryResult(IReadOnlyList<AuditRecord> Records, string? NextPageToken, bool HasMore, long? TotalCount = null)
Initializes a new instance of AuditQueryResult.
- Records: IReadOnlyList<AuditRecord>
- The collection of matching audit records returned for this page.
- NextPageToken: string?
- The continuation token to supply as `AuditQuery.ContinuationToken` for the next page, or `null` if on the final page.
- HasMore: bool
- A value indicating whether additional matching records exist beyond the current page.
- TotalCount: long?
- The optional total number of matching records across all pages when `AuditQuery.IncludeTotalCount` is `true`; otherwise `null`.
propertyHasMore
public bool HasMore { get; init; }
A value indicating whether additional matching records exist beyond the current page.
propertyNextPageToken
public string? NextPageToken { get; init; }
The continuation token to supply as `AuditQuery.ContinuationToken` for the next page, or `null` if on the final page.
propertyRecords
public IReadOnlyList<AuditRecord> Records { get; init; }
The collection of matching audit records returned for this page.
propertyTotalCount
public long? TotalCount { get; init; }
The optional total number of matching records across all pages when `AuditQuery.IncludeTotalCount` is `true`; otherwise `null`.
record
AuditRecord
Ensamblado: EricksonLopez.Auditing.Abstractionspublic sealed record AuditRecord
Represents the canonical, immutable evidence record of an audited event.
Miembros (13)
propertyAction
public required AuditAction Action { get; init; }
Gets the operation that was executed.
propertyActor
public required AuditActor Actor { get; init; }
Gets the identity that performed the action.
propertyChanges
public IReadOnlyList<AuditChange>? Changes { get; init; }
Gets the optional collection of field-level changes captured during the action.
propertyContext
public required AuditContext Context { get; init; }
Gets the technical execution context at the time of the action.
propertyErrorCode
public string? ErrorCode { get; init; }
Gets the optional error category or code when the outcome is unsuccessful.
propertyId
public required Guid Id { get; init; }
Gets the unique, time-ordered identifier of this record.
propertyImpersonation
public AuditImpersonation? Impersonation { get; init; }
Gets the optional delegated execution or support impersonation metadata when an operator acts on behalf of another actor.
propertyIntegrityHash
public string? IntegrityHash { get; init; }
Gets the optional cryptographic HMAC hash computed for this record and chained to previous records.
propertyOccurredAt
public required DateTimeOffset OccurredAt { get; init; }
Gets the exact UTC timestamp when the action occurred.
propertyOutcome
public required AuditOutcome Outcome { get; init; }
Gets the observable result of the operation.
propertyPreviousHash
public string? PreviousHash { get; init; }
Gets the optional cryptographic hash of the immediately preceding record in the chain.
propertyResource
public required AuditResource Resource { get; init; }
Gets the target resource on which the operation was performed.
propertySecurityClassification
public AuditSecurityClassification SecurityClassification { get; init; }
Gets the security criticality and privilege tier of this audit record. Defaults to `AuditSecurityClassification.Standard`.
class
AuditRecordBuilder
Ensamblado: EricksonLopez.Auditingpublic sealed class AuditRecordBuilder
Provides a fluent builder for constructing immutable `AuditRecord` instances.
Miembros (36)
methodAddChange
public AuditRecordBuilder AddChange(string field, string? oldValue, string? newValue, bool isRedacted = false)
Adds a property modification change.
- field: string
- The property name.
- oldValue: string?
- The original value.
- newValue: string?
- The updated value.
- isRedacted: bool
- Indicates whether the change is redacted.
Retorna: The builder instance.
methodAddRedactedChange
public AuditRecordBuilder AddRedactedChange(string field)
Adds a redacted property change.
- field: string
- The property name.
Retorna: The builder instance.
methodAsBreakGlassActivity
public AuditRecordBuilder AsBreakGlassActivity(AuditExecutionPlane plane = AuditExecutionPlane.Control)
Marks the audit record as emergency `BreakGlass` principal activity.
- plane: AuditExecutionPlane
- The execution plane. Defaults to `AuditExecutionPlane.Control`.
Retorna: The builder instance.
methodAsGenesisActivity
public AuditRecordBuilder AsGenesisActivity(AuditExecutionPlane plane = AuditExecutionPlane.Control)
Marks the audit record as root `GENESIS` identity activity on the control or bootstrap plane.
- plane: AuditExecutionPlane
- The execution plane. Defaults to `AuditExecutionPlane.Control`.
Retorna: The builder instance.
methodBuild
public AuditRecord Build()
Builds the immutable `AuditRecord` instance, propagating ambient `AuditScope.Current` values where not explicitly overridden.
Retorna: A constructed `AuditRecord`.
methodBuildDefault
public static AuditRecord BuildDefault(string tenantId = "", string actorId = "", string resourceType = "", string resourceId = "", AuditOutcome outcome = AuditOutcome.Success, string? correlationId = null)
Creates a pre-configured `AuditRecord` instance with optional field overrides.
- tenantId: string
- The tenant identifier.
- actorId: string
- The actor identifier.
- resourceType: string
- The resource type.
- resourceId: string
- The resource identifier.
- outcome: AuditOutcome
- The outcome status.
- correlationId: string?
- The optional correlation identifier.
Retorna: A new `AuditRecord` instance with the specified values.
methodCreate
public static AuditRecordBuilder Create()
Creates a new instance of the `AuditRecordBuilder` class.
Retorna: A new `AuditRecordBuilder` instance.
methodWithAction
public AuditRecordBuilder WithAction(AuditAction action)
Sets the action that was performed.
- action: AuditAction
- The audit action.
Retorna: The builder instance.
methodWithAction
public AuditRecordBuilder WithAction(string code)
Sets the action code that was performed.
- code: string
- The action code.
Retorna: The builder instance.
methodWithActor
public AuditRecordBuilder WithActor(AuditActor actor)
Sets the actor that executed the action.
- actor: AuditActor
- The actor details.
Retorna: The builder instance.
methodWithActor
public AuditRecordBuilder WithActor(AuditActorType type, string id, string? displayName = null)
Sets the actor details that executed the action.
- type: AuditActorType
- The actor type classification.
- id: string
- The actor identifier.
- displayName: string?
- The optional actor display name.
Retorna: The builder instance.
methodWithCausationId
public AuditRecordBuilder WithCausationId(string? causationId)
Sets the causation identifier.
- causationId: string?
- The causation identifier.
Retorna: The builder instance.
methodWithChanges
public AuditRecordBuilder WithChanges(IEnumerable<AuditChange>? changes)
Sets the complete changes collection.
- changes: IEnumerable<AuditChange>?
- The changes collection.
Retorna: The builder instance.
methodWithCorrelationId
public AuditRecordBuilder WithCorrelationId(string? correlationId)
Sets the correlation identifier.
- correlationId: string?
- The correlation identifier.
Retorna: The builder instance.
methodWithErrorCode
public AuditRecordBuilder WithErrorCode(string? errorCode)
Sets the error code if outcome is a failure.
- errorCode: string?
- The error code.
Retorna: The builder instance.
methodWithExecutionPlane
public AuditRecordBuilder WithExecutionPlane(AuditExecutionPlane executionPlane)
Sets the security execution plane (`CONTROL`, `TENANT`, `M2M`, or `BOOTSTRAP`).
- executionPlane: AuditExecutionPlane
- The execution plane classification.
Retorna: The builder instance.
methodWithId
public AuditRecordBuilder WithId(Guid id)
Sets the unique identifier for the audit record.
- id: Guid
- The unique identifier.
Retorna: The builder instance.
methodWithIdempotencyKey
public AuditRecordBuilder WithIdempotencyKey(string? idempotencyKey)
Sets the idempotency key for deduplicating retry attempts.
- idempotencyKey: string?
- The idempotency key.
Retorna: The builder instance.
methodWithImpersonation
public AuditRecordBuilder WithImpersonation(AuditImpersonation? impersonation)
Sets the delegated execution or support impersonation metadata.
- impersonation: AuditImpersonation?
- The impersonation context, or `null` to clear.
Retorna: The builder instance.
methodWithIntegrityHash
public AuditRecordBuilder WithIntegrityHash(string? hash, string? previousHash = null)
Sets the cryptographic integrity hash.
- hash: string?
- The HMAC hash.
- previousHash: string?
- The optional preceding hash in the chain.
Retorna: The builder instance.
methodWithIpAddress
public AuditRecordBuilder WithIpAddress(string? ipAddress)
Sets the client IP address.
- ipAddress: string?
- The client IP address.
Retorna: The builder instance.
methodWithMetadata
public AuditRecordBuilder WithMetadata(IReadOnlyDictionary<string, string>? metadata)
Sets the context metadata dictionary.
- metadata: IReadOnlyDictionary<string, string>?
- The metadata entries to include.
Retorna: The builder instance.
methodWithMetadata
public AuditRecordBuilder WithMetadata(string key, string value)
Adds or updates a context metadata key-value entry.
- key: string
- The metadata key.
- value: string
- The metadata value.
Retorna: The builder instance.
methodWithOccurredAt
public AuditRecordBuilder WithOccurredAt(DateTimeOffset occurredAt)
Sets the UTC timestamp when the action occurred.
- occurredAt: DateTimeOffset
- The occurrence timestamp.
Retorna: The builder instance.
methodWithOrganizationId
public AuditRecordBuilder WithOrganizationId(string? organizationId)
Sets the optional hierarchical sub-tenant organization or company identifier.
- organizationId: string?
- The organization or company identifier.
Retorna: The builder instance.
methodWithOutcome
public AuditRecordBuilder WithOutcome(AuditOutcome outcome)
Sets the outcome of the audited action.
- outcome: AuditOutcome
- The outcome classification.
Retorna: The builder instance.
methodWithPreviousHash
public AuditRecordBuilder WithPreviousHash(string? previousHash)
Sets the cryptographic hash of the preceding record in the chain.
- previousHash: string?
- The previous record hash to set.
Retorna: The builder instance.
methodWithRequestId
public AuditRecordBuilder WithRequestId(string? requestId)
Sets the request identifier.
- requestId: string?
- The request identifier.
Retorna: The builder instance.
methodWithResource
public AuditRecordBuilder WithResource(AuditResource resource)
Sets the target resource.
- resource: AuditResource
- The audit resource.
Retorna: The builder instance.
methodWithResource
public AuditRecordBuilder WithResource(string type, string id, string? aggregateType = null, string? aggregateId = null)
Sets the target resource details.
- type: string
- The resource type.
- id: string
- The resource identifier.
- aggregateType: string?
- The optional aggregate root type.
- aggregateId: string?
- The optional aggregate root identifier.
Retorna: The builder instance.
methodWithSecurityClassification
public AuditRecordBuilder WithSecurityClassification(AuditSecurityClassification classification)
Sets the security criticality classification of the audit record.
- classification: AuditSecurityClassification
- The security classification.
Retorna: The builder instance.
methodWithSource
public AuditRecordBuilder WithSource(string source)
Sets the system or component source name.
- source: string
- The source identifier.
Retorna: The builder instance.
methodWithSupportImpersonation
public AuditRecordBuilder WithSupportImpersonation(string impersonatorId, string ticketReference, string justification, string? sessionId = null, string? impersonatorDisplayName = null)
Configures a delegated support impersonation context requiring a verified ticket reference and justification.
- impersonatorId: string
- The support operator identifier.
- ticketReference: string
- The verified support ticket reference.
- justification: string
- The mandatory justification for the support session.
- sessionId: string?
- The optional bounded session identifier.
- impersonatorDisplayName: string?
- The optional support operator display name.
Retorna: The builder instance.
methodWithTenant
public AuditRecordBuilder WithTenant(string tenantId)
Sets the tenant identifier.
- tenantId: string
- The tenant identifier.
Retorna: The builder instance.
methodWithTimeProvider
public AuditRecordBuilder WithTimeProvider(TimeProvider timeProvider)
Sets the UTC timestamp using the specified `TimeProvider`, honoring active `AmbientAuditTimeProvider` scopes.
- timeProvider: TimeProvider
- The deterministic time provider to sample.
Retorna: The builder instance.
methodWithUserAgent
public AuditRecordBuilder WithUserAgent(string? userAgent)
Sets the user agent string.
- userAgent: string?
- The client user agent string.
Retorna: The builder instance.
record
AuditResource
Ensamblado: EricksonLopez.Auditing.Abstractionspublic sealed record AuditResource(string Type, string Id, string? AggregateType, string? AggregateId)
Represents the target resource on which an audited action was performed.
Miembros (5)
constructorAuditResource
public AuditResource(string Type, string Id, string? AggregateType = null, string? AggregateId = null)
Initializes a new instance of AuditResource.
- Type: string
- The logical type or entity class of the resource.
- Id: string
- The stable identifier of the specific resource instance.
- AggregateType: string?
- The optional aggregate root entity type when the resource is a child entity.
- AggregateId: string?
- The optional identifier of the aggregate root entity.
propertyAggregateId
public string? AggregateId { get; init; }
The optional identifier of the aggregate root entity.
propertyAggregateType
public string? AggregateType { get; init; }
The optional aggregate root entity type when the resource is a child entity.
propertyId
public string Id { get; init; }
Gets the stable identifier of the specific resource instance.
propertyType
public string Type { get; init; }
Gets the logical type or entity class of the resource.
class
AuditScope
Ensamblado: EricksonLopez.Auditingpublic sealed class AuditScope : IDisposable
Implementa: IDisposable
Provides an ambient scope for enriching audit records with additional context.
Miembros (32)
methodBegin
public static AuditScope Begin(IReadOnlyDictionary<string, string>? initialMetadata = null)
Begins a new ambient audit scope with optional initial metadata.
- initialMetadata: IReadOnlyDictionary<string, string>?
- The optional initial key-value metadata to seed into the new scope.
Retorna: A new `AuditScope` instance. Disposing it restores the enclosing scope.
methodDispose
public void Dispose()
Inherits documentation from base type or interface.
methodWithActor
public AuditScope WithActor(AuditActor actor)
Sets the ambient actor for this scope.
- actor: AuditActor
- The actor to associate with this scope.
Retorna: The current `AuditScope` instance for method chaining.
methodWithCausationId
public AuditScope WithCausationId(string causationId)
Sets the ambient causation identifier for this scope.
- causationId: string
- The causation identifier to associate with this scope.
Retorna: The current `AuditScope` instance for method chaining.
methodWithCorrelationId
public AuditScope WithCorrelationId(string correlationId)
Sets the ambient correlation identifier for this scope.
- correlationId: string
- The correlation identifier to associate with this scope.
Retorna: The current `AuditScope` instance for method chaining.
methodWithExecutionPlane
public AuditScope WithExecutionPlane(AuditExecutionPlane executionPlane)
Sets the ambient security execution plane (`CONTROL`, `TENANT`, `M2M`, or `BOOTSTRAP`) for this scope.
- executionPlane: AuditExecutionPlane
- The security execution plane to associate with this scope.
Retorna: The current `AuditScope` instance for method chaining.
methodWithImpersonation
public AuditScope WithImpersonation(AuditImpersonation impersonation, bool allowOverride = false)
Sets the ambient delegated support impersonation context for this scope, enforcing the anti-nested-impersonation security invariant by default.
- impersonation: AuditImpersonation
- The delegated impersonation context.
- allowOverride: bool
- If `false` (the default), throws `InvalidOperationException` when an enclosing scope already carries a conflicting active impersonation session.
Retorna: The current `AuditScope` instance for method chaining.
methodWithMetadata
public AuditScope WithMetadata(string key, string value)
Adds or updates a metadata entry within this scope in a thread-safe manner.
- key: string
- The metadata key to set.
- value: string
- The metadata value to associate with the specified key.
Retorna: The current `AuditScope` instance for method chaining.
methodWithOrganizationId
public AuditScope WithOrganizationId(string organizationId)
Sets the ambient sub-tenant organization or company identifier for this scope.
- organizationId: string
- The non-empty organization or company identifier.
Retorna: The current `AuditScope` instance for method chaining.
methodWithSecurityClassification
public AuditScope WithSecurityClassification(AuditSecurityClassification classification)
Sets the ambient security criticality classification for this scope.
- classification: AuditSecurityClassification
- The security classification to associate with this scope.
Retorna: The current `AuditScope` instance for method chaining.
methodWithTenant
public AuditScope WithTenant(string tenantId)
Sets the ambient tenant identifier for this scope.
- tenantId: string
- The tenant identifier string to associate with this scope.
Retorna: The current `AuditScope` instance for method chaining.
methodWithTenant
public AuditScope WithTenant(TenantId tenantId)
Sets the ambient tenant identifier for this scope.
- tenantId: TenantId
- The tenant identifier to associate with this scope.
Retorna: The current `AuditScope` instance for method chaining.
propertyActor
public AuditActor? Actor { get; }
Gets the actor explicitly set on this scope, or `null`.
propertyCausationId
public string? CausationId { get; }
Gets the causation identifier explicitly set on this scope, or `null`.
propertyCorrelationId
public string? CorrelationId { get; }
Gets the correlation identifier explicitly set on this scope, or `null`.
propertyCurrent
public static AuditScope? Current { get; }
Gets the current ambient `AuditScope`, or `null` if none is active.
propertyEffectiveActor
public AuditActor? EffectiveActor { get; }
Gets the effective actor resolved from this scope or the nearest enclosing parent scope.
propertyEffectiveCausationId
public string? EffectiveCausationId { get; }
Gets the effective causation identifier resolved from this scope or the nearest enclosing parent scope.
propertyEffectiveCorrelationId
public string? EffectiveCorrelationId { get; }
Gets the effective correlation identifier resolved from this scope or the nearest enclosing parent scope.
propertyEffectiveExecutionPlane
public AuditExecutionPlane? EffectiveExecutionPlane { get; }
Gets the effective security execution plane resolved from this scope, scope metadata, or the nearest enclosing parent scope.
propertyEffectiveImpersonation
public AuditImpersonation? EffectiveImpersonation { get; }
Gets the effective delegated support impersonation context resolved from this scope or the nearest enclosing parent scope.
propertyEffectiveMetadata
public IReadOnlyDictionary<string, string> EffectiveMetadata { get; }
Gets the effective metadata key-value pairs merged hierarchically from all enclosing parent scopes down to this scope, with child scope entries overriding parent scope entries of the same key.
propertyEffectiveOrganizationId
public string? EffectiveOrganizationId { get; }
Gets the effective sub-tenant organization identifier resolved from this scope, scope metadata, or the nearest enclosing parent scope.
propertyEffectiveSecurityClassification
public AuditSecurityClassification? EffectiveSecurityClassification { get; }
Gets the effective security criticality classification resolved from this scope or the nearest enclosing parent scope.
propertyEffectiveTenantId
public TenantId? EffectiveTenantId { get; }
Gets the effective tenant identifier resolved from this scope or the nearest enclosing parent scope.
propertyExecutionPlane
public AuditExecutionPlane? ExecutionPlane { get; }
Gets the security execution plane explicitly set on this scope, or `null`.
propertyImpersonation
public AuditImpersonation? Impersonation { get; }
Gets the delegated support impersonation context explicitly set on this scope, or `null`.
propertyMetadata
public IReadOnlyDictionary<string, string> Metadata { get; }
Gets the metadata key-value pairs registered directly within this scope.
propertyOrganizationId
public string? OrganizationId { get; }
Gets the sub-tenant organization or company identifier explicitly set on this scope, or `null`.
propertyParent
public AuditScope? Parent { get; }
Gets the parent `AuditScope`, or `null` if this is a root scope.
propertySecurityClassification
public AuditSecurityClassification? SecurityClassification { get; }
Gets the security criticality classification explicitly set on this scope, or `null`.
propertyTenantId
public TenantId? TenantId { get; }
Gets the tenant identifier explicitly set on this scope, or `null`.
record
AuditSecurityAlert
Ensamblado: EricksonLopez.Auditing.Abstractionspublic sealed record AuditSecurityAlert(Guid AlertId, AuditSecuritySeverity Severity, string AlertCode, string Summary, AuditRecord Record, DateTimeOffset EmittedAt)
Represents an immutable real-time security alert emitted when high-criticality audit records are recorded.
Miembros (7)
constructorAuditSecurityAlert
public AuditSecurityAlert(Guid AlertId, AuditSecuritySeverity Severity, string AlertCode, string Summary, AuditRecord Record, DateTimeOffset EmittedAt)
Initializes a new instance of AuditSecurityAlert.
- AlertId: Guid
- The unique monotonic identifier of the security alert.
- Severity: AuditSecuritySeverity
- The operational severity of the alert.
- AlertCode: string
- The machine-readable classification code of the alert (for example, `GENESIS_ACCOUNT_ACTIVITY`).
- Summary: string
- The human-readable summary describing why the alert was triggered without exposing sensitive secrets.
- Record: AuditRecord
- The canonical `AuditRecord` that triggered the alert.
- EmittedAt: DateTimeOffset
- The UTC timestamp when the alert was emitted.
propertyAlertCode
public string AlertCode { get; init; }
Gets the machine-readable classification code of the alert.
propertyAlertId
public Guid AlertId { get; init; }
The unique monotonic identifier of the security alert.
propertyEmittedAt
public DateTimeOffset EmittedAt { get; init; }
The UTC timestamp when the alert was emitted.
propertyRecord
public AuditRecord Record { get; init; }
Gets the canonical `AuditRecord` that triggered the alert.
propertySeverity
public AuditSecuritySeverity Severity { get; init; }
The operational severity of the alert.
propertySummary
public string Summary { get; init; }
Gets the human-readable summary describing why the alert was triggered.
enum
AuditSecurityClassification
Ensamblado: EricksonLopez.Auditing.Abstractionspublic enum AuditSecurityClassification : byte
Specifies the security criticality and privilege tier of an audited event or principal.
Miembros (5)
fieldBreakGlass
BreakGlass = 3
Specifies an emergency break-glass access event requiring non-droppable persistence and immediate security review.
fieldGenesis
Genesis = 4
Specifies an operation involving the root `GENESIS` identity requiring mandatory fail-closed persistence and critical security alerting.
fieldPrivilegedControl
PrivilegedControl = 2
Specifies a privileged platform control-plane or delegated support administration event.
fieldSecuritySensitive
SecuritySensitive = 1
Specifies a security-sensitive operation such as authentication, MFA, credential lifecycle, or permission change.
fieldStandard
Standard = 0
Specifies a routine operational business or data mutation event.
enum
AuditSecuritySeverity
Ensamblado: EricksonLopez.Auditing.Abstractionspublic enum AuditSecuritySeverity : byte
Specifies the operational severity level of an emitted `AuditSecurityAlert`.
Miembros (4)
fieldCritical
Critical = 3
Specifies a critical security alert such as root `GENESIS` or `BreakGlass` principal activity.
fieldHigh
High = 2
Specifies a high-severity security alert such as bootstrap plane modification or emergency access.
fieldInformational
Informational = 0
Specifies an informational security notification.
fieldWarning
Warning = 1
Specifies an elevated security warning such as a denied sensitive action or delegated support session.
class
AuditSensitiveAttribute
Ensamblado: EricksonLopez.Auditing.Abstractionspublic sealed class AuditSensitiveAttribute : Attribute
Hereda de: Attribute
Indicates that a property, field, or parameter contains sensitive credentials, tokens, or PII that must be redacted from audit change values and diagnostic payloads.
Miembros (2)
constructorAuditSensitiveAttribute
public AuditSensitiveAttribute(string? classification = null)
Initializes a new instance of the `AuditSensitiveAttribute` class.
- classification: string?
- An optional non-sensitive label classifying the protected datum (for example, `Credential`, `MfaSecret`, or `Pii`).
propertyClassification
public string? Classification { get; }
Gets the optional classification label describing the category of sensitive data.
class
AuditSensitivityPipeline
Ensamblado: EricksonLopez.Auditingpublic sealed class AuditSensitivityPipeline : IAuditSensitivityPipeline
Implementa: IAuditSensitivityPipeline
Provides a pipeline that filters change tracking records and context metadata to suppress, redact, or hash sensitive field values according to configured policies.
Miembros (8)
constructorAuditSensitivityPipeline
public AuditSensitivityPipeline(AuditConfiguration config, IAuditCryptoKeyProvider? keyProvider = null, IAuditFieldEncryptor? fieldEncryptor = null)
Initializes a new instance of the `AuditSensitivityPipeline` class.
- config: AuditConfiguration
- The audit configuration containing sensitivity policies.
- keyProvider: IAuditCryptoKeyProvider?
- The optional crypto key provider for GDPR crypto-shredding.
- fieldEncryptor: IAuditFieldEncryptor?
- The optional field encryptor for GDPR crypto-shredding.
methodApplyAsync
public async ValueTask<IReadOnlyList<AuditChange>?> ApplyAsync(IReadOnlyList<AuditChange>? changes, string tenantId, CancellationToken cancellationToken = default)
Applies sensitivity policies to a collection of field changes, returning a sanitized collection.
- changes: IReadOnlyList<AuditChange>?
- The raw collection of field changes to process.
- tenantId: string
- The tenant ID to use for fetching encryption keys.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the sanitized collection of changes, or `null` if all changes were excluded or the input was `null`.
methodHashValue
public static string HashValue(string value, string? salt = null)
Calculates the lowercase hexadecimal SHA-256 digest of the specified string value, with optional cryptographic salt.
- value: string
- The plaintext string value to hash.
- salt: string?
- The optional salt to prevent rainbow table attacks on low-entropy values.
Retorna: The lowercase hexadecimal SHA-256 digest of the input string.
methodIsSensitiveFieldName
public bool IsSensitiveFieldName(string? fieldName)
Determines whether the specified field or metadata key matches the configured denylist or canonical credential/secret naming patterns.
- fieldName: string?
- The property, field, or metadata key name to evaluate.
Retorna: `true` if the key is classified as sensitive; otherwise, `false`.
methodSanitizeAsync
public async ValueTask<AuditRecord> SanitizeAsync(AuditRecord record, CancellationToken cancellationToken = default)
Sanitizes the specified audit record by applying redaction or exclusions to sensitive fields.
- record: AuditRecord
- The audit record to sanitize.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the sanitized audit record.
propertyFieldEncryptor
public IAuditFieldEncryptor? FieldEncryptor { get; }
Gets the optional field encryptor configured for GDPR crypto-shredding.
propertyKeyProvider
public IAuditCryptoKeyProvider? KeyProvider { get; }
Gets the optional crypto key provider configured for GDPR crypto-shredding.
fieldRedactedLiteral
public const string RedactedLiteral
Gets the canonical redaction placeholder literal substituted for sensitive metadata entries.
enum
AuditSortDirection
Ensamblado: EricksonLopez.Auditing.Abstractionspublic enum AuditSortDirection : byte
Specifies the chronological sorting direction for audit record queries.
record
AuditStamp
Ensamblado: EricksonLopez.Auditing.Abstractionspublic readonly record struct AuditStamp(string ActorId, DateTimeOffset Timestamp, string? ImpersonatorId, AuditExecutionPlane ExecutionPlane)
Represents an immutable point-in-time entity audit stamp resolved from deterministic time and ambient principal context.
Miembros (7)
constructorAuditStamp
public AuditStamp(string ActorId, DateTimeOffset Timestamp, string? ImpersonatorId = null, AuditExecutionPlane ExecutionPlane = AuditExecutionPlane.Unspecified)
Initializes a new instance of AuditStamp.
- ActorId: string
- The identifier of the target or subject actor.
- Timestamp: DateTimeOffset
- The deterministic UTC timestamp of the persistence operation.
- ImpersonatorId: string?
- The optional identifier of the operator performing delegated impersonation.
- ExecutionPlane: AuditExecutionPlane
- The security execution plane active at the time of stamping.
propertyActorId
public string ActorId { get; init; }
The identifier of the target or subject actor.
propertyEffectiveOperatorId
public string EffectiveOperatorId { get; }
Gets the physical operator identifier (`ImpersonatorId` when impersonated; otherwise, `ActorId`).
propertyExecutionPlane
public AuditExecutionPlane ExecutionPlane { get; init; }
The security execution plane active at the time of stamping.
propertyImpersonatorId
public string? ImpersonatorId { get; init; }
The optional identifier of the operator performing delegated impersonation.
propertyIsImpersonated
public bool IsImpersonated { get; }
Gets a value indicating whether the stamp was captured during an active delegated impersonation session.
propertyTimestamp
public DateTimeOffset Timestamp { get; init; }
The deterministic UTC timestamp of the persistence operation.
class
AuditingServiceCollectionExtensions
Ensamblado: EricksonLopez.Auditingpublic static class AuditingServiceCollectionExtensions
Provides extension methods for registering core auditing services into an `IServiceCollection`.
Miembros (5)
methodAddAuditing
public static IAuditBuilder AddAuditing(this IServiceCollection services, Action<AuditConfiguration>? configure = null)
Adds core auditing services, configuration, pipeline, entity stamper, and default providers to the service collection.
- services: this IServiceCollection
- The service collection to register into.
- configure: Action<AuditConfiguration>?
- An optional action to configure auditing policies.
Retorna: An `IAuditBuilder` instance for configuring storage and providers.
methodAddSecurityAlertSink<TSink>
public static IAuditBuilder AddSecurityAlertSink<TSink>(this IAuditBuilder builder) where TSink : class, IAuditSecurityAlertSink
Registers an `IAuditSecurityAlertSink` implementation and automatically enables real-time security alerting.
- builder: this IAuditBuilder
- The audit builder being configured.
Retorna: The `IAuditBuilder` instance for fluent method chaining.
methodApplyDecorators
public static IAuditBuilder ApplyDecorators(this IAuditBuilder builder)
Applies any pending decorators (HMAC integrity verification, security alerting, high-throughput buffering) to the registered audit store.
- builder: this IAuditBuilder
- The audit builder being configured.
Retorna: The `IAuditBuilder` instance for fluent method chaining.
methodEnableBuffering
public static IAuditBuilder EnableBuffering(this IAuditBuilder builder, Action<BufferedAuditStoreOptions>? configure = null)
Decorates the registered `IAuditStore` with a high-throughput asynchronous batching buffer (`BufferedAuditStoreDecorator`).
- builder: this IAuditBuilder
- The audit builder being configured.
- configure: Action<BufferedAuditStoreOptions>?
- An optional configuration delegate to customize buffer capacity, batch size, and flush interval.
Retorna: The `IAuditBuilder` instance for fluent method chaining.
methodEnableSecurityAlerts
public static IAuditBuilder EnableSecurityAlerts(this IAuditBuilder builder)
Enables real-time security alerting via `SecurityAlertAuditStoreDecorator` for `GENESIS`, `BreakGlass`, `BOOTSTRAP` plane, and delegated support impersonation records.
- builder: this IAuditBuilder
- The audit builder being configured.
Retorna: The `IAuditBuilder` instance for fluent method chaining.
class
BufferedAuditStoreDecorator
Ensamblado: EricksonLopez.Auditingpublic sealed partial class BufferedAuditStoreDecorator : IAuditStore, IAsyncDisposable, IDisposable
Implementa: IAsyncDisposable, IAuditStore, IDisposable
Provides high-throughput asynchronous batching for an `IAuditStore` using tenant-partitioned bounded channels, background drain workers, and AES-256-GCM Dead-Letter Queue support.
Miembros (9)
constructorBufferedAuditStoreDecorator
public BufferedAuditStoreDecorator(IAuditStore innerStore, BufferedAuditStoreOptions? options = null, ILogger<BufferedAuditStoreDecorator>? logger = null, IAuditSensitivityPipeline? sensitivityPipeline = null)
Initializes a new instance of the `BufferedAuditStoreDecorator` class.
- innerStore: IAuditStore
- The underlying audit store where batches are persisted.
- options: BufferedAuditStoreOptions?
- Optional buffer configuration options.
- logger: ILogger<BufferedAuditStoreDecorator>?
- Optional logger for background worker diagnostics.
- sensitivityPipeline: IAuditSensitivityPipeline?
- Optional sensitivity pipeline executed before buffering records.
methodAppendAsync
public async ValueTask AppendAsync(AuditRecord record, CancellationToken cancellationToken = default)
Inherits documentation from base type or interface.
- record: AuditRecord
- cancellationToken: CancellationToken
methodAppendBatchAsync
public async ValueTask AppendBatchAsync(IReadOnlyList<AuditRecord> records, CancellationToken cancellationToken = default)
Inherits documentation from base type or interface.
- records: IReadOnlyList<AuditRecord>
- cancellationToken: CancellationToken
methodDecryptDeadLetterBatch
public static List<AuditRecord> DecryptDeadLetterBatch(ReadOnlySpan<byte> encryptedPayload, ReadOnlySpan<byte> key)
Decrypts and authenticates an AES-256-GCM Dead-Letter Queue payload back into audit records.
- encryptedPayload: ReadOnlySpan<byte>
- The encrypted byte payload (`[version:1B][nonce:12B][tag:16B][ciphertext:NB]`).
- key: ReadOnlySpan<byte>
- The 32-byte (256-bit) encryption key.
Retorna: The deserialized list of `AuditRecord` instances.
methodDispose
public void Dispose()
Inherits documentation from base type or interface.
methodDisposeAsync
public async ValueTask DisposeAsync()
Inherits documentation from base type or interface.
methodEncryptDeadLetterBatch
public static byte[] EncryptDeadLetterBatch(IReadOnlyList<AuditRecord> batch, ReadOnlySpan<byte> key)
Encrypts a batch of audit records using authenticated AES-256-GCM (`[version:1B][nonce:12B][tag:16B][ciphertext:NB]`).
- batch: IReadOnlyList<AuditRecord>
- The batch of audit records to encrypt.
- key: ReadOnlySpan<byte>
- The 32-byte (256-bit) encryption key.
Retorna: The authenticated encrypted payload.
methodQueryAsync
public ValueTask<AuditQueryResult> QueryAsync(AuditQuery query, CancellationToken cancellationToken = default)
Inherits documentation from base type or interface.
- query: AuditQuery
- cancellationToken: CancellationToken
propertyEffectiveDeadLetterEncryptionKey
public ReadOnlyMemory<byte>? EffectiveDeadLetterEncryptionKey { get; }
Gets the effective 256-bit AES-GCM encryption key for Dead-Letter Queue files when `BufferedAuditStoreOptions.EncryptDeadLetterQueue` is enabled.
class
BufferedAuditStoreOptions
Ensamblado: EricksonLopez.Auditingpublic sealed class BufferedAuditStoreOptions
Represents configuration options for `BufferedAuditStoreDecorator`.
Miembros (8)
propertyBatchSize
public int BatchSize { get; set; }
Gets or sets the maximum number of audit records dispatched in a single batch to the underlying store.
propertyCapacity
public int Capacity { get; set; }
Gets or sets the maximum number of audit records buffered in memory before applying backpressure.
propertyDeadLetterDirectory
public string? DeadLetterDirectory { get; set; }
Gets or sets the directory path where Dead-Letter Queue (DLQ) files are written when all store retries fail. When `null`, defaults to the system temporary directory.
propertyDeadLetterEncryptionKey
public byte[]? DeadLetterEncryptionKey { get; set; }
Gets or sets the 256-bit (32-byte) AES-GCM key used to encrypt Dead-Letter Queue (DLQ) files. Setting a valid key automatically enables `EncryptDeadLetterQueue`.
propertyEncryptDeadLetterQueue
public bool EncryptDeadLetterQueue { get; set; }
Gets or sets whether Dead-Letter Queue (DLQ) files are encrypted on disk using authenticated AES-256-GCM. Automatically set to `true` when `DeadLetterEncryptionKey` is configured.
propertyFlushInterval
public TimeSpan FlushInterval { get; set; }
Gets or sets the maximum duration to wait before flushing accumulated records even if `BatchSize` has not been reached.
propertyFullMode
public BoundedChannelFullMode FullMode { get; set; }
Gets or sets the behavior when writing to a full buffer.
propertyWorkerCount
public int WorkerCount { get; set; }
Gets or sets the number of concurrent background workers draining the buffer.
enum
EntityAuditActorResolution
Ensamblado: EricksonLopez.Auditing.Abstractionspublic enum EntityAuditActorResolution : byte
Specifies which principal identifier is stamped onto entity audit columns (`CreatedBy`, `UpdatedBy`, `DeletedBy`) during delegated impersonation.
class
EntityAuditStamper
Ensamblado: EricksonLopez.Auditingpublic sealed class EntityAuditStamper : IEntityAuditStamper
Implementa: IEntityAuditStamper
Default implementation of `IEntityAuditStamper` providing decoupled, impersonation-aware entity audit stamping using `TimeProvider`.
Miembros (11)
constructorEntityAuditStamper
public EntityAuditStamper(IAuditActorProvider actorProvider, TimeProvider? timeProvider = null, IAuditContextProvider? contextProvider = null, AuditConfiguration? configuration = null)
Initializes a new instance of the `EntityAuditStamper` class.
- actorProvider: IAuditActorProvider
- The provider used to resolve the active actor when no ambient scope override is present.
- timeProvider: TimeProvider?
- The optional deterministic `TimeProvider`. Defaults to `TimeProvider.System` when `null`.
- contextProvider: IAuditContextProvider?
- The optional context provider used to resolve the active execution plane.
- configuration: AuditConfiguration?
- The optional audit configuration controlling actor attribution during impersonation.
methodAuditEntityForDelete
public AuditStamp AuditEntityForDelete(IAuditableTarget entity)
Stamps soft-deletion metadata onto an `IAuditableTarget` entity immediately prior to SQL soft-delete execution.
- entity: IAuditableTarget
- The entity to stamp for soft-deletion.
Retorna: The applied `AuditStamp`.
methodAuditEntityForDelete<TActorId>
public AuditStamp AuditEntityForDelete<TActorId>(IAuditableTarget<TActorId> entity, Func<string, TActorId> actorParser)
Stamps soft-deletion metadata onto a strongly-typed `IAuditableTarget<TActorId>` entity.
- entity: IAuditableTarget<TActorId>
- The entity to stamp for soft-deletion.
- actorParser: Func<string, TActorId>
- A deterministic conversion function mapping the resolved actor string to `TActorId`.
Retorna: The applied `AuditStamp`.
methodAuditEntityForDelete<TEntity, TActorId>
public AuditStamp AuditEntityForDelete<TEntity, TActorId>(TEntity entity, Func<string, TActorId> actorParser, Action<TEntity, TActorId, DateTimeOffset> applyStamp) where TEntity : class
Stamps soft-deletion metadata onto an arbitrary pure-domain entity using an explicit zero-reflection callback.
- entity: TEntity
- The pure domain entity instance.
- actorParser: Func<string, TActorId>
- A deterministic conversion function mapping the resolved actor string to `TActorId`.
- applyStamp: Action<TEntity, TActorId, DateTimeOffset>
- The callback invoking the entity's soft-delete audit method (for example, `(e, uid, ts) => e.MarkDeleted(uid, ts)`).
Retorna: The applied `AuditStamp`.
methodAuditEntityForInsert
public AuditStamp AuditEntityForInsert(IAuditableTarget entity)
Stamps creation metadata onto an `IAuditableTarget` entity immediately prior to SQL insert execution.
- entity: IAuditableTarget
- The entity to stamp for insertion.
Retorna: The applied `AuditStamp`.
methodAuditEntityForInsert<TActorId>
public AuditStamp AuditEntityForInsert<TActorId>(IAuditableTarget<TActorId> entity, Func<string, TActorId> actorParser)
Stamps creation metadata onto a strongly-typed `IAuditableTarget<TActorId>` entity.
- entity: IAuditableTarget<TActorId>
- The entity to stamp for insertion.
- actorParser: Func<string, TActorId>
- A deterministic conversion function mapping the resolved actor string to `TActorId`.
Retorna: The applied `AuditStamp`.
methodAuditEntityForInsert<TEntity, TActorId>
public AuditStamp AuditEntityForInsert<TEntity, TActorId>(TEntity entity, Func<string, TActorId> actorParser, Action<TEntity, TActorId, DateTimeOffset> applyStamp) where TEntity : class
Stamps creation metadata onto an arbitrary pure-domain entity using an explicit zero-reflection callback.
- entity: TEntity
- The pure domain entity instance.
- actorParser: Func<string, TActorId>
- A deterministic conversion function mapping the resolved actor string to `TActorId`.
- applyStamp: Action<TEntity, TActorId, DateTimeOffset>
- The callback invoking the entity's creation audit method (for example, `(e, uid, ts) => e.MarkCreated(uid, ts)`).
Retorna: The applied `AuditStamp`.
methodAuditEntityForUpdate
public AuditStamp AuditEntityForUpdate(IAuditableTarget entity)
Stamps modification metadata onto an `IAuditableTarget` entity immediately prior to SQL update execution.
- entity: IAuditableTarget
- The entity to stamp for update.
Retorna: The applied `AuditStamp`.
methodAuditEntityForUpdate<TActorId>
public AuditStamp AuditEntityForUpdate<TActorId>(IAuditableTarget<TActorId> entity, Func<string, TActorId> actorParser)
Stamps modification metadata onto a strongly-typed `IAuditableTarget<TActorId>` entity.
- entity: IAuditableTarget<TActorId>
- The entity to stamp for update.
- actorParser: Func<string, TActorId>
- A deterministic conversion function mapping the resolved actor string to `TActorId`.
Retorna: The applied `AuditStamp`.
methodAuditEntityForUpdate<TEntity, TActorId>
public AuditStamp AuditEntityForUpdate<TEntity, TActorId>(TEntity entity, Func<string, TActorId> actorParser, Action<TEntity, TActorId, DateTimeOffset> applyStamp) where TEntity : class
Stamps modification metadata onto an arbitrary pure-domain entity using an explicit zero-reflection callback.
- entity: TEntity
- The pure domain entity instance.
- actorParser: Func<string, TActorId>
- A deterministic conversion function mapping the resolved actor string to `TActorId`.
- applyStamp: Action<TEntity, TActorId, DateTimeOffset>
- The callback invoking the entity's update audit method (for example, `(e, uid, ts) => e.MarkUpdated(uid, ts)`).
Retorna: The applied `AuditStamp`.
methodCaptureStamp
public AuditStamp CaptureStamp()
Captures the current deterministic `AuditStamp` from the active `TimeProvider`, ambient scope, and actor provider.
Retorna: An immutable `AuditStamp` representing the active actor, optional impersonator, plane, and UTC timestamp.
class
HmacAuditIntegrityService
Ensamblado: EricksonLopez.Auditing.Abstractionspublic sealed class HmacAuditIntegrityService
Provides computation and verification of HMAC-SHA256 integrity hashes for cryptographic chaining of audit records.
Miembros (3)
constructorHmacAuditIntegrityService
public HmacAuditIntegrityService(IAuditIntegrityProvider keyProvider, IAuditHashAlgorithm hashAlgorithm)
Initializes a new instance of the `HmacAuditIntegrityService` class.
- keyProvider: IAuditIntegrityProvider
- The cryptographic key provider for tenant integrity keys.
- hashAlgorithm: IAuditHashAlgorithm
- The cryptographic hash algorithm used for integrity signatures.
methodComputeHash
public string ComputeHash(AuditRecord record, string? previousHash)
Computes the HMAC-SHA256 hash for an audit record, incorporating the preceding record hash.
- record: AuditRecord
- The audit record to hash.
- previousHash: string?
- The hash of the preceding record in the tenant chain, or `null` for the initial record.
Retorna: The lowercase hexadecimal HMAC-SHA256 digest string.
methodVerify
public bool Verify(AuditRecord record)
Determines whether the integrity hash of a stored audit record matches its recomputed value.
- record: AuditRecord
- The audit record whose integrity is to be verified.
Retorna: `true` if the integrity hash is valid and matches; otherwise, `false`.
class
HmacSha256AuditHashAlgorithm
Ensamblado: EricksonLopez.Auditing.Abstractionspublic sealed class HmacSha256AuditHashAlgorithm : IAuditHashAlgorithm
Implementa: IAuditHashAlgorithm
Provides an HMAC-SHA256 implementation of `IAuditHashAlgorithm` for audit record integrity.
Miembros (3)
methodComputeHash
public int ComputeHash(ReadOnlySpan<byte> data, ReadOnlySpan<byte> key, Span<byte> destination)
Computes the cryptographic hash for the given data and key, writing the result into the destination span.
- data: ReadOnlySpan<byte>
- The canonicalized payload data to hash.
- key: ReadOnlySpan<byte>
- The cryptographic key.
- destination: Span<byte>
- The destination span to receive the computed hash bytes.
Retorna: The number of bytes written to the destination span.
propertyAlgorithmId
public string AlgorithmId { get; }
Gets the string identifier of this algorithm, such as "HMACSHA256".
propertyHashLengthInBytes
public int HashLengthInBytes { get; }
Gets the exact length in bytes of the hash produced by this algorithm.
interface
IAuditActorProvider
Ensamblado: EricksonLopez.Auditing.Abstractionspublic interface IAuditActorProvider
Defines a provider for resolving the current authenticated actor identity.
Miembros (1)
methodGetCurrentActor
AuditActor GetCurrentActor()
Resolves the current authenticated actor identity.
Retorna: The `AuditActor` performing the current operation, or `AuditActor.Anonymous` if unauthenticated.
interface
IAuditBuilder
Ensamblado: EricksonLopez.Auditing.Abstractionspublic interface IAuditBuilder
Defines a fluent builder for configuring auditing services and registering storage providers.
Miembros (5)
methodAddEnricher<TEnricher>
IAuditBuilder AddEnricher<TEnricher>() where TEnricher : class, IAuditEnricher
Registers an audit enricher to augment records in the logging pipeline.
Retorna: The current `IAuditBuilder` instance for fluent chaining.
methodEnableIntegrityChain
IAuditBuilder EnableIntegrityChain()
Enables HMAC-SHA256 cryptographic chain integrity verification for audit records.
Retorna: The current `IAuditBuilder` instance for fluent chaining.
methodUseActorProvider<TProvider>
IAuditBuilder UseActorProvider<TProvider>() where TProvider : class, IAuditActorProvider
Registers a custom actor provider type to resolve current actor identities.
Retorna: The current `IAuditBuilder` instance for fluent chaining.
methodUseStore<TStore>
IAuditBuilder UseStore<TStore>() where TStore : class, IAuditStore
Registers an audit persistence store implementation.
Retorna: The current `IAuditBuilder` instance for fluent chaining.
propertyServices
IServiceCollection Services { get; }
Gets the underlying service collection being configured.
interface
IAuditChainHeadProvider
Ensamblado: EricksonLopez.Auditing.Abstractionspublic interface IAuditChainHeadProvider
Provides direct lookup of the latest cryptographic integrity hash for a given tenant without requiring full `IAuditRecordReader.QueryAsync` support.
Miembros (1)
methodGetLatestIntegrityHashAsync
ValueTask<string?> GetLatestIntegrityHashAsync(TenantId tenantId, CancellationToken cancellationToken = default)
Retrieves the `AuditRecord.IntegrityHash` of the most recently appended audit record for `tenantId`, or `null` if no record exists yet.
- tenantId: TenantId
- The tenant identifier whose chain head is requested.
- cancellationToken: CancellationToken
- A token to monitor for cancellation requests.
Retorna: The latest integrity hash string, or `null` for a genesis record.
interface
IAuditContextProvider
Ensamblado: EricksonLopez.Auditing.Abstractionspublic interface IAuditContextProvider
Defines a provider for resolving the current ambient execution context.
Miembros (1)
methodGetCurrentContext
AuditContext GetCurrentContext()
Resolves the current ambient execution context.
Retorna: The current `AuditContext` instance.
interface
IAuditCryptoKeyProvider
Ensamblado: EricksonLopez.Auditing.Abstractionspublic interface IAuditCryptoKeyProvider
Provides cryptographic key management for the Crypto-Shredding pattern (GDPR Art. 17).
Miembros (2)
methodGetEncryptionKeyAsync
ValueTask<byte[]> GetEncryptionKeyAsync(string subjectId, CancellationToken cancellationToken = default)
Retrieves or generates the encryption key associated with a specific subject (e.g., tenant or actor).
- subjectId: string
- The identifier of the subject whose data requires encryption.
- cancellationToken: CancellationToken
- A token to monitor for cancellation requests.
Retorna: A task representing the asynchronous operation. The task result contains a 32-byte cryptographic key for AES-GCM encryption.
methodShredKeyAsync
ValueTask ShredKeyAsync(string subjectId, CancellationToken cancellationToken = default)
Permanently deletes the encryption key associated with a specific subject, rendering all their encrypted PII permanently inaccessible.
- subjectId: string
- The identifier of the subject whose key should be destroyed.
- cancellationToken: CancellationToken
- A token to monitor for cancellation requests.
Retorna: A task representing the asynchronous operation.
interface
IAuditEnricher
Ensamblado: EricksonLopez.Auditing.Abstractionspublic interface IAuditEnricher
Defines a pipeline enricher capable of augmenting or transforming an `AuditRecord` before persistence.
Miembros (1)
methodEnrichAsync
ValueTask<AuditRecord> EnrichAsync(AuditRecord record, CancellationToken cancellationToken = default)
Enriches the specified `record` with ambient, environmental, or domain-specific attributes.
- record: AuditRecord
- The audit record to enrich.
- cancellationToken: CancellationToken
- A token to monitor for cancellation requests.
Retorna: A task representing the asynchronous operation, returning the enriched `AuditRecord`.
interface
IAuditFieldEncryptor
Ensamblado: EricksonLopez.Auditing.Abstractionspublic interface IAuditFieldEncryptor
Defines an authenticated field-level encryption and decryption service for GDPR Art. 17 Crypto-Shredding.
Miembros (2)
methodDecryptAsync
ValueTask<string> DecryptAsync(string ciphertext, string subjectId, CancellationToken cancellationToken = default)
Decrypts an `ENC:v1:` ciphertext field value using the cryptographic key associated with `subjectId`, or returns `[SHREDDED]` if the subject's key has been permanently destroyed.
- ciphertext: string
- The `ENC:v1:` ciphertext value to decrypt.
- subjectId: string
- The tenant or subject identifier whose encryption key is used.
- cancellationToken: CancellationToken
- A token to monitor for cancellation requests.
Retorna: The decrypted plaintext value, or `[SHREDDED]` if the key was destroyed.
methodEncryptAsync
ValueTask<string> EncryptAsync(string plaintext, string subjectId, CancellationToken cancellationToken = default)
Encrypts a plaintext field value using the cryptographic key associated with `subjectId`.
- plaintext: string
- The plaintext field value to encrypt.
- subjectId: string
- The tenant or subject identifier whose encryption key is used.
- cancellationToken: CancellationToken
- A token to monitor for cancellation requests.
Retorna: The authenticated ciphertext payload formatted with the `ENC:v1:` envelope prefix.
interface
IAuditHashAlgorithm
Ensamblado: EricksonLopez.Auditing.Abstractionspublic interface IAuditHashAlgorithm
Defines a cryptographic hashing algorithm used to compute the integrity signature of an audit record.
Miembros (3)
methodComputeHash
int ComputeHash(ReadOnlySpan<byte> data, ReadOnlySpan<byte> key, Span<byte> destination)
Computes the cryptographic hash for the given data and key, writing the result into the destination span.
- data: ReadOnlySpan<byte>
- The canonicalized payload data to hash.
- key: ReadOnlySpan<byte>
- The cryptographic key.
- destination: Span<byte>
- The destination span to receive the computed hash bytes.
Retorna: The number of bytes written to the destination span.
propertyAlgorithmId
string AlgorithmId { get; }
Gets the string identifier of this algorithm, such as "HMACSHA256".
propertyHashLengthInBytes
int HashLengthInBytes { get; }
Gets the exact length in bytes of the hash produced by this algorithm.
interface
IAuditIntegrityProvider
Ensamblado: EricksonLopez.Auditing.Abstractionspublic interface IAuditIntegrityProvider
Defines a provider for retrieving cryptographic keys used in HMAC chain integrity verification.
Miembros (1)
methodGetCurrentKey
ReadOnlyMemory<byte> GetCurrentKey(TenantId tenantId)
Retrieves the current cryptographic key bytes for the specified tenant.
- tenantId: TenantId
- The tenant identifier for which to retrieve the key.
Retorna: A read-only memory segment containing the cryptographic key bytes.
interface
IAuditIntegrityVerifier
Ensamblado: EricksonLopez.Auditing.Abstractionspublic interface IAuditIntegrityVerifier
Defines a verifier for evaluating cryptographic chain integrity across audit records.
Miembros (1)
methodVerifyChainAsync
ValueTask<AuditIntegrityVerificationResult> VerifyChainAsync(string tenantId, DateTimeOffset from, DateTimeOffset until, CancellationToken cancellationToken = default)
Verifies the cryptographic HMAC chain for audit records within the specified time window.
- tenantId: string
- The tenant identifier whose audit chain is to be verified.
- from: DateTimeOffset
- The inclusive start timestamp of the verification window.
- until: DateTimeOffset
- The inclusive end timestamp of the verification window.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the verification outcome details.
interface
IAuditLogger
Ensamblado: EricksonLopez.Auditing.Abstractionspublic interface IAuditLogger
Provides a simplified facade for creating and persisting audit records without manually resolving actors and scopes.
Miembros (1)
methodLogAsync
ValueTask LogAsync(AuditAction action, AuditResource resource, AuditOutcome outcome, CancellationToken cancellationToken = default)
Logs an audit event asynchronously.
- action: AuditAction
- The operation that was executed.
- resource: AuditResource
- The target resource on which the operation was performed.
- outcome: AuditOutcome
- The observable result of the operation.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation.
interface
IAuditLogger<TCategoryName>
Ensamblado: EricksonLopez.Auditing.Abstractionspublic interface IAuditLogger<TCategoryName> : IAuditLogger
Implementa: IAuditLogger
Provides a strongly-typed facade for logging audit records associated with a specific category type.
Miembros (0)
Este tipo declara 0 miembros públicos (por ejemplo, interfaz marcadora o enum/record vacío).
interface
IAuditRecordReader
Ensamblado: EricksonLopez.Auditing.Abstractionspublic interface IAuditRecordReader
Defines the read-only persistence contract for querying and streaming immutable audit records (Interface Segregation Principle).
Miembros (2)
methodQueryAsync
ValueTask<AuditQueryResult> QueryAsync(AuditQuery query, CancellationToken cancellationToken = default)
Queries persisted audit records using the specified filter and pagination parameters.
- query: AuditQuery
- The query parameters and pagination options.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the paginated query results.
methodStreamAsync
async IAsyncEnumerable<AuditRecord> StreamAsync(AuditQuery query, CancellationToken cancellationToken = default)
Streams all persisted audit records matching the specified filter, automatically handling pagination.
- query: AuditQuery
- The query parameters. Pagination parameters are overridden internally.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: An async-enumerable sequence of matching audit records.
interface
IAuditRecordWriter
Ensamblado: EricksonLopez.Auditing.Abstractionspublic interface IAuditRecordWriter
Defines the write-only persistence contract for appending immutable audit records (Interface Segregation Principle).
Miembros (2)
methodAppendAsync
ValueTask AppendAsync(AuditRecord record, CancellationToken cancellationToken = default)
Appends a single audit record to the persistent store.
- record: AuditRecord
- The audit record to persist.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation.
methodAppendBatchAsync
ValueTask AppendBatchAsync(IReadOnlyList<AuditRecord> records, CancellationToken cancellationToken = default)
Appends a collection of audit records to the persistent store in a single batch operation.
- records: IReadOnlyList<AuditRecord>
- The collection of audit records to persist.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation.
interface
IAuditSecurityAlertSink
Ensamblado: EricksonLopez.Auditing.Abstractionspublic interface IAuditSecurityAlertSink
Defines an asynchronous sink for dispatching real-time security alerts (such as `GENESIS`, `BreakGlass`, or delegated support impersonation activity) to SIEM, SOC, or incident-response channels.
Miembros (1)
methodEmitAlertAsync
ValueTask EmitAlertAsync(AuditSecurityAlert alert, CancellationToken cancellationToken = default)
Emits a structured security alert asynchronously.
- alert: AuditSecurityAlert
- The immutable security alert payload.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous alert dispatch operation.
interface
IAuditSensitivityPipeline
Ensamblado: EricksonLopez.Auditing.Abstractionspublic interface IAuditSensitivityPipeline
Defines a contract for sanitizing audit records and field changes before persistence.
Miembros (2)
methodApplyAsync
ValueTask<IReadOnlyList<AuditChange>?> ApplyAsync(IReadOnlyList<AuditChange>? changes, string tenantId, CancellationToken cancellationToken = default)
Applies sensitivity policies to a collection of field changes, returning a sanitized collection.
- changes: IReadOnlyList<AuditChange>?
- The raw collection of field changes to process.
- tenantId: string
- The tenant ID to use for fetching encryption keys.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the sanitized collection of changes, or `null` if all changes were excluded or the input was `null`.
methodSanitizeAsync
ValueTask<AuditRecord> SanitizeAsync(AuditRecord record, CancellationToken cancellationToken = default)
Sanitizes the specified audit record by applying redaction or exclusions to sensitive fields.
- record: AuditRecord
- The audit record to sanitize.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A task representing the asynchronous operation. The task result contains the sanitized audit record.
interface
IAuditStore
Ensamblado: EricksonLopez.Auditing.Abstractionspublic interface IAuditStore : IAuditRecordWriter, IAuditRecordReader
Implementa: IAuditRecordReader, IAuditRecordWriter
Defines the persistence store contract for appending and querying immutable audit records.
Miembros (0)
Este tipo declara 0 miembros públicos (por ejemplo, interfaz marcadora o enum/record vacío).
interface
IAuditTimeProvider
Ensamblado: EricksonLopez.Auditing.Abstractionspublic interface IAuditTimeProvider
Defines an abstraction for obtaining the current deterministic audit timestamp.
Miembros (1)
methodGetUtcNow
DateTimeOffset GetUtcNow()
Gets the current deterministic audit timestamp in UTC.
Retorna: The current UTC timestamp.
interface
IAuditableTarget
Ensamblado: EricksonLopez.Auditing.Abstractionspublic interface IAuditableTarget
Defines a decoupled persistence contract for domain entities that accept centralized creation, modification, and soft-deletion audit stamps.
Miembros (3)
methodMarkCreated
void MarkCreated(string actorId, DateTimeOffset timestamp)
Applies creation audit metadata prior to insert execution.
- actorId: string
- The resolved creator identifier.
- timestamp: DateTimeOffset
- The deterministic UTC creation timestamp.
methodMarkDeleted
void MarkDeleted(string actorId, DateTimeOffset timestamp)
Applies soft-deletion audit metadata prior to soft-delete execution.
- actorId: string
- The resolved deleter identifier.
- timestamp: DateTimeOffset
- The deterministic UTC soft-deletion timestamp.
methodMarkUpdated
void MarkUpdated(string actorId, DateTimeOffset timestamp)
Applies modification audit metadata prior to update execution.
- actorId: string
- The resolved modifier identifier.
- timestamp: DateTimeOffset
- The deterministic UTC modification timestamp.
interface
IAuditableTarget<TActorId>
Ensamblado: EricksonLopez.Auditing.Abstractionspublic interface IAuditableTarget<TActorId>
Defines a strongly-typed decoupled persistence contract for domain entities that accept centralized creation, modification, and soft-deletion audit stamps without boxing or string allocations.
Miembros (3)
methodMarkCreated
void MarkCreated(TActorId actorId, DateTimeOffset timestamp)
Applies creation audit metadata prior to insert execution.
- actorId: TActorId
- The resolved strongly-typed creator identifier.
- timestamp: DateTimeOffset
- The deterministic UTC creation timestamp.
methodMarkDeleted
void MarkDeleted(TActorId actorId, DateTimeOffset timestamp)
Applies soft-deletion audit metadata prior to soft-delete execution.
- actorId: TActorId
- The resolved strongly-typed deleter identifier.
- timestamp: DateTimeOffset
- The deterministic UTC soft-deletion timestamp.
methodMarkUpdated
void MarkUpdated(TActorId actorId, DateTimeOffset timestamp)
Applies modification audit metadata prior to update execution.
- actorId: TActorId
- The resolved strongly-typed modifier identifier.
- timestamp: DateTimeOffset
- The deterministic UTC modification timestamp.
interface
IEntityAuditStamper
Ensamblado: EricksonLopez.Auditing.Abstractionspublic interface IEntityAuditStamper
Provides centralized, decoupled entity audit stamping (`AuditEntityForInsert`, `AuditEntityForUpdate`, `AuditEntityForDelete`) driven by `TimeProvider` and impersonation-aware actor resolution for Unit of Work and Dapper repositories.
Miembros (10)
methodAuditEntityForDelete
AuditStamp AuditEntityForDelete(IAuditableTarget entity)
Stamps soft-deletion metadata onto an `IAuditableTarget` entity immediately prior to SQL soft-delete execution.
- entity: IAuditableTarget
- The entity to stamp for soft-deletion.
Retorna: The applied `AuditStamp`.
methodAuditEntityForDelete<TActorId>
AuditStamp AuditEntityForDelete<TActorId>(IAuditableTarget<TActorId> entity, Func<string, TActorId> actorParser)
Stamps soft-deletion metadata onto a strongly-typed `IAuditableTarget<TActorId>` entity.
- entity: IAuditableTarget<TActorId>
- The entity to stamp for soft-deletion.
- actorParser: Func<string, TActorId>
- A deterministic conversion function mapping the resolved actor string to `TActorId`.
Retorna: The applied `AuditStamp`.
methodAuditEntityForDelete<TEntity, TActorId>
AuditStamp AuditEntityForDelete<TEntity, TActorId>(TEntity entity, Func<string, TActorId> actorParser, Action<TEntity, TActorId, DateTimeOffset> applyStamp) where TEntity : class
Stamps soft-deletion metadata onto an arbitrary pure-domain entity using an explicit zero-reflection callback.
- entity: TEntity
- The pure domain entity instance.
- actorParser: Func<string, TActorId>
- A deterministic conversion function mapping the resolved actor string to `TActorId`.
- applyStamp: Action<TEntity, TActorId, DateTimeOffset>
- The callback invoking the entity's soft-delete audit method (for example, `(e, uid, ts) => e.MarkDeleted(uid, ts)`).
Retorna: The applied `AuditStamp`.
methodAuditEntityForInsert
AuditStamp AuditEntityForInsert(IAuditableTarget entity)
Stamps creation metadata onto an `IAuditableTarget` entity immediately prior to SQL insert execution.
- entity: IAuditableTarget
- The entity to stamp for insertion.
Retorna: The applied `AuditStamp`.
methodAuditEntityForInsert<TActorId>
AuditStamp AuditEntityForInsert<TActorId>(IAuditableTarget<TActorId> entity, Func<string, TActorId> actorParser)
Stamps creation metadata onto a strongly-typed `IAuditableTarget<TActorId>` entity.
- entity: IAuditableTarget<TActorId>
- The entity to stamp for insertion.
- actorParser: Func<string, TActorId>
- A deterministic conversion function mapping the resolved actor string to `TActorId`.
Retorna: The applied `AuditStamp`.
methodAuditEntityForInsert<TEntity, TActorId>
AuditStamp AuditEntityForInsert<TEntity, TActorId>(TEntity entity, Func<string, TActorId> actorParser, Action<TEntity, TActorId, DateTimeOffset> applyStamp) where TEntity : class
Stamps creation metadata onto an arbitrary pure-domain entity using an explicit zero-reflection callback.
- entity: TEntity
- The pure domain entity instance.
- actorParser: Func<string, TActorId>
- A deterministic conversion function mapping the resolved actor string to `TActorId`.
- applyStamp: Action<TEntity, TActorId, DateTimeOffset>
- The callback invoking the entity's creation audit method (for example, `(e, uid, ts) => e.MarkCreated(uid, ts)`).
Retorna: The applied `AuditStamp`.
methodAuditEntityForUpdate
AuditStamp AuditEntityForUpdate(IAuditableTarget entity)
Stamps modification metadata onto an `IAuditableTarget` entity immediately prior to SQL update execution.
- entity: IAuditableTarget
- The entity to stamp for update.
Retorna: The applied `AuditStamp`.
methodAuditEntityForUpdate<TActorId>
AuditStamp AuditEntityForUpdate<TActorId>(IAuditableTarget<TActorId> entity, Func<string, TActorId> actorParser)
Stamps modification metadata onto a strongly-typed `IAuditableTarget<TActorId>` entity.
- entity: IAuditableTarget<TActorId>
- The entity to stamp for update.
- actorParser: Func<string, TActorId>
- A deterministic conversion function mapping the resolved actor string to `TActorId`.
Retorna: The applied `AuditStamp`.
methodAuditEntityForUpdate<TEntity, TActorId>
AuditStamp AuditEntityForUpdate<TEntity, TActorId>(TEntity entity, Func<string, TActorId> actorParser, Action<TEntity, TActorId, DateTimeOffset> applyStamp) where TEntity : class
Stamps modification metadata onto an arbitrary pure-domain entity using an explicit zero-reflection callback.
- entity: TEntity
- The pure domain entity instance.
- actorParser: Func<string, TActorId>
- A deterministic conversion function mapping the resolved actor string to `TActorId`.
- applyStamp: Action<TEntity, TActorId, DateTimeOffset>
- The callback invoking the entity's update audit method (for example, `(e, uid, ts) => e.MarkUpdated(uid, ts)`).
Retorna: The applied `AuditStamp`.
methodCaptureStamp
AuditStamp CaptureStamp()
Captures the current deterministic `AuditStamp` from the active `TimeProvider`, ambient scope, and actor provider.
Retorna: An immutable `AuditStamp` representing the active actor, optional impersonator, plane, and UTC timestamp.
interface
ITransactionalAuditStore
Ensamblado: EricksonLopez.Auditing.Abstractionspublic interface ITransactionalAuditStore : IAuditStore
Implementa: IAuditStore
Extends `IAuditStore` with explicit ADO.NET connection and transaction enlistment so forensic security audit records commit or roll back atomically within an active Unit of Work transaction.
Miembros (2)
methodAppendAsync
ValueTask AppendAsync(AuditRecord record, IDbConnection connection, IDbTransaction? transaction = null, CancellationToken cancellationToken = default)
Appends a single immutable audit record using the caller-owned database connection and optional active transaction.
- record: AuditRecord
- The immutable audit record to persist.
- connection: IDbConnection
- The caller-managed database connection.
- transaction: IDbTransaction?
- The optional active database transaction to enlist into.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation.
methodAppendBatchAsync
ValueTask AppendBatchAsync(IReadOnlyList<AuditRecord> records, IDbConnection connection, IDbTransaction? transaction = null, CancellationToken cancellationToken = default)
Appends an ordered batch of immutable audit records using the caller-owned database connection and optional active transaction.
- records: IReadOnlyList<AuditRecord>
- The ordered collection of audit records to persist.
- connection: IDbConnection
- The caller-managed database connection.
- transaction: IDbTransaction?
- The optional active database transaction to enlist into.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Retorna: A value task representing the asynchronous operation.
class
InMemoryCryptoKeyProvider
Ensamblado: EricksonLopez.Auditingpublic sealed class InMemoryCryptoKeyProvider : IAuditCryptoKeyProvider
Implementa: IAuditCryptoKeyProvider
Provides an in-memory implementation of `IAuditCryptoKeyProvider` supporting per-subject AES-256 key generation and irreversible cryptographic key destruction (GDPR Art. 17 Crypto-Shredding).
Miembros (3)
methodGetEncryptionKeyAsync
public ValueTask<byte[]> GetEncryptionKeyAsync(string subjectId, CancellationToken cancellationToken = default)
Retrieves or generates the encryption key associated with a specific subject (e.g., tenant or actor).
- subjectId: string
- The identifier of the subject whose data requires encryption.
- cancellationToken: CancellationToken
- A token to monitor for cancellation requests.
Retorna: A task representing the asynchronous operation. The task result contains a 32-byte cryptographic key for AES-GCM encryption.
methodIsKeyShredded
public bool IsKeyShredded(string subjectId)
Determines whether the cryptographic key for the specified subject has been permanently shredded.
- subjectId: string
- The subject identifier to check.
Retorna: `true` if the subject's key has been shredded; otherwise, `false`.
methodShredKeyAsync
public ValueTask ShredKeyAsync(string subjectId, CancellationToken cancellationToken = default)
Permanently deletes the encryption key associated with a specific subject, rendering all their encrypted PII permanently inaccessible.
- subjectId: string
- The identifier of the subject whose key should be destroyed.
- cancellationToken: CancellationToken
- A token to monitor for cancellation requests.
Retorna: A task representing the asynchronous operation.
class
IntegrityAuditStoreDecorator
Ensamblado: EricksonLopez.Auditingpublic sealed class IntegrityAuditStoreDecorator : IAuditStore, IAsyncDisposable, IDisposable
Implementa: IAsyncDisposable, IAuditStore, IDisposable
Provides cryptographic HMAC-SHA256 integrity chaining for an `IAuditStore` before records are persisted to the underlying store.
Miembros (6)
constructorIntegrityAuditStoreDecorator
public IntegrityAuditStoreDecorator(IAuditStore innerStore, HmacAuditIntegrityService integrityService, KeyedSemaphoreSlim? keyedLocks = null, IAuditSensitivityPipeline? sensitivityPipeline = null)
Initializes a new instance of the `IntegrityAuditStoreDecorator` class.
- innerStore: IAuditStore
- The underlying audit store where records are persisted.
- integrityService: HmacAuditIntegrityService
- The service used to compute HMAC integrity hashes.
- keyedLocks: KeyedSemaphoreSlim?
- Optional keyed concurrency lock primitive for per-tenant serialization.
- sensitivityPipeline: IAuditSensitivityPipeline?
- Optional sensitivity pipeline executed prior to HMAC calculation.
methodAppendAsync
public async ValueTask AppendAsync(AuditRecord record, CancellationToken cancellationToken = default)
Inherits documentation from base type or interface.
- record: AuditRecord
- cancellationToken: CancellationToken
methodAppendBatchAsync
public async ValueTask AppendBatchAsync(IReadOnlyList<AuditRecord> records, CancellationToken cancellationToken = default)
Inherits documentation from base type or interface.
- records: IReadOnlyList<AuditRecord>
- cancellationToken: CancellationToken
methodDispose
public void Dispose()
Inherits documentation from base type or interface.
methodDisposeAsync
public async ValueTask DisposeAsync()
Inherits documentation from base type or interface.
methodQueryAsync
public ValueTask<AuditQueryResult> QueryAsync(AuditQuery query, CancellationToken cancellationToken = default)
Inherits documentation from base type or interface.
- query: AuditQuery
- cancellationToken: CancellationToken
class
ResilientAuditStoreDecorator
Ensamblado: EricksonLopez.Auditingpublic sealed partial class ResilientAuditStoreDecorator : IAuditStore
Implementa: IAuditStore
Provides failure resilience policies (`AuditFailureBehavior`) and critical action protection for an underlying `IAuditStore`.
Miembros (4)
constructorResilientAuditStoreDecorator
public ResilientAuditStoreDecorator(IAuditStore innerStore, AuditConfiguration configuration, ILogger<ResilientAuditStoreDecorator>? logger = null)
Initializes a new instance of the `ResilientAuditStoreDecorator` class.
- innerStore: IAuditStore
- The underlying audit store to decorate.
- configuration: AuditConfiguration
- The audit configuration defining failure behaviors.
- logger: ILogger<ResilientAuditStoreDecorator>?
- Optional logger for diagnostic warnings when operating in FailOpen mode.
methodAppendAsync
public async ValueTask AppendAsync(AuditRecord record, CancellationToken cancellationToken = default)
Inherits documentation from base type or interface.
- record: AuditRecord
- cancellationToken: CancellationToken
methodAppendBatchAsync
public async ValueTask AppendBatchAsync(IReadOnlyList<AuditRecord> records, CancellationToken cancellationToken = default)
Inherits documentation from base type or interface.
- records: IReadOnlyList<AuditRecord>
- cancellationToken: CancellationToken
methodQueryAsync
public ValueTask<AuditQueryResult> QueryAsync(AuditQuery query, CancellationToken cancellationToken = default)
Inherits documentation from base type or interface.
- query: AuditQuery
- cancellationToken: CancellationToken
class
SecurityAlertAuditStoreDecorator
Ensamblado: EricksonLopez.Auditingpublic sealed partial class SecurityAlertAuditStoreDecorator : IAuditStore, IAsyncDisposable, IDisposable
Implementa: IAsyncDisposable, IAuditStore, IDisposable
Decorates an `IAuditStore` to evaluate high-criticality security audit events (including root `GENESIS` identity operations, `BreakGlass` emergency access, `BOOTSTRAP` plane mutations, delegated support impersonation, and denied security-sensitive actions) and emit structured alerts to `IAuditSecurityAlertSink` subscribers and diagnostic loggers.
Miembros (12)
constructorSecurityAlertAuditStoreDecorator
public SecurityAlertAuditStoreDecorator(IAuditStore innerStore, IEnumerable<IAuditSecurityAlertSink>? alertSinks = null, TimeProvider? timeProvider = null, ILogger<SecurityAlertAuditStoreDecorator>? logger = null)
Initializes a new instance of the `SecurityAlertAuditStoreDecorator` class.
- innerStore: IAuditStore
- The underlying audit store to decorate.
- alertSinks: IEnumerable<IAuditSecurityAlertSink>?
- The optional sequence of registered security alert sinks.
- timeProvider: TimeProvider?
- The optional deterministic `TimeProvider`.
- logger: ILogger<SecurityAlertAuditStoreDecorator>?
- The optional structured logger.
methodAppendAsync
public async ValueTask AppendAsync(AuditRecord record, CancellationToken cancellationToken = default)
Inherits documentation from base type or interface.
- record: AuditRecord
- cancellationToken: CancellationToken
methodAppendBatchAsync
public async ValueTask AppendBatchAsync(IReadOnlyList<AuditRecord> records, CancellationToken cancellationToken = default)
Inherits documentation from base type or interface.
- records: IReadOnlyList<AuditRecord>
- cancellationToken: CancellationToken
methodDispose
public void Dispose()
Inherits documentation from base type or interface.
methodDisposeAsync
public async ValueTask DisposeAsync()
Inherits documentation from base type or interface.
methodQueryAsync
public ValueTask<AuditQueryResult> QueryAsync(AuditQuery query, CancellationToken cancellationToken = default)
Inherits documentation from base type or interface.
- query: AuditQuery
- cancellationToken: CancellationToken
methodTryBuildAlert
public bool TryBuildAlert(AuditRecord record, out AuditSecurityAlert? alert)
Evaluates whether the specified `AuditRecord` warrants a real-time `AuditSecurityAlert`.
- record: AuditRecord
- The audit record to inspect.
- alert: out AuditSecurityAlert?
- When this method returns `true`, contains the constructed `AuditSecurityAlert`; otherwise, `null`.
Retorna: `true` if an alert was generated; otherwise, `false`.
fieldBootstrapPlaneAlertCode
public const string BootstrapPlaneAlertCode
Alert code emitted when an operation is executed on `AuditExecutionPlane.Bootstrap`.
fieldBreakGlassAlertCode
public const string BreakGlassAlertCode
Alert code emitted when an operation is executed under `AuditSecurityClassification.BreakGlass`.
fieldGenesisAlertCode
public const string GenesisAlertCode
Alert code emitted when an operation is executed under `AuditSecurityClassification.Genesis`.
fieldImpersonationAlertCode
public const string ImpersonationAlertCode
Alert code emitted when an operation is executed under active delegated support impersonation.
fieldSecurityAccessDeniedAlertCode
public const string SecurityAccessDeniedAlertCode
Alert code emitted when a security-classified operation is rejected (`AuditOutcome.Denied`).
class
SensitivityAuditStoreDecorator
Ensamblado: EricksonLopez.Auditingpublic sealed class SensitivityAuditStoreDecorator : IAuditStore, IAsyncDisposable, IDisposable
Implementa: IAsyncDisposable, IAuditStore, IDisposable
Provides pre-persistence sensitivity sanitization (denylist stripping, redaction, truncation, and field encryption) for an `IAuditStore` so that downstream decorators (such as HMAC integrity signing and channel buffering) operate exclusively on sanitized records.
Miembros (6)
constructorSensitivityAuditStoreDecorator
public SensitivityAuditStoreDecorator(IAuditStore innerStore, IAuditSensitivityPipeline sensitivityPipeline)
Initializes a new instance of the `SensitivityAuditStoreDecorator` class.
- innerStore: IAuditStore
- The inner audit store to receive sanitized records.
- sensitivityPipeline: IAuditSensitivityPipeline
- The sensitivity pipeline used to sanitize records before persistence.
methodAppendAsync
public async ValueTask AppendAsync(AuditRecord record, CancellationToken cancellationToken = default)
Inherits documentation from base type or interface.
- record: AuditRecord
- cancellationToken: CancellationToken
methodAppendBatchAsync
public async ValueTask AppendBatchAsync(IReadOnlyList<AuditRecord> records, CancellationToken cancellationToken = default)
Inherits documentation from base type or interface.
- records: IReadOnlyList<AuditRecord>
- cancellationToken: CancellationToken
methodDispose
public void Dispose()
Inherits documentation from base type or interface.
methodDisposeAsync
public async ValueTask DisposeAsync()
Inherits documentation from base type or interface.
methodQueryAsync
public ValueTask<AuditQueryResult> QueryAsync(AuditQuery query, CancellationToken cancellationToken = default)
Inherits documentation from base type or interface.
- query: AuditQuery
- cancellationToken: CancellationToken
class
SystemAuditActorProvider
Ensamblado: EricksonLopez.Auditing.Abstractionspublic sealed class SystemAuditActorProvider : IAuditActorProvider
Implementa: IAuditActorProvider
Provides a default actor provider that returns `AuditActor.System` for background operations.
Miembros (2)
methodGetCurrentActor
public AuditActor GetCurrentActor()
Resolves the current authenticated actor identity.
Retorna: The `AuditActor` performing the current operation, or `AuditActor.Anonymous` if unauthenticated.
fieldInstance
public static readonly SystemAuditActorProvider Instance
Gets the singleton instance of `SystemAuditActorProvider`.
class
SystemTimeProviderAuditAdapter
Ensamblado: EricksonLopez.Auditing.Abstractionspublic sealed class SystemTimeProviderAuditAdapter : IAuditTimeProvider
Implementa: IAuditTimeProvider
Adapts the .NET BCL `TimeProvider` to `IAuditTimeProvider` while honoring active `AmbientAuditTimeProvider` deterministic scopes.
Miembros (2)
constructorSystemTimeProviderAuditAdapter
public SystemTimeProviderAuditAdapter(TimeProvider? timeProvider = null)
Initializes a new instance of the `SystemTimeProviderAuditAdapter` class.
- timeProvider: TimeProvider?
- The optional BCL `TimeProvider`. Defaults to `TimeProvider.System` when `null`.
methodGetUtcNow
public DateTimeOffset GetUtcNow()
Gets the current deterministic audit timestamp in UTC.
Retorna: The current UTC timestamp.
record
TenantId
Ensamblado: EricksonLopez.Auditing.Abstractionspublic readonly record struct TenantId
Represents a strongly-typed, immutable tenant identifier for auditing boundaries.
Miembros (5)
constructorTenantId
public TenantId(string value)
Initializes a new instance of the `TenantId` struct.
- value: string
- The non-empty string value of the tenant.
methodToString
public override string ToString()
Inherits documentation from base type or interface.
methodimplicit operator TenantId
public static implicit operator TenantId(string value)
Converts a `string` to a `TenantId`.
- value: string
- The string value to convert.
Retorna: A new `TenantId` instance initialized with the specified value.
methodimplicit operator string
public static implicit operator string(TenantId tenantId)
Converts a `TenantId` to a `string`.
- tenantId: TenantId
- The tenant identifier to convert.
Retorna: The string representation of the tenant identifier.
propertyValue
public string Value { get; }
Gets the raw string value of the tenant identifier.