private static void Seed(IApplicationBuilder app)
        {
            var options = app.ApplicationServices.GetRequiredService <IOptions <TableStorageConfigurationOptions> >();

            // seed API resources

            var apiResourceLogger = app.ApplicationServices.GetRequiredService <ILogger <ApiResourceTableStore> >();
            var apiResourceStore  = new ApiResourceTableStore(options, apiResourceLogger);

            foreach (var apiResource in Host.Configuration.Resources.GetApiResources())
            {
                apiResourceStore.StoreAsync(apiResource).GetAwaiter().GetResult();
            }

            // seed Identity resources

            var identityResourceLogger = app.ApplicationServices.GetRequiredService <ILogger <IdentityResourceTableStore> >();
            var identityResourceStore  = new IdentityResourceTableStore(options, identityResourceLogger);

            foreach (var identityResource in Host.Configuration.Resources.GetIdentityResources())
            {
                identityResourceStore.StoreAsync(identityResource).GetAwaiter().GetResult();
            }

            // seed Clients

            var clientLogger = app.ApplicationServices.GetRequiredService <ILogger <ClientStore> >();
            var clientStore  = new ClientStore(options, clientLogger);

            foreach (var client in Clients.Get())
            {
                clientStore.StoreAsync(client).GetAwaiter().GetResult();
            }
        }
Example #2
0
        private static void InitializeIdentityResources(IServiceProvider services)
        {
            var options = services.GetRequiredService <IOptions <TableStorageConfigurationOptions> >();

            // seed Identity resources

            var identityResourceLogger = services.GetRequiredService <ILogger <IdentityResourceTableStore> >();
            var identityResourceStore  = new IdentityResourceTableStore(options, identityResourceLogger);

            foreach (var identityResource in Config.GetIdentityResources())
            {
                identityResourceStore.StoreAsync(identityResource).GetAwaiter().GetResult();
            }
        }