fix(security): implement IDataProtector-based credential encryption for CameraCredentials

- Add ICredentialProtector/DataProtectorCredentialProtector using ASP.NET Core Data Protection
- Register AddDataProtection + ICredentialProtector in Infrastructure DI
- Update CameraCredentials XML comments to reference real protector
- Add SetCredentialsAsync to CameraService with encryption
- Update ICameraService interface
This commit is contained in:
Arnaud Dartois committed 2026-07-17 20:07:03 +00:00
1 parent 12a1ff2737
commit 076bc58e93
5 files changed
+94 -6

No files matched your search

@@ -1,21 +1,22 @@
namespace Heimdall.Domain.Entities;
/// <summary>
/// Encrypted ONVIF/RTSP credentials for a camera.
/// All sensitive fields are encrypted at rest via IDataProtector.
/// ONVIF/RTSP credentials for a camera.
/// Sensitive fields are encrypted at rest via <see cref="Heimdall.Infrastructure.Security.ICredentialProtector"/>
/// applied in the service layer before storage.
/// </summary>
public class CameraCredentials
{
public Guid CameraId { get; private set; }
public string OnvifUsername { get; private set; } = "admin";
/// <summary>Encrypted at rest via IDataProtector (applied at service layer).</summary>
/// <summary>Encrypted via ICredentialProtector at the service layer.</summary>
public string OnvifPassword { get; private set; } = string.Empty;
/// <summary>Encrypted at rest via IDataProtector (applied at service layer).</summary>
/// <summary>Encrypted via ICredentialProtector at the service layer.</summary>
public string RtspUsername { get; private set; } = string.Empty;
/// <summary>Encrypted at rest via IDataProtector (applied at service layer).</summary>
/// <summary>Encrypted via ICredentialProtector at the service layer.</summary>
public string RtspPassword { get; private set; } = string.Empty;
public DateTime CreatedAt { get; private set; } = DateTime.UtcNow;