Пример #1
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllersWithViews();

            services.AddDbContext <DataContext>(options =>
            {
                options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"));
            })
            .AddIdentity <IdentityUser, IdentityRole>(options =>
            {
                options.Password.RequireDigit           = false;
                options.Password.RequireLowercase       = false;
                options.Password.RequireNonAlphanumeric = false;
                options.Password.RequireUppercase       = false;
                options.Password.RequiredLength         = 5;
            })
            .AddEntityFrameworkStores <DataContext>();

            services.AddIdentityServer(options =>
            {
                options.UserInteraction.LoginUrl  = "/Home/Login";
                options.UserInteraction.LogoutUrl = "/Home/Logout";
            })
            .AddAspNetIdentity <IdentityUser>()
            .AddInMemoryApiResources(IdentityServerConfiguration.GetApiResources())
            .AddInMemoryApiScopes(IdentityServerConfiguration.GetScopes())
            .AddInMemoryClients(IdentityServerConfiguration.Clients())
            .AddInMemoryIdentityResources(IdentityServerConfiguration.GetIdentityResources())
            .AddDeveloperSigningCredential();
        }