Modification du Progam
This commit is contained in:
15
Program.cs
15
Program.cs
@@ -31,6 +31,11 @@ namespace administration
|
|||||||
options.Cookie.IsEssential = true;
|
options.Cookie.IsEssential = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
builder.Services.AddAuthentication("BasicAuthentication")
|
||||||
|
.AddScheme<AuthenticationSchemeOptions, BasicAuthenticationHandler>("BasicAuthentication", null);
|
||||||
|
|
||||||
|
builder.Services.AddAuthorization();
|
||||||
|
|
||||||
// Ajouter les services MVC
|
// Ajouter les services MVC
|
||||||
builder.Services.AddControllersWithViews();
|
builder.Services.AddControllersWithViews();
|
||||||
|
|
||||||
@@ -65,17 +70,9 @@ namespace administration
|
|||||||
app.UseCors("AllowFrontend");
|
app.UseCors("AllowFrontend");
|
||||||
app.UseSession();
|
app.UseSession();
|
||||||
|
|
||||||
builder.Services.AddAuthentication("BasicAuthentication")
|
|
||||||
.AddScheme<AuthenticationSchemeOptions, BasicAuthenticationHandler>("BasicAuthentication", null);
|
|
||||||
|
|
||||||
app.UseAuthentication();
|
app.UseAuthentication();
|
||||||
|
app.UseAuthorization();
|
||||||
|
|
||||||
builder.Services.AddAuthorization(options =>
|
|
||||||
{
|
|
||||||
options.FallbackPolicy = new AuthorizationPolicyBuilder()
|
|
||||||
.RequireAuthenticatedUser()
|
|
||||||
.Build();
|
|
||||||
});
|
|
||||||
// Route par défaut
|
// Route par défaut
|
||||||
app.MapControllerRoute(
|
app.MapControllerRoute(
|
||||||
name: "default",
|
name: "default",
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ namespace administration.Services
|
|||||||
var password = credentials[1];
|
var password = credentials[1];
|
||||||
|
|
||||||
// 🔐 Valide ici tes identifiants
|
// 🔐 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"));
|
return Task.FromResult(AuthenticateResult.Fail("Invalid Username or Password"));
|
||||||
|
|
||||||
var claims = new[] {
|
var claims = new[] {
|
||||||
|
|||||||
Reference in New Issue
Block a user