// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMemoryCache(); services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); //add database based localization services.AddSqlLocalization(options => { var conString = Configuration["ConnectionStrings:ConnectionString"]; options.ConnectionString = conString; }); //Enable JWTToken validation and Authentication services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearerPerTenant((options, tenant) => { var settings = new JwtTokenSettings { SigningKey = tenant.SigningKey, Issuer = tenant.HostName, Audience = tenant.TenantName }; var provider = new JwtTokenProvider(settings); options.TokenValidationParameters = provider.GetTokenValidationParameters(); }); //Enable Scope based authorization services.AddAuthorization(); services.AddSingleton <IAuthorizationPolicyProvider, ScopeAuthorizationPolicyProvider>(); services.AddSingleton <IAuthorizationHandler, ScopeAuthorizationHandler>(); services.AddMvc().AddJsonOptions(options => options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver()); services.Configure <RequestLocalizationOptions>(options => { var supportedCultures = new List <CultureInfo> { new CultureInfo("en-US"), new CultureInfo("ne-NP") }; options.DefaultRequestCulture = new RequestCulture(supportedCultures.First()); options.SupportedCultures = supportedCultures; options.SupportedUICultures = supportedCultures; }); //Register repository and business services Register(services); }