Modification du Progam
This commit is contained in:
15
Program.cs
15
Program.cs
@@ -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",
|
||||
|
||||
@@ -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[] {
|
||||
|
||||
Reference in New Issue
Block a user