diff --git a/Source/Startup.cs b/Source/Startup.cs index 31e5268..1485131 100644 --- a/Source/Startup.cs +++ b/Source/Startup.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; @@ -30,6 +31,9 @@ namespace QuickCHAT options => options.UseNpgsql(Configuration.GetConnectionString("MainDatabase")) ) .BuildServiceProvider(); + services.AddAntiforgery(); + services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) + .AddCookie(options => options.LoginPath = new PathString("/authorize")); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. @@ -42,7 +46,7 @@ namespace QuickCHAT app.UseHsts(); app.UseHttpsRedirection(); } - + app.UseAuthentication(); app.UseMvc(); } }