Skip to content

Instantly share code, notes, and snippets.

@manoj-choudhari-git
Last active January 25, 2020 20:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manoj-choudhari-git/9859999a22e0b66b855ecef96ba7a124 to your computer and use it in GitHub Desktop.
Save manoj-choudhari-git/9859999a22e0b66b855ecef96ba7a124 to your computer and use it in GitHub Desktop.
Startup Configuration - Adding Authentication Middleware
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("SqlConnection")));
services.AddIdentity<IdentityUser, IdentityRole>(options => options.SignIn.RequireConfirmedAccount = true)
.AddEntityFrameworkStores<ApplicationDbContext>();
services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, options =>
{
options.SlidingExpiration = true;
options.ExpireTimeSpan = new TimeSpan(0, 1, 0);
});
services.AddControllers();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment