public IServiceProvider ConfigureServices(IServiceCollection services) { var provider = services.BuildServiceProvider(); _settings = provider.GetService <IBaseSettings>(); services.AddSingleton(_settings); services.AddAuthentication(options => { options.SignInScheme = "ServerCookie"; }); services.AddLocalization(options => options.ResourcesPath = "Resources"); services.AddMvc() .AddViewLocalization() .AddDataAnnotationsLocalization() .AddMvcOptions(o => { o.Filters.Add(typeof(UnhandledExceptionFilter)); }); services.AddDistributedMemoryCache(); services.AddAutoMapper(); services.AddSession(options => { options.IdleTimeout = TimeSpan.FromMinutes(30); }); WebDependencies.Create(services); return(ApiDependencies.Create(services, _settings)); }
public IServiceProvider ConfigureServices(IServiceCollection services) { OAuthSettings settings = new OAuthSettings(); if (Environment.IsProduction() && string.IsNullOrEmpty(Configuration["SettingsUrl"])) { throw new Exception("SettingsUrl is not found"); } if (string.IsNullOrEmpty(Configuration["SettingsUrl"])) { Configuration.Bind(settings); } else { settings = SettingsProcessor.Process <OAuthSettings>(Configuration["SettingsUrl"].GetStringAsync().Result); } services.AddSingleton <IOAuthSettings>(settings); services.AddAuthentication(options => { options.SignInScheme = "ServerCookie"; }); services.AddLocalization(options => options.ResourcesPath = "Resources"); services.AddCors(options => { options.AddPolicy("Lykke", builder => { builder.AllowAnyOrigin() .AllowAnyHeader() .AllowAnyMethod() .AllowCredentials(); }); }); services.AddMvc() .AddViewLocalization() .AddDataAnnotationsLocalization() .AddMvcOptions(o => { o.Filters.Add(typeof(UnhandledExceptionFilter)); }); services.AddDistributedMemoryCache(); services.AddAutoMapper(); services.AddSession(options => { options.IdleTimeout = TimeSpan.FromMinutes(30); }); services.Configure <ForwardedHeadersOptions>(options => { options.ForwardedHeaders = ForwardedHeaders.XForwardedProto; }); WebDependencies.Create(services); return(ApiDependencies.Create(services, settings)); }