diff --git a/src/Heimdall.Agent/Services/AgentState.cs b/src/Heimdall.Agent/Services/AgentState.cs
index 9a8c039..a283e84 100644
--- a/src/Heimdall.Agent/Services/AgentState.cs
+++ b/src/Heimdall.Agent/Services/AgentState.cs
@@ -1,3 +1,4 @@
+using System.Runtime.InteropServices;
using System.Text.Json;
namespace Heimdall.Agent.Services;
@@ -73,13 +74,24 @@ public sealed class AgentState
}
///
- /// Persists the current identity to disk.
+ /// Persists the current identity to disk with restrictive permissions (0600).
+ /// The API key is stored as plaintext — in a production deployment, consider
+ /// encrypting the file or using a hardware-bound keystore (e.g., TPM/TPM2).
///
public async Task SaveAsync(CancellationToken ct = default)
{
Directory.CreateDirectory(_stateDir);
+
+ // Set restrictive directory permissions (owner only)
+ if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
+ File.SetUnixFileMode(_stateDir, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute);
+
var json = JsonSerializer.Serialize(this);
await File.WriteAllTextAsync(StatePath, json, ct);
+
+ // Restrict file to owner read/write only (0600)
+ if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
+ File.SetUnixFileMode(StatePath, UnixFileMode.UserRead | UnixFileMode.UserWrite);
}
///
diff --git a/src/Heimdall.Agent/Services/CameraStreamService.cs b/src/Heimdall.Agent/Services/CameraStreamService.cs
index c41681e..18988da 100644
--- a/src/Heimdall.Agent/Services/CameraStreamService.cs
+++ b/src/Heimdall.Agent/Services/CameraStreamService.cs
@@ -36,13 +36,27 @@ public sealed class CameraStreamService : IDisposable
var psi = new ProcessStartInfo
{
FileName = "ffmpeg",
- Arguments = $"-rtsp_transport tcp -i \"{rtspUrl}\" -f image2pipe -vcodec mjpeg -q:v 3 -update 1 -",
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,
CreateNoWindow = true,
};
+ // Use ArgumentList to prevent argument injection via rtspUrl
+ psi.ArgumentList.Add("-rtsp_transport");
+ psi.ArgumentList.Add("tcp");
+ psi.ArgumentList.Add("-i");
+ psi.ArgumentList.Add(rtspUrl);
+ psi.ArgumentList.Add("-f");
+ psi.ArgumentList.Add("image2pipe");
+ psi.ArgumentList.Add("-vcodec");
+ psi.ArgumentList.Add("mjpeg");
+ psi.ArgumentList.Add("-q:v");
+ psi.ArgumentList.Add("3");
+ psi.ArgumentList.Add("-update");
+ psi.ArgumentList.Add("1");
+ psi.ArgumentList.Add("-");
+
var process = new Process { StartInfo = psi };
process.Start();
@@ -70,6 +84,9 @@ public sealed class CameraStreamService : IDisposable
if (_sessions.TryRemove(cameraId, out var session))
{
session.Cancel();
+ // Mark semaphore as released BEFORE releasing, so CleanupSession's
+ // finally block does NOT double-release (see SemaphoreReleased flag).
+ session.SemaphoreReleased = true;
_throttle.Release();
_logger.LogInformation("Stream stopped for camera {CameraId}", cameraId);
}
diff --git a/src/Heimdall.Api/Controllers/SettingsController.cs b/src/Heimdall.Api/Controllers/SettingsController.cs
index f4fbcec..45a952f 100644
--- a/src/Heimdall.Api/Controllers/SettingsController.cs
+++ b/src/Heimdall.Api/Controllers/SettingsController.cs
@@ -39,7 +39,14 @@ public class SettingsController : ControllerBase
var result = await _settingService.GetAllSettingsAsync(ct);
if (!result.IsSuccess)
return StatusCode(result.StatusCode ?? 400, new { error = result.Error });
- return Ok(result.Data);
+
+ // Redact sensitive values before returning to client
+ var redacted = result.Data!.Select(s => s with
+ {
+ Value = RedactValue(s.ValueType, s.Value, s.Key)
+ }).ToList();
+
+ return Ok(redacted);
}
/// Get a global setting by key (Admin only).
@@ -50,9 +57,16 @@ public class SettingsController : ControllerBase
public async Task GetByKey(string key, CancellationToken ct)
{
var result = await _settingService.GetSettingByKeyAsync(key, ct);
- return result.IsSuccess
- ? Ok(result.Data)
- : NotFound(new { error = result.Error });
+ if (!result.IsSuccess)
+ return NotFound(new { error = result.Error });
+
+ // Redact sensitive values before returning to client
+ var redacted = result.Data! with
+ {
+ Value = RedactValue(result.Data.ValueType, result.Data.Value, result.Data.Key)
+ };
+
+ return Ok(redacted);
}
/// Create a new global setting (Admin only).
diff --git a/src/Heimdall.Application/DTOs/CameraDto.cs b/src/Heimdall.Application/DTOs/CameraDto.cs
index 3488a34..43a6291 100644
--- a/src/Heimdall.Application/DTOs/CameraDto.cs
+++ b/src/Heimdall.Application/DTOs/CameraDto.cs
@@ -12,7 +12,9 @@ public record CreateCameraRequest(
public record UpdateCameraRequest(
string Name,
string? RtspUrl,
- CameraStatus? Status);
+ CameraStatus? Status,
+ string? Manufacturer = null,
+ string? Model = null);
/// Camera response including all discovery and stream test metadata.
public record CameraResponse(
diff --git a/src/Heimdall.Infrastructure/Data/AppDbContext.cs b/src/Heimdall.Infrastructure/Data/AppDbContext.cs
index 5245a0c..8317743 100644
--- a/src/Heimdall.Infrastructure/Data/AppDbContext.cs
+++ b/src/Heimdall.Infrastructure/Data/AppDbContext.cs
@@ -10,15 +10,12 @@ namespace Heimdall.Infrastructure.Data;
public class AppDbContext : IdentityDbContext
{
private readonly AuditInterceptor _auditInterceptor;
- private readonly SoftDeleteInterceptor _softDeleteInterceptor;
public AppDbContext(
DbContextOptions options,
- AuditInterceptor auditInterceptor,
- SoftDeleteInterceptor softDeleteInterceptor) : base(options)
+ AuditInterceptor auditInterceptor) : base(options)
{
_auditInterceptor = auditInterceptor;
- _softDeleteInterceptor = softDeleteInterceptor;
}
// Domain entities
@@ -77,8 +74,7 @@ public class AppDbContext : IdentityDbContext
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.AddInterceptors(
- _auditInterceptor,
- _softDeleteInterceptor);
+ _auditInterceptor);
// Suppress informational EF Core messages that create noise in
// error tracking (GlitchTip #538). Redundant index warnings are
diff --git a/src/Heimdall.Infrastructure/Data/AppDbContextFactory.cs b/src/Heimdall.Infrastructure/Data/AppDbContextFactory.cs
index ed64371..9fba9ff 100644
--- a/src/Heimdall.Infrastructure/Data/AppDbContextFactory.cs
+++ b/src/Heimdall.Infrastructure/Data/AppDbContextFactory.cs
@@ -1,3 +1,4 @@
+
using Heimdall.Infrastructure.Data.Interceptors;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
@@ -22,7 +23,6 @@ public class AppDbContextFactory : IDesignTimeDbContextFactory
return new AppDbContext(
optionsBuilder.Options,
- new AuditInterceptor(),
- new SoftDeleteInterceptor());
+ new AuditInterceptor());
}
}
diff --git a/src/Heimdall.Infrastructure/Data/Interceptors/SoftDeleteInterceptor.cs b/src/Heimdall.Infrastructure/Data/Interceptors/SoftDeleteInterceptor.cs
deleted file mode 100644
index 41901db..0000000
--- a/src/Heimdall.Infrastructure/Data/Interceptors/SoftDeleteInterceptor.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using Heimdall.Domain.Primitives;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Diagnostics;
-
-namespace Heimdall.Infrastructure.Data.Interceptors;
-
-public sealed class SoftDeleteInterceptor : SaveChangesInterceptor
-{
- public override ValueTask> SavingChangesAsync(
- DbContextEventData eventData,
- InterceptionResult result,
- CancellationToken cancellationToken = default)
- {
- if (eventData.Context is null)
- return base.SavingChangesAsync(eventData, result, cancellationToken);
-
- var entries = eventData.Context.ChangeTracker
- .Entries();
-
- foreach (var entry in entries)
- {
- if (entry.State is EntityState.Deleted)
- {
- entry.State = EntityState.Modified;
- entry.Entity.SoftDelete();
- }
- }
-
- return base.SavingChangesAsync(eventData, result, cancellationToken);
- }
-}
diff --git a/src/Heimdall.Infrastructure/DependencyInjection.cs b/src/Heimdall.Infrastructure/DependencyInjection.cs
index 760370b..9c03c7e 100644
--- a/src/Heimdall.Infrastructure/DependencyInjection.cs
+++ b/src/Heimdall.Infrastructure/DependencyInjection.cs
@@ -24,9 +24,8 @@ public static class DependencyInjection
var env = environmentName ?? Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Production";
var isTesting = env == "Testing";
- // EF Core interceptors (registered as singletons — they are stateless)
+ // EF Core interceptor (registered as singleton — it is stateless)
services.AddSingleton();
- services.AddSingleton();
if (isTesting)
{
diff --git a/src/Heimdall.Infrastructure/Migrations/20260716204205_InitialCreate.Designer.cs b/src/Heimdall.Infrastructure/Migrations/20260716204205_InitialCreate.Designer.cs
deleted file mode 100644
index bc89781..0000000
--- a/src/Heimdall.Infrastructure/Migrations/20260716204205_InitialCreate.Designer.cs
+++ /dev/null
@@ -1,841 +0,0 @@
-//
-using System;
-using Heimdall.Infrastructure.Data;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Migrations;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
-
-#nullable disable
-
-namespace Heimdall.Infrastructure.Migrations
-{
- [DbContext(typeof(AppDbContext))]
- [Migration("20260716204205_InitialCreate")]
- partial class InitialCreate
- {
- ///
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .HasAnnotation("ProductVersion", "10.0.8")
- .HasAnnotation("Relational:MaxIdentifierLength", 63);
-
- NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
-
- modelBuilder.Entity("Heimdall.Domain.Entities.Agent", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("uuid");
-
- b.Property("ApiKeyHash")
- .HasMaxLength(128)
- .HasColumnType("character varying(128)");
-
- b.Property("ApiKeyPrefix")
- .HasMaxLength(8)
- .HasColumnType("character varying(8)");
-
- b.Property("CpuCores")
- .HasColumnType("integer");
-
- b.Property("CreatedAt")
- .ValueGeneratedOnAdd()
- .HasColumnType("timestamp with time zone")
- .HasDefaultValueSql("NOW()");
-
- b.Property("DeletedAt")
- .HasColumnType("timestamp with time zone");
-
- b.Property("GpuType")
- .IsRequired()
- .HasMaxLength(20)
- .HasColumnType("character varying(20)");
-
- b.Property("HasGpu")
- .HasColumnType("boolean");
-
- b.Property("Hostname")
- .IsRequired()
- .HasMaxLength(255)
- .HasColumnType("character varying(255)");
-
- b.Property("IsDeleted")
- .HasColumnType("boolean");
-
- b.Property("LastHeartbeat")
- .HasColumnType("timestamp with time zone");
-
- b.Property("MemoryMb")
- .HasColumnType("bigint");
-
- b.Property("Name")
- .IsRequired()
- .HasMaxLength(200)
- .HasColumnType("character varying(200)");
-
- b.Property("PublicIp")
- .HasMaxLength(45)
- .HasColumnType("character varying(45)");
-
- b.Property("SiteId")
- .HasColumnType("uuid");
-
- b.Property("Status")
- .IsRequired()
- .HasMaxLength(20)
- .HasColumnType("character varying(20)");
-
- b.Property("UpdatedAt")
- .ValueGeneratedOnAdd()
- .HasColumnType("timestamp with time zone")
- .HasDefaultValueSql("NOW()");
-
- b.Property("Version")
- .IsRequired()
- .HasMaxLength(50)
- .HasColumnType("character varying(50)");
-
- b.HasKey("Id");
-
- b.HasIndex("LastHeartbeat")
- .HasFilter("\"Status\" = 'Online'");
-
- b.HasIndex("SiteId");
-
- b.ToTable("agents", (string)null);
- });
-
- modelBuilder.Entity("Heimdall.Domain.Entities.ApiKey", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("uuid");
-
- b.Property("CreatedAt")
- .ValueGeneratedOnAdd()
- .HasColumnType("timestamp with time zone")
- .HasDefaultValueSql("NOW()");
-
- b.Property("CreatedByUserId")
- .HasColumnType("uuid");
-
- b.Property("Enabled")
- .HasColumnType("boolean");
-
- b.Property("ExpiresAt")
- .HasColumnType("timestamp with time zone");
-
- b.Property("KeyHash")
- .IsRequired()
- .HasMaxLength(128)
- .HasColumnType("character varying(128)");
-
- b.Property("KeyPrefix")
- .IsRequired()
- .HasMaxLength(8)
- .HasColumnType("character varying(8)");
-
- b.Property("LastUsedAt")
- .HasColumnType("timestamp with time zone");
-
- b.Property("SiteId")
- .HasColumnType("uuid");
-
- b.HasKey("Id");
-
- b.HasIndex("KeyHash");
-
- b.HasIndex("KeyPrefix");
-
- b.HasIndex("SiteId");
-
- b.ToTable("api_keys", (string)null);
- });
-
- modelBuilder.Entity("Heimdall.Domain.Entities.AppRole", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("uuid");
-
- b.Property("ConcurrencyStamp")
- .IsConcurrencyToken()
- .HasColumnType("text");
-
- b.Property("Name")
- .HasMaxLength(256)
- .HasColumnType("character varying(256)");
-
- b.Property("NormalizedName")
- .HasMaxLength(256)
- .HasColumnType("character varying(256)");
-
- b.HasKey("Id");
-
- b.HasIndex("NormalizedName")
- .IsUnique()
- .HasDatabaseName("RoleNameIndex");
-
- b.ToTable("roles", (string)null);
- });
-
- modelBuilder.Entity("Heimdall.Domain.Entities.AppUser", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("uuid");
-
- b.Property("AccessFailedCount")
- .HasColumnType("integer");
-
- b.Property("ConcurrencyStamp")
- .IsConcurrencyToken()
- .HasColumnType("text");
-
- b.Property("CreatedAt")
- .ValueGeneratedOnAdd()
- .HasColumnType("timestamp with time zone")
- .HasDefaultValueSql("NOW()");
-
- b.Property("DisplayName")
- .IsRequired()
- .HasMaxLength(200)
- .HasColumnType("character varying(200)");
-
- b.Property("Email")
- .HasMaxLength(256)
- .HasColumnType("character varying(256)");
-
- b.Property("EmailConfirmed")
- .HasColumnType("boolean");
-
- b.Property("Language")
- .IsRequired()
- .ValueGeneratedOnAdd()
- .HasMaxLength(10)
- .HasColumnType("character varying(10)")
- .HasDefaultValue("fr");
-
- b.Property("LockoutEnabled")
- .HasColumnType("boolean");
-
- b.Property("LockoutEnd")
- .HasColumnType("timestamp with time zone");
-
- b.Property("NormalizedEmail")
- .HasMaxLength(256)
- .HasColumnType("character varying(256)");
-
- b.Property("NormalizedUserName")
- .HasMaxLength(256)
- .HasColumnType("character varying(256)");
-
- b.Property("PasswordHash")
- .HasColumnType("text");
-
- b.Property("PhoneNumber")
- .HasColumnType("text");
-
- b.Property("PhoneNumberConfirmed")
- .HasColumnType("boolean");
-
- b.Property("SecurityStamp")
- .HasColumnType("text");
-
- b.Property("Theme")
- .ValueGeneratedOnAdd()
- .HasMaxLength(20)
- .HasColumnType("character varying(20)")
- .HasDefaultValue("Auto");
-
- b.Property("TwoFactorEnabled")
- .HasColumnType("boolean");
-
- b.Property("UserName")
- .HasMaxLength(256)
- .HasColumnType("character varying(256)");
-
- b.HasKey("Id");
-
- b.HasIndex("NormalizedEmail")
- .HasDatabaseName("EmailIndex");
-
- b.HasIndex("NormalizedUserName")
- .IsUnique()
- .HasDatabaseName("UserNameIndex");
-
- b.ToTable("users", (string)null);
- });
-
- modelBuilder.Entity("Heimdall.Domain.Entities.AuditLog", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("uuid");
-
- b.Property("Action")
- .IsRequired()
- .HasMaxLength(100)
- .HasColumnType("character varying(100)");
-
- b.Property("IpAddress")
- .HasMaxLength(45)
- .HasColumnType("character varying(45)");
-
- b.Property("NewValue")
- .HasColumnType("text");
-
- b.Property("OldValue")
- .HasColumnType("text");
-
- b.Property("ResourceId")
- .HasMaxLength(100)
- .HasColumnType("character varying(100)");
-
- b.Property("ResourceType")
- .IsRequired()
- .HasMaxLength(100)
- .HasColumnType("character varying(100)");
-
- b.Property("Timestamp")
- .ValueGeneratedOnAdd()
- .HasColumnType("timestamp with time zone")
- .HasDefaultValueSql("NOW()");
-
- b.Property("UserId")
- .HasColumnType("uuid");
-
- b.HasKey("Id");
-
- b.HasIndex("Timestamp")
- .IsDescending();
-
- b.HasIndex("UserId");
-
- b.HasIndex("ResourceType", "ResourceId", "Timestamp")
- .IsDescending(false, false, true);
-
- b.ToTable("audit_logs", (string)null);
- });
-
- modelBuilder.Entity("Heimdall.Domain.Entities.Camera", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("uuid");
-
- b.Property("AgentId")
- .HasColumnType("uuid");
-
- b.Property("CreatedAt")
- .ValueGeneratedOnAdd()
- .HasColumnType("timestamp with time zone")
- .HasDefaultValueSql("NOW()");
-
- b.Property("DeletedAt")
- .HasColumnType("timestamp with time zone");
-
- b.Property("HasAudio")
- .HasColumnType("boolean");
-
- b.Property("HasMotionDetection")
- .HasColumnType("boolean");
-
- b.Property("HasPtz")
- .HasColumnType("boolean");
-
- b.Property("IsDeleted")
- .HasColumnType("boolean");
-
- b.Property("Manufacturer")
- .HasMaxLength(100)
- .HasColumnType("character varying(100)");
-
- b.Property("Model")
- .HasMaxLength(100)
- .HasColumnType("character varying(100)");
-
- b.Property("Name")
- .IsRequired()
- .HasMaxLength(200)
- .HasColumnType("character varying(200)");
-
- b.Property("RtspUrl")
- .HasMaxLength(1000)
- .HasColumnType("character varying(1000)");
-
- b.Property("SiteId")
- .HasColumnType("uuid");
-
- b.Property("Status")
- .IsRequired()
- .HasMaxLength(20)
- .HasColumnType("character varying(20)");
-
- b.Property("UpdatedAt")
- .ValueGeneratedOnAdd()
- .HasColumnType("timestamp with time zone")
- .HasDefaultValueSql("NOW()");
-
- b.HasKey("Id");
-
- b.HasIndex("AgentId");
-
- b.HasIndex("SiteId");
-
- b.ToTable("cameras", (string)null);
- });
-
- modelBuilder.Entity("Heimdall.Domain.Entities.CameraCredentials", b =>
- {
- b.Property("CameraId")
- .HasColumnType("uuid");
-
- b.Property("CreatedAt")
- .ValueGeneratedOnAdd()
- .HasColumnType("timestamp with time zone")
- .HasDefaultValueSql("NOW()");
-
- b.Property("OnvifPassword")
- .IsRequired()
- .HasMaxLength(500)
- .HasColumnType("character varying(500)");
-
- b.Property("OnvifUsername")
- .IsRequired()
- .ValueGeneratedOnAdd()
- .HasMaxLength(100)
- .HasColumnType("character varying(100)")
- .HasDefaultValue("admin");
-
- b.Property("RtspPassword")
- .IsRequired()
- .HasMaxLength(500)
- .HasColumnType("character varying(500)");
-
- b.Property("RtspUsername")
- .IsRequired()
- .HasMaxLength(100)
- .HasColumnType("character varying(100)");
-
- b.Property("UpdatedAt")
- .ValueGeneratedOnAdd()
- .HasColumnType("timestamp with time zone")
- .HasDefaultValueSql("NOW()");
-
- b.HasKey("CameraId");
-
- b.ToTable("camera_credentials", (string)null);
- });
-
- modelBuilder.Entity("Heimdall.Domain.Entities.CameraDetectionProfile", b =>
- {
- b.Property("CameraId")
- .HasColumnType("uuid");
-
- b.Property("ActiveIntervalMs")
- .HasColumnType("integer");
-
- b.Property("AnimalCooldownSec")
- .HasColumnType("integer");
-
- b.Property("DetectAnimal")
- .HasColumnType("boolean");
-
- b.Property("DetectMotion")
- .HasColumnType("boolean");
-
- b.Property("DetectPackage")
- .HasColumnType("boolean");
-
- b.Property("DetectPerson")
- .HasColumnType("boolean");
-
- b.Property("DetectVehicle")
- .HasColumnType("boolean");
-
- b.Property("FaceRecognition")
- .HasColumnType("boolean");
-
- b.Property("IdleIntervalMs")
- .HasColumnType("integer");
-
- b.Property("IoUThreshold")
- .HasColumnType("double precision");
-
- b.Property("LicensePlateRecognition")
- .HasColumnType("boolean");
-
- b.Property("MaxEventsPerMinute")
- .HasColumnType("integer");
-
- b.Property("MinConfidence")
- .ValueGeneratedOnAdd()
- .HasColumnType("double precision")
- .HasDefaultValue(0.40000000000000002);
-
- b.Property("MotionIntervalMs")
- .HasColumnType("integer");
-
- b.Property("MotionThreshold")
- .HasColumnType("double precision");
-
- b.Property("PersonCooldownSec")
- .HasColumnType("integer");
-
- b.Property("RequireMotionForAI")
- .HasColumnType("boolean");
-
- b.Property("VehicleCooldownSec")
- .HasColumnType("integer");
-
- b.Property("YoloModel")
- .IsRequired()
- .ValueGeneratedOnAdd()
- .HasMaxLength(50)
- .HasColumnType("character varying(50)")
- .HasDefaultValue("yolov8n");
-
- b.HasKey("CameraId");
-
- b.ToTable("camera_detection_profiles", (string)null);
- });
-
- modelBuilder.Entity("Heimdall.Domain.Entities.Site", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("uuid");
-
- b.Property("Address")
- .HasMaxLength(500)
- .HasColumnType("character varying(500)");
-
- b.Property("CreatedAt")
- .ValueGeneratedOnAdd()
- .HasColumnType("timestamp with time zone")
- .HasDefaultValueSql("NOW()");
-
- b.Property("DeletedAt")
- .HasColumnType("timestamp with time zone");
-
- b.Property("Enabled")
- .HasColumnType("boolean");
-
- b.Property("IsDeleted")
- .HasColumnType("boolean");
-
- b.Property("Name")
- .IsRequired()
- .HasMaxLength(200)
- .HasColumnType("character varying(200)");
-
- b.Property("RegistrationTokenHash")
- .HasMaxLength(128)
- .HasColumnType("character varying(128)");
-
- b.Property("Timezone")
- .IsRequired()
- .ValueGeneratedOnAdd()
- .HasMaxLength(100)
- .HasColumnType("character varying(100)")
- .HasDefaultValue("UTC");
-
- b.Property("TokenExpiresAt")
- .HasColumnType("timestamp with time zone");
-
- b.Property("UpdatedAt")
- .ValueGeneratedOnAdd()
- .HasColumnType("timestamp with time zone")
- .HasDefaultValueSql("NOW()");
-
- b.HasKey("Id");
-
- b.HasIndex("IsDeleted")
- .HasFilter("\"IsDeleted\" = false");
-
- b.HasIndex("Name");
-
- b.ToTable("sites", (string)null);
- });
-
- modelBuilder.Entity("Heimdall.Domain.Entities.UserSite", b =>
- {
- b.Property("UserId")
- .HasColumnType("uuid");
-
- b.Property("SiteId")
- .HasColumnType("uuid");
-
- b.HasKey("UserId", "SiteId");
-
- b.HasIndex("SiteId");
-
- b.ToTable("user_sites", (string)null);
- });
-
- modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("integer");
-
- NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
-
- b.Property("ClaimType")
- .HasColumnType("text");
-
- b.Property("ClaimValue")
- .HasColumnType("text");
-
- b.Property("RoleId")
- .HasColumnType("uuid");
-
- b.HasKey("Id");
-
- b.HasIndex("RoleId");
-
- b.ToTable("role_claims", (string)null);
- });
-
- modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("integer");
-
- NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
-
- b.Property("ClaimType")
- .HasColumnType("text");
-
- b.Property("ClaimValue")
- .HasColumnType("text");
-
- b.Property("UserId")
- .HasColumnType("uuid");
-
- b.HasKey("Id");
-
- b.HasIndex("UserId");
-
- b.ToTable("user_claims", (string)null);
- });
-
- modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b =>
- {
- b.Property("LoginProvider")
- .HasColumnType("text");
-
- b.Property("ProviderKey")
- .HasColumnType("text");
-
- b.Property("ProviderDisplayName")
- .HasColumnType("text");
-
- b.Property("UserId")
- .HasColumnType("uuid");
-
- b.HasKey("LoginProvider", "ProviderKey");
-
- b.HasIndex("UserId");
-
- b.ToTable("user_logins", (string)null);
- });
-
- modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b =>
- {
- b.Property("UserId")
- .HasColumnType("uuid");
-
- b.Property("RoleId")
- .HasColumnType("uuid");
-
- b.HasKey("UserId", "RoleId");
-
- b.HasIndex("RoleId");
-
- b.ToTable("user_roles", (string)null);
- });
-
- modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b =>
- {
- b.Property("UserId")
- .HasColumnType("uuid");
-
- b.Property("LoginProvider")
- .HasColumnType("text");
-
- b.Property("Name")
- .HasColumnType("text");
-
- b.Property("Value")
- .HasColumnType("text");
-
- b.HasKey("UserId", "LoginProvider", "Name");
-
- b.ToTable("user_tokens", (string)null);
- });
-
- modelBuilder.Entity("Heimdall.Domain.Entities.Agent", b =>
- {
- b.HasOne("Heimdall.Domain.Entities.Site", "Site")
- .WithMany("Agents")
- .HasForeignKey("SiteId")
- .OnDelete(DeleteBehavior.Restrict)
- .IsRequired();
-
- b.Navigation("Site");
- });
-
- modelBuilder.Entity("Heimdall.Domain.Entities.ApiKey", b =>
- {
- b.HasOne("Heimdall.Domain.Entities.Site", "Site")
- .WithMany()
- .HasForeignKey("SiteId")
- .OnDelete(DeleteBehavior.Restrict);
-
- b.Navigation("Site");
- });
-
- modelBuilder.Entity("Heimdall.Domain.Entities.Camera", b =>
- {
- b.HasOne("Heimdall.Domain.Entities.Agent", "Agent")
- .WithMany("Cameras")
- .HasForeignKey("AgentId")
- .OnDelete(DeleteBehavior.SetNull);
-
- b.HasOne("Heimdall.Domain.Entities.Site", "Site")
- .WithMany("Cameras")
- .HasForeignKey("SiteId")
- .OnDelete(DeleteBehavior.Restrict)
- .IsRequired();
-
- b.Navigation("Agent");
-
- b.Navigation("Site");
- });
-
- modelBuilder.Entity("Heimdall.Domain.Entities.CameraCredentials", b =>
- {
- b.HasOne("Heimdall.Domain.Entities.Camera", "Camera")
- .WithOne("Credentials")
- .HasForeignKey("Heimdall.Domain.Entities.CameraCredentials", "CameraId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("Camera");
- });
-
- modelBuilder.Entity("Heimdall.Domain.Entities.CameraDetectionProfile", b =>
- {
- b.HasOne("Heimdall.Domain.Entities.Camera", "Camera")
- .WithOne("DetectionProfile")
- .HasForeignKey("Heimdall.Domain.Entities.CameraDetectionProfile", "CameraId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("Camera");
- });
-
- modelBuilder.Entity("Heimdall.Domain.Entities.UserSite", b =>
- {
- b.HasOne("Heimdall.Domain.Entities.Site", "Site")
- .WithMany()
- .HasForeignKey("SiteId")
- .OnDelete(DeleteBehavior.Restrict)
- .IsRequired();
-
- b.HasOne("Heimdall.Domain.Entities.AppUser", "User")
- .WithMany("UserSites")
- .HasForeignKey("UserId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("Site");
-
- b.Navigation("User");
- });
-
- modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b =>
- {
- b.HasOne("Heimdall.Domain.Entities.AppRole", null)
- .WithMany()
- .HasForeignKey("RoleId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
- });
-
- modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b =>
- {
- b.HasOne("Heimdall.Domain.Entities.AppUser", null)
- .WithMany()
- .HasForeignKey("UserId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
- });
-
- modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b =>
- {
- b.HasOne("Heimdall.Domain.Entities.AppUser", null)
- .WithMany()
- .HasForeignKey("UserId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
- });
-
- modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b =>
- {
- b.HasOne("Heimdall.Domain.Entities.AppRole", null)
- .WithMany()
- .HasForeignKey("RoleId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.HasOne("Heimdall.Domain.Entities.AppUser", null)
- .WithMany()
- .HasForeignKey("UserId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
- });
-
- modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b =>
- {
- b.HasOne("Heimdall.Domain.Entities.AppUser", null)
- .WithMany()
- .HasForeignKey("UserId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
- });
-
- modelBuilder.Entity("Heimdall.Domain.Entities.Agent", b =>
- {
- b.Navigation("Cameras");
- });
-
- modelBuilder.Entity("Heimdall.Domain.Entities.AppUser", b =>
- {
- b.Navigation("UserSites");
- });
-
- modelBuilder.Entity("Heimdall.Domain.Entities.Camera", b =>
- {
- b.Navigation("Credentials");
-
- b.Navigation("DetectionProfile");
- });
-
- modelBuilder.Entity("Heimdall.Domain.Entities.Site", b =>
- {
- b.Navigation("Agents");
-
- b.Navigation("Cameras");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/src/Heimdall.Infrastructure/Migrations/20260717192108_AddMustChangePassword.Designer.cs b/src/Heimdall.Infrastructure/Migrations/20260717192108_AddMustChangePassword.Designer.cs
deleted file mode 100644
index e30130f..0000000
--- a/src/Heimdall.Infrastructure/Migrations/20260717192108_AddMustChangePassword.Designer.cs
+++ /dev/null
@@ -1,846 +0,0 @@
-//
-using System;
-using Heimdall.Infrastructure.Data;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Migrations;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
-
-#nullable disable
-
-namespace Heimdall.Infrastructure.Migrations
-{
- [DbContext(typeof(AppDbContext))]
- [Migration("20260717192108_AddMustChangePassword")]
- partial class AddMustChangePassword
- {
- ///
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .HasAnnotation("ProductVersion", "10.0.8")
- .HasAnnotation("Relational:MaxIdentifierLength", 63);
-
- NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
-
- modelBuilder.Entity("Heimdall.Domain.Entities.Agent", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("uuid");
-
- b.Property("ApiKeyHash")
- .HasMaxLength(128)
- .HasColumnType("character varying(128)");
-
- b.Property("ApiKeyPrefix")
- .HasMaxLength(8)
- .HasColumnType("character varying(8)");
-
- b.Property("CpuCores")
- .HasColumnType("integer");
-
- b.Property("CreatedAt")
- .ValueGeneratedOnAdd()
- .HasColumnType("timestamp with time zone")
- .HasDefaultValueSql("NOW()");
-
- b.Property("DeletedAt")
- .HasColumnType("timestamp with time zone");
-
- b.Property("GpuType")
- .IsRequired()
- .HasMaxLength(20)
- .HasColumnType("character varying(20)");
-
- b.Property("HasGpu")
- .HasColumnType("boolean");
-
- b.Property("Hostname")
- .IsRequired()
- .HasMaxLength(255)
- .HasColumnType("character varying(255)");
-
- b.Property("IsDeleted")
- .HasColumnType("boolean");
-
- b.Property("LastHeartbeat")
- .HasColumnType("timestamp with time zone");
-
- b.Property("MemoryMb")
- .HasColumnType("bigint");
-
- b.Property("Name")
- .IsRequired()
- .HasMaxLength(200)
- .HasColumnType("character varying(200)");
-
- b.Property("PublicIp")
- .HasMaxLength(45)
- .HasColumnType("character varying(45)");
-
- b.Property("SiteId")
- .HasColumnType("uuid");
-
- b.Property("Status")
- .IsRequired()
- .HasMaxLength(20)
- .HasColumnType("character varying(20)");
-
- b.Property("UpdatedAt")
- .ValueGeneratedOnAdd()
- .HasColumnType("timestamp with time zone")
- .HasDefaultValueSql("NOW()");
-
- b.Property("Version")
- .IsRequired()
- .HasMaxLength(50)
- .HasColumnType("character varying(50)");
-
- b.HasKey("Id");
-
- b.HasIndex("LastHeartbeat")
- .HasFilter("\"Status\" = 'Online'");
-
- b.HasIndex("SiteId");
-
- b.ToTable("agents", (string)null);
- });
-
- modelBuilder.Entity("Heimdall.Domain.Entities.ApiKey", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("uuid");
-
- b.Property("CreatedAt")
- .ValueGeneratedOnAdd()
- .HasColumnType("timestamp with time zone")
- .HasDefaultValueSql("NOW()");
-
- b.Property("CreatedByUserId")
- .HasColumnType("uuid");
-
- b.Property("Enabled")
- .HasColumnType("boolean");
-
- b.Property("ExpiresAt")
- .HasColumnType("timestamp with time zone");
-
- b.Property("KeyHash")
- .IsRequired()
- .HasMaxLength(128)
- .HasColumnType("character varying(128)");
-
- b.Property("KeyPrefix")
- .IsRequired()
- .HasMaxLength(8)
- .HasColumnType("character varying(8)");
-
- b.Property("LastUsedAt")
- .HasColumnType("timestamp with time zone");
-
- b.Property("SiteId")
- .HasColumnType("uuid");
-
- b.HasKey("Id");
-
- b.HasIndex("KeyHash");
-
- b.HasIndex("KeyPrefix");
-
- b.HasIndex("SiteId");
-
- b.ToTable("api_keys", (string)null);
- });
-
- modelBuilder.Entity("Heimdall.Domain.Entities.AppRole", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("uuid");
-
- b.Property("ConcurrencyStamp")
- .IsConcurrencyToken()
- .HasColumnType("text");
-
- b.Property("Name")
- .HasMaxLength(256)
- .HasColumnType("character varying(256)");
-
- b.Property("NormalizedName")
- .HasMaxLength(256)
- .HasColumnType("character varying(256)");
-
- b.HasKey("Id");
-
- b.HasIndex("NormalizedName")
- .IsUnique()
- .HasDatabaseName("RoleNameIndex");
-
- b.ToTable("roles", (string)null);
- });
-
- modelBuilder.Entity("Heimdall.Domain.Entities.AppUser", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("uuid");
-
- b.Property("AccessFailedCount")
- .HasColumnType("integer");
-
- b.Property("ConcurrencyStamp")
- .IsConcurrencyToken()
- .HasColumnType("text");
-
- b.Property("CreatedAt")
- .ValueGeneratedOnAdd()
- .HasColumnType("timestamp with time zone")
- .HasDefaultValueSql("NOW()");
-
- b.Property("DisplayName")
- .IsRequired()
- .HasMaxLength(200)
- .HasColumnType("character varying(200)");
-
- b.Property("Email")
- .HasMaxLength(256)
- .HasColumnType("character varying(256)");
-
- b.Property("EmailConfirmed")
- .HasColumnType("boolean");
-
- b.Property("Language")
- .IsRequired()
- .ValueGeneratedOnAdd()
- .HasMaxLength(10)
- .HasColumnType("character varying(10)")
- .HasDefaultValue("fr");
-
- b.Property("LockoutEnabled")
- .HasColumnType("boolean");
-
- b.Property("LockoutEnd")
- .HasColumnType("timestamp with time zone");
-
- b.Property("MustChangePassword")
- .ValueGeneratedOnAdd()
- .HasColumnType("boolean")
- .HasDefaultValue(false);
-
- b.Property("NormalizedEmail")
- .HasMaxLength(256)
- .HasColumnType("character varying(256)");
-
- b.Property("NormalizedUserName")
- .HasMaxLength(256)
- .HasColumnType("character varying(256)");
-
- b.Property("PasswordHash")
- .HasColumnType("text");
-
- b.Property("PhoneNumber")
- .HasColumnType("text");
-
- b.Property("PhoneNumberConfirmed")
- .HasColumnType("boolean");
-
- b.Property("SecurityStamp")
- .HasColumnType("text");
-
- b.Property("Theme")
- .ValueGeneratedOnAdd()
- .HasMaxLength(20)
- .HasColumnType("character varying(20)")
- .HasDefaultValue("Auto");
-
- b.Property("TwoFactorEnabled")
- .HasColumnType("boolean");
-
- b.Property("UserName")
- .HasMaxLength(256)
- .HasColumnType("character varying(256)");
-
- b.HasKey("Id");
-
- b.HasIndex("NormalizedEmail")
- .HasDatabaseName("EmailIndex");
-
- b.HasIndex("NormalizedUserName")
- .IsUnique()
- .HasDatabaseName("UserNameIndex");
-
- b.ToTable("users", (string)null);
- });
-
- modelBuilder.Entity("Heimdall.Domain.Entities.AuditLog", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("uuid");
-
- b.Property("Action")
- .IsRequired()
- .HasMaxLength(100)
- .HasColumnType("character varying(100)");
-
- b.Property("IpAddress")
- .HasMaxLength(45)
- .HasColumnType("character varying(45)");
-
- b.Property("NewValue")
- .HasColumnType("text");
-
- b.Property("OldValue")
- .HasColumnType("text");
-
- b.Property("ResourceId")
- .HasMaxLength(100)
- .HasColumnType("character varying(100)");
-
- b.Property("ResourceType")
- .IsRequired()
- .HasMaxLength(100)
- .HasColumnType("character varying(100)");
-
- b.Property("Timestamp")
- .ValueGeneratedOnAdd()
- .HasColumnType("timestamp with time zone")
- .HasDefaultValueSql("NOW()");
-
- b.Property("UserId")
- .HasColumnType("uuid");
-
- b.HasKey("Id");
-
- b.HasIndex("Timestamp")
- .IsDescending();
-
- b.HasIndex("UserId");
-
- b.HasIndex("ResourceType", "ResourceId", "Timestamp")
- .IsDescending(false, false, true);
-
- b.ToTable("audit_logs", (string)null);
- });
-
- modelBuilder.Entity("Heimdall.Domain.Entities.Camera", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("uuid");
-
- b.Property("AgentId")
- .HasColumnType("uuid");
-
- b.Property("CreatedAt")
- .ValueGeneratedOnAdd()
- .HasColumnType("timestamp with time zone")
- .HasDefaultValueSql("NOW()");
-
- b.Property("DeletedAt")
- .HasColumnType("timestamp with time zone");
-
- b.Property("HasAudio")
- .HasColumnType("boolean");
-
- b.Property("HasMotionDetection")
- .HasColumnType("boolean");
-
- b.Property("HasPtz")
- .HasColumnType("boolean");
-
- b.Property("IsDeleted")
- .HasColumnType("boolean");
-
- b.Property("Manufacturer")
- .HasMaxLength(100)
- .HasColumnType("character varying(100)");
-
- b.Property("Model")
- .HasMaxLength(100)
- .HasColumnType("character varying(100)");
-
- b.Property("Name")
- .IsRequired()
- .HasMaxLength(200)
- .HasColumnType("character varying(200)");
-
- b.Property("RtspUrl")
- .HasMaxLength(1000)
- .HasColumnType("character varying(1000)");
-
- b.Property("SiteId")
- .HasColumnType("uuid");
-
- b.Property("Status")
- .IsRequired()
- .HasMaxLength(20)
- .HasColumnType("character varying(20)");
-
- b.Property("UpdatedAt")
- .ValueGeneratedOnAdd()
- .HasColumnType("timestamp with time zone")
- .HasDefaultValueSql("NOW()");
-
- b.HasKey("Id");
-
- b.HasIndex("AgentId");
-
- b.HasIndex("SiteId");
-
- b.ToTable("cameras", (string)null);
- });
-
- modelBuilder.Entity("Heimdall.Domain.Entities.CameraCredentials", b =>
- {
- b.Property("CameraId")
- .HasColumnType("uuid");
-
- b.Property("CreatedAt")
- .ValueGeneratedOnAdd()
- .HasColumnType("timestamp with time zone")
- .HasDefaultValueSql("NOW()");
-
- b.Property("OnvifPassword")
- .IsRequired()
- .HasMaxLength(500)
- .HasColumnType("character varying(500)");
-
- b.Property("OnvifUsername")
- .IsRequired()
- .ValueGeneratedOnAdd()
- .HasMaxLength(100)
- .HasColumnType("character varying(100)")
- .HasDefaultValue("admin");
-
- b.Property("RtspPassword")
- .IsRequired()
- .HasMaxLength(500)
- .HasColumnType("character varying(500)");
-
- b.Property("RtspUsername")
- .IsRequired()
- .HasMaxLength(100)
- .HasColumnType("character varying(100)");
-
- b.Property("UpdatedAt")
- .ValueGeneratedOnAdd()
- .HasColumnType("timestamp with time zone")
- .HasDefaultValueSql("NOW()");
-
- b.HasKey("CameraId");
-
- b.ToTable("camera_credentials", (string)null);
- });
-
- modelBuilder.Entity("Heimdall.Domain.Entities.CameraDetectionProfile", b =>
- {
- b.Property("CameraId")
- .HasColumnType("uuid");
-
- b.Property("ActiveIntervalMs")
- .HasColumnType("integer");
-
- b.Property("AnimalCooldownSec")
- .HasColumnType("integer");
-
- b.Property("DetectAnimal")
- .HasColumnType("boolean");
-
- b.Property("DetectMotion")
- .HasColumnType("boolean");
-
- b.Property("DetectPackage")
- .HasColumnType("boolean");
-
- b.Property("DetectPerson")
- .HasColumnType("boolean");
-
- b.Property("DetectVehicle")
- .HasColumnType("boolean");
-
- b.Property("FaceRecognition")
- .HasColumnType("boolean");
-
- b.Property("IdleIntervalMs")
- .HasColumnType("integer");
-
- b.Property("IoUThreshold")
- .HasColumnType("double precision");
-
- b.Property("LicensePlateRecognition")
- .HasColumnType("boolean");
-
- b.Property("MaxEventsPerMinute")
- .HasColumnType("integer");
-
- b.Property("MinConfidence")
- .ValueGeneratedOnAdd()
- .HasColumnType("double precision")
- .HasDefaultValue(0.40000000000000002);
-
- b.Property("MotionIntervalMs")
- .HasColumnType("integer");
-
- b.Property("MotionThreshold")
- .HasColumnType("double precision");
-
- b.Property("PersonCooldownSec")
- .HasColumnType("integer");
-
- b.Property