Modification du Progam

This commit is contained in:
2025-08-03 17:47:41 +02:00
parent 2b611fe0b0
commit 9a1159d4bc
2 changed files with 7 additions and 10 deletions

View File

@@ -31,6 +31,11 @@ namespace administration
options.Cookie.IsEssential = true;
});
builder.Services.AddAuthentication("BasicAuthentication")
.AddScheme<AuthenticationSchemeOptions, BasicAuthenticationHandler>("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<AuthenticationSchemeOptions, BasicAuthenticationHandler>("BasicAuthentication", null);
app.UseAuthentication();
app.UseAuthorization();
builder.Services.AddAuthorization(options =>
{
options.FallbackPolicy = new AuthorizationPolicyBuilder()
.RequireAuthenticatedUser()
.Build();
});
// Route par défaut
app.MapControllerRoute(
name: "default",