diff --git a/Webzine.WebApplication/Controllers/AccueilController.cs b/Webzine.WebApplication/Controllers/AccueilController.cs
index 7c3d15a..f7832da 100644
--- a/Webzine.WebApplication/Controllers/AccueilController.cs
+++ b/Webzine.WebApplication/Controllers/AccueilController.cs
@@ -1,6 +1,5 @@
namespace Webzine.WebApplication.Controllers
{
- using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Webzine.Repository.Contracts;
@@ -39,7 +38,6 @@
///
/// Le numéro de page pour la pagination des titres (par défaut à 0).
/// La vue Index avec le ViewModel contenant les listes de titres à afficher.
- [Authorize(Roles = "ADMIN")]
public IActionResult Index(int page = 0)
{
this.logger.LogInformation("Arrivée sur la page d'accueil");
diff --git a/Webzine.WebApplication/Middlewares/LogTempsExecutionMiddleware.cs b/Webzine.WebApplication/Middlewares/LogTempsExecutionMiddleware.cs
index 1b86308..6412b00 100644
--- a/Webzine.WebApplication/Middlewares/LogTempsExecutionMiddleware.cs
+++ b/Webzine.WebApplication/Middlewares/LogTempsExecutionMiddleware.cs
@@ -37,26 +37,44 @@
this.logger.LogInformation("[IN] TraceId: {traceId} | Méthode: {methode} | Endpoint: {endpoint}", traceId, methode, endpoint);
- await this.next(context);
-
- // (Après le contrôleur)
- chronometre.Stop(); // arrête le chrono
- var tempsEcoule = chronometre.ElapsedMilliseconds;
-
- var httpCode = context.Response.StatusCode; // exemple: 200, 404, 500
-
- // --- OUT ---
- if (httpCode >= 500)
+ try
{
- this.logger.LogError("[OUT] TraceId: {traceId} | HTTP {httpCode} | Temps: {tempsEcoule} ms | Endpoint: {endpoint}", traceId, httpCode, tempsEcoule, endpoint);
+ await this.next(context);
}
- else if (httpCode >= 400)
+ catch (Exception exception)
{
- this.logger.LogWarning("[OUT] TraceId: {traceId} | HTTP {httpCode} | Temps: {tempsEcoule} ms | Endpoint: {endpoint}", traceId, httpCode, tempsEcoule, endpoint);
+ chronometre.Stop();
+ this.logger.LogError(
+ exception,
+ "[EXCEPTION] TraceId: {traceId} | Temps: {tempsEcoule} ms | Endpoint: {endpoint}",
+ traceId,
+ chronometre.ElapsedMilliseconds,
+ endpoint);
+ throw;
}
- else
+ finally
{
- this.logger.LogInformation("[OUT] TraceId: {traceId} | HTTP {httpCode} | Temps: {tempsEcoule} ms | Endpoint: {endpoint}", traceId, httpCode, tempsEcoule, endpoint);
+ if (chronometre.IsRunning)
+ {
+ chronometre.Stop();
+ }
+
+ var tempsEcoule = chronometre.ElapsedMilliseconds;
+ var httpCode = context.Response.StatusCode; // exemple: 200, 404, 500
+
+ // --- OUT ---
+ if (httpCode >= 500)
+ {
+ this.logger.LogError("[OUT] TraceId: {traceId} | HTTP {httpCode} | Temps: {tempsEcoule} ms | Endpoint: {endpoint}", traceId, httpCode, tempsEcoule, endpoint);
+ }
+ else if (httpCode >= 400)
+ {
+ this.logger.LogWarning("[OUT] TraceId: {traceId} | HTTP {httpCode} | Temps: {tempsEcoule} ms | Endpoint: {endpoint}", traceId, httpCode, tempsEcoule, endpoint);
+ }
+ else
+ {
+ this.logger.LogInformation("[OUT] TraceId: {traceId} | HTTP {httpCode} | Temps: {tempsEcoule} ms | Endpoint: {endpoint}", traceId, httpCode, tempsEcoule, endpoint);
+ }
}
}
}
diff --git a/Webzine.WebApplication/Views/Account/AuthError.cshtml b/Webzine.WebApplication/Views/Account/AuthError.cshtml
new file mode 100644
index 0000000..eb70072
--- /dev/null
+++ b/Webzine.WebApplication/Views/Account/AuthError.cshtml
@@ -0,0 +1,19 @@
+@{
+ ViewData["Title"] = "Erreur de connexion";
+ var message = ViewData["Message"]?.ToString();
+}
+
+
+
Erreur de connexion
+
+
La connexion avec Keycloak n'a pas pu aboutir.
+
+ @if (!string.IsNullOrWhiteSpace(message))
+ {
+
@message
+ }
+
+
+ Retour à l'accueil
+
+
diff --git a/Webzine.WebApplication/appsettings.Production.json b/Webzine.WebApplication/appsettings.Production.json
index f458f85..c6083e7 100644
--- a/Webzine.WebApplication/appsettings.Production.json
+++ b/Webzine.WebApplication/appsettings.Production.json
@@ -4,5 +4,8 @@
"SpotifySeeder": {
"ClientId": "",
"ClientSecret": ""
+ },
+ "Keycloak": {
+ "PublicOrigin": "http://192.168.10.80:8080"
}
}