Skip to content

Instantly share code, notes, and snippets.

@hoetz
Last active December 27, 2016 16:02
Show Gist options
  • Save hoetz/3f517a2a28e4e78053b8 to your computer and use it in GitHub Desktop.
Save hoetz/3f517a2a28e4e78053b8 to your computer and use it in GitHub Desktop.
asp.net vNext Identity for dummies: your own storage providers
using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using Microsoft.Framework.ConfigurationModel;
using Microsoft.AspNet.Diagnostics;
using Microsoft.AspNet.Identity;
using ManagementWeb.Models;
using ManagementWeb.Storage;
namespace HelloMvc
{
public class Startup
{
public IConfiguration Configuration { get; private set; }
public void Configure(IApplicationBuilder app)
{
app.UseServices(services =>
{
services.AddIdentity<ApplicationUser, IdentityRole>(Configuration)
.AddDefaultTokenProviders();
services.AddScoped<IRoleStore<IdentityRole>, RoleStore>();
services.AddScoped<IUserStore<ApplicationUser>, UserStore>();
services.AddScoped<SignInManager<ApplicationUser>, SignInManager<ApplicationUser>>();
services.AddScoped<ISignInManager<ApplicationUser>, ApplicationSignInManager>();
services.AddMvc();
});
app.UseErrorPage(ErrorPageOptions.ShowAll);
app.UseMvc();
app.UseIdentity();
}
}
}
public class ApplicationUser : IdentityUser { }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment