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,45 @@
|
||||
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 role with its permissions.</summary>
|
||||
public record RoleResponse(string Name, IReadOnlyList<string> Permissions);
|
||||
|
||||
/// <summary>Response DTO for a list of roles.</summary>
|
||||
public record RolesListResponse(IReadOnlyList<RoleResponse> Roles);
|
||||
|
||||
[ApiController]
|
||||
[Route("api/roles")]
|
||||
[Authorize(AuthenticationSchemes = "JwtBearer", Policy = AppPermissions.AdminUsers)]
|
||||
[EnableRateLimiting("Api")]
|
||||
public class RolesController : ControllerBase
|
||||
{
|
||||
/// <summary>Returns all roles with their associated permissions.</summary>
|
||||
[HttpGet]
|
||||
[ProducesResponseType(typeof(RolesListResponse), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
|
||||
public IActionResult List()
|
||||
{
|
||||
var roles = AppPermissions.RolePermissions
|
||||
.Select(kvp => new RoleResponse(kvp.Key, kvp.Value))
|
||||
.ToList();
|
||||
|
||||
return Ok(new RolesListResponse(roles));
|
||||
}
|
||||
|
||||
/// <summary>Returns a single role with its permissions.</summary>
|
||||
[HttpGet("{name}")]
|
||||
[ProducesResponseType(typeof(RoleResponse), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(void), StatusCodes.Status404NotFound)]
|
||||
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
|
||||
public IActionResult GetByName(string name)
|
||||
{
|
||||
if (!AppPermissions.RolePermissions.TryGetValue(name, out var permissions))
|
||||
return NotFound(new { error = $"Role '{name}' not found" });
|
||||
|
||||
return Ok(new RoleResponse(name, permissions));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user