Browse Source

Add Antiforgery and Cookie Authentication

master
Nick Rirush 5 years ago
parent
commit
6e8ec037b9
  1. 6
      Source/Startup.cs

6
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();
}
}

Loading…
Cancel
Save