Esempio n. 1
0
        private static void EnsureSeedData(ConfigurationDbContext context)
        {
            if (!context.Clients.Any())
            {
                foreach (var client in InitConfig.GetClients().ToList())
                {
                    context.Clients.Add(client.ToEntity());
                }
                context.SaveChanges();
            }

            //if (!context.IdentityResources.Any())
            //{
            //    Console.WriteLine("IdentityResources being populated");
            //    foreach (var resource in InitConfig.GetIdentityResources().ToList())
            //    {
            //        context.IdentityResources.Add(resource.ToEntity());
            //    }
            //    context.SaveChanges();
            //}

            if (!context.ApiResources.Any())
            {
                foreach (var resource in InitConfig.GetApiResources().ToList())
                {
                    context.ApiResources.Add(resource.ToEntity());
                }
                context.SaveChanges();
            }
        }
Esempio n. 2
0
 public static void AddIdentityServerCenter(this IServiceCollection services)
 {
     //客户端模式,
     services.AddIdentityServer()
     .AddDeveloperSigningCredential()                        //默认的开发者证书--临时证书
     .AddInMemoryClients(InitConfig.GetClients())            //inmemory内存模式
     .AddInMemoryApiResources(InitConfig.GetApiResources()); //能访问啥资源
 }