feat(api+web): merge REST API and Blazor UI into single process
Previously the API (heimdall-central) and Blazor UI (heimdall-web) ran as separate containers with the Blazor Server making internal HTTP calls to the API. This caused the Blazor circuit to disconnect when the API was unreachable (network error → "Une erreur réseau est survenue"). Now both serve from the same .NET process on the same port: - All 16 API controllers, ExceptionFilter, and SignalR hubs integrated into Heimdall.Web - JWT auth, CORS, rate limiting configured in the unified Program.cs - Dockerfile.central entrypoint runs web/Heimdall.Web.dll - docker-compose simplified: heimdall-central service removed - CI publishes heimdall-web image instead of heimdall-central Also fixes timezone validation on Alpine/tzdata-less environments and enables FluentValidation auto-validation in the API project.
This commit is contained in:
1 parent
892ca88de8
commit
562aabdfc8
30 files changed
+1969
-99
No files matched your search
@@ -0,0 +1,76 @@
|
||||
using Heimdall.Infrastructure.Security;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.RateLimiting;
|
||||
|
||||
namespace Heimdall.Api.Controllers;
|
||||
|
||||
/// <summary>Response DTO for a single permission with its display name and category.</summary>
|
||||
public record PermissionInfo(string Name, string DisplayName, string Category);
|
||||
|
||||
/// <summary>Response DTO for a list of permissions.</summary>
|
||||
public record PermissionsListResponse(IReadOnlyList<PermissionInfo> Permissions);
|
||||
|
||||
[ApiController]
|
||||
[Route("api/permissions")]
|
||||
[Authorize(AuthenticationSchemes = "JwtBearer", Policy = AppPermissions.AdminUsers)]
|
||||
[EnableRateLimiting("Api")]
|
||||
public class PermissionsController : ControllerBase
|
||||
{
|
||||
private static readonly Dictionary<string, string> CategoryMap = new()
|
||||
{
|
||||
["Site."] = "Sites",
|
||||
["Camera."] = "Caméras",
|
||||
["Event."] = "Événements",
|
||||
["Person."] = "Personnes",
|
||||
["Admin."] = "Administration",
|
||||
};
|
||||
|
||||
private static readonly Dictionary<string, string> DisplayNames = new()
|
||||
{
|
||||
[AppPermissions.SiteRead] = "Lecture des sites",
|
||||
[AppPermissions.SiteWrite] = "Écriture des sites",
|
||||
[AppPermissions.SiteDelete] = "Suppression des sites",
|
||||
[AppPermissions.CameraRead] = "Lecture des caméras",
|
||||
[AppPermissions.CameraWrite] = "Écriture des caméras",
|
||||
[AppPermissions.CameraLive] = "Visionnage en direct",
|
||||
[AppPermissions.CameraRecord] = "Enregistrement",
|
||||
[AppPermissions.CameraSnapshot] = "Captures d'écran",
|
||||
[AppPermissions.EventRead] = "Lecture des événements",
|
||||
[AppPermissions.PersonRead] = "Lecture des personnes",
|
||||
[AppPermissions.PersonWrite] = "Écriture des personnes",
|
||||
[AppPermissions.AdminManage] = "Gestion de l'administration",
|
||||
[AppPermissions.AdminUsers] = "Gestion des utilisateurs",
|
||||
[AppPermissions.AdminApiKeys] = "Gestion des clés API",
|
||||
[AppPermissions.AdminJobs] = "Gestion des tâches",
|
||||
};
|
||||
|
||||
/// <summary>Returns all available permissions grouped by category.</summary>
|
||||
[HttpGet]
|
||||
[ProducesResponseType(typeof(PermissionsListResponse), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
|
||||
public IActionResult List()
|
||||
{
|
||||
var allPermissions = AppPermissions.RolePermissions.Values
|
||||
.SelectMany(p => p)
|
||||
.Distinct()
|
||||
.OrderBy(p => p)
|
||||
.Select(p => new PermissionInfo(
|
||||
p,
|
||||
DisplayNames.GetValueOrDefault(p, p),
|
||||
GetCategory(p)))
|
||||
.ToList();
|
||||
|
||||
return Ok(new PermissionsListResponse(allPermissions));
|
||||
}
|
||||
|
||||
private static string GetCategory(string permission)
|
||||
{
|
||||
foreach (var (prefix, category) in CategoryMap)
|
||||
{
|
||||
if (permission.StartsWith(prefix, StringComparison.Ordinal))
|
||||
return category;
|
||||
}
|
||||
return "Autres";
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user