Esempio n. 1
0
        private static void EnsureSeedExternalIdps(SSDbContext context)
        {
            if (context.ExternalIdentityProvider.Any())
            {
                return;
            }

            Console.WriteLine("OIDC External Idps being populated");
            foreach (var oidcProvider in IdentityServerInitialConfiguration.GetExternalProviders().ToList())
            {
                context.OpenIdConnectIdentityProvider.Add(oidcProvider);
            }
            context.SaveChanges();
        }
Esempio n. 2
0
        private static void EnsureSeedData(ConfigurationDbContext context)
        {
            if (!context.Clients.Any())
            {
                Console.WriteLine("Clients being populated");
                foreach (var client in IdentityServerInitialConfiguration.GetClients().ToList())
                {
                    context.Clients.Add(client.ToEntity());
                }
                context.SaveChanges();
            }
            else
            {
                Console.WriteLine("Clients already populated");
            }

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

            if (!context.ApiResources.Any())
            {
                Console.WriteLine("ApiResources being populated");
                foreach (var resource in IdentityServerInitialConfiguration.GetApiResources().ToList())
                {
                    context.ApiResources.Add(resource.ToEntity());
                }
                context.SaveChanges();
            }
            else
            {
                Console.WriteLine("ApiResources already populated");
            }
        }