Program now uses Authentication and Authorization

This commit is contained in:
quentin 2024-07-12 18:05:54 -05:00
parent 1dd4d3dca7
commit 18ab0b592f

View File

@ -6,6 +6,7 @@ using API.Services;
using API.Services.Interfaces;
using DAL.Contexts;
using DAL.Models;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.EntityFrameworkCore;
using Serilog;
using System.Reflection;
@ -72,6 +73,9 @@ namespace API
return new UserManager(userService, hashingFactory, logger, hashingType);
});
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie();
WebApplication app = builder.Build();
if (app.Environment.IsDevelopment())
@ -85,6 +89,8 @@ namespace API
MinimumSameSitePolicy = SameSiteMode.Strict
});
app.UseAuthorization();
app.UseHttpsRedirection();
app.MapControllers();
app.Run();