Using cookie middleware without ASP.NET Core Identity
If you want to use your own data store and login controls to authenticate a user, Cookie middleware is the best choice. Cookie middleware serializes the user principal into an encrypted cookie and it uses that cookie to validate users on every request. The user principal can be retrieved by calling the HttpContext.User property.
Cookie middleware can be used by adding a NuGet package named Microsoft.AspNetCore.Authentication.Cookies and the following code snippet in the Configure method in the Startup class:
CookieAuthenticationOptions options = new
CookieAuthenticationOptions();
options.AuthenticationScheme = "CookiesMiddlewareAuth";
options.LoginPath = "/Account/Login";
options.AccessDeniedPath = "/Account/AccessDenied";
options.AutomaticAuthenticate = true;
options.AutomaticChallenge = true;
app.UseCookieAuthentication(options);The following table shows a description of few properties that CookieAuthenticationOptions...