From 18ab0b592f302df0f0ef15bba8ed43fe927e45a8 Mon Sep 17 00:00:00 2001 From: quentin Date: Fri, 12 Jul 2024 18:05:54 -0500 Subject: [PATCH] Program now uses Authentication and Authorization --- API/Program.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/API/Program.cs b/API/Program.cs index 46b68d9..8ab0673 100644 --- a/API/Program.cs +++ b/API/Program.cs @@ -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();