public void ConfigureServices(IServiceCollection services) { var isSqlServer = bool.Parse(Configuration["isSqlServer"]); var isSqlLite = bool.Parse(Configuration["isSqlLite"]); // Add the dependencies needed to enable CORS services.AddCors(options => options.AddPolicy("AllowAll", p => p.AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader())); var connectionString = Configuration["Data:DefaultConnection:ConnectionString"]; // Configure the rate limitation services.Configure <RateLimitationOptions>(opt => { opt.IsEnabled = true; opt.RateLimitationElements = new List <RateLimitationElement> { new RateLimitationElement { Name = "PostToken", NumberOfRequests = 20, SlidingTime = 2000 } }; opt.MemoryCache = new MemoryCache(new MemoryCacheOptions()); }); var dataSourceType = DataSourceTypes.InMemory; if (isSqlServer) { dataSourceType = DataSourceTypes.SqlServer; } else if (isSqlLite) { dataSourceType = DataSourceTypes.SqlLite; } // Configure Simple identity server services.AddSimpleIdentityServer(new DataSourceOptions { DataSourceType = dataSourceType, ConnectionString = connectionString, Clients = Clients.Get(), JsonWebKeys = JsonWebKeys.Get(), ResourceOwners = ResourceOwners.Get(), Scopes = Scopes.Get(), Translations = Translations.Get() }, _swaggerOptions); services.AddLogging(); }