From 9a1159d4bc58365ebbd1b71796b76b740729fe4b Mon Sep 17 00:00:00 2001 From: Byakuya Date: Sun, 3 Aug 2025 17:47:41 +0200 Subject: [PATCH] Modification du Progam --- Program.cs | 15 ++++++--------- Services/BasicAuthenticationHandler.cs | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/Program.cs b/Program.cs index 06984ba..0a7864e 100644 --- a/Program.cs +++ b/Program.cs @@ -31,6 +31,11 @@ namespace administration options.Cookie.IsEssential = true; }); + builder.Services.AddAuthentication("BasicAuthentication") +.AddScheme("BasicAuthentication", null); + + builder.Services.AddAuthorization(); + // Ajouter les services MVC builder.Services.AddControllersWithViews(); @@ -65,17 +70,9 @@ namespace administration app.UseCors("AllowFrontend"); app.UseSession(); - builder.Services.AddAuthentication("BasicAuthentication") - .AddScheme("BasicAuthentication", null); - app.UseAuthentication(); + app.UseAuthorization(); - builder.Services.AddAuthorization(options => - { - options.FallbackPolicy = new AuthorizationPolicyBuilder() - .RequireAuthenticatedUser() - .Build(); - }); // Route par défaut app.MapControllerRoute( name: "default", diff --git a/Services/BasicAuthenticationHandler.cs b/Services/BasicAuthenticationHandler.cs index d88e0e3..df843ee 100644 --- a/Services/BasicAuthenticationHandler.cs +++ b/Services/BasicAuthenticationHandler.cs @@ -30,7 +30,7 @@ namespace administration.Services var password = credentials[1]; // 🔐 Valide ici tes identifiants - if (username != "admin" || password != "Mf33ksTRLrPKSqQ4cTXitgiSN6BPBt89") + if (username != "admin" || password != Environment.GetEnvironmentVariable("DB_PASSWORD")) return Task.FromResult(AuthenticateResult.Fail("Invalid Username or Password")); var claims = new[] {