public Task <IEnumerable <IdentityResource> > FindIdentityResourcesByScopeAsync(IEnumerable <string> scopeNames)
        {
            var scopes = scopeNames.ToArray();

            var resources = from identityResource in _context.IdentityResources()
                            where scopes.Contains(identityResource.Name)
                            select identityResource;

            var results = resources.ToArray();

            _logger.LogDebug("Found {scopes} identity scopes in database", results.Select(x => x.Name));

            return(Task.FromResult(results.Select(x => x.ToModel()).ToArray().AsEnumerable()));
        }
Пример #2
0
        private static void EnsureSeedData(IConfigurationDbContext context)
        {
            foreach (var client in Clients.Get().ToList())
            {
                var dbRecords = context.Clients(client.ClientId).ToList();
                if (dbRecords.Count == 0)
                {
                    context.AddClient(client.ToEntity());
                }
            }

            foreach (var resource in Resources.GetIdentityResources().ToList())
            {
                var dbRecords = context.IdentityResources(resource.Name).ToList();
                if (dbRecords.Count == 0)
                {
                    context.AddIdentityResource(resource.ToEntity());
                }
            }

            foreach (var resource in Resources.GetApiResources().ToList())
            {
                var dbRecords = context.ApiResources(resource.Name).ToList();
                if (dbRecords.Count == 0)
                {
                    context.AddApiResource(resource.ToEntity());
                }
            }
        }