public void ConfigureServices(IServiceCollection services) { #region services setup KeyVaultService.Create(Environment.GetEnvironmentVariable("VaultUri")); EmailService.Create(KeyVaultService.GetSecretByName("SMTP--PASS")); PaymentService.Create(KeyVaultService.GetSecretByName("PayU")); BlobStorageService.Create(KeyVaultService.GetSecretByName("ConnectionStrings--BlobSotrage")); InputManager.Create(KeyVaultService.GetSecretByName("PBKDF2--params")); #endregion services.AddControllersWithViews(); services.AddDbContext <DatabaseContext>(options => options.UseLazyLoadingProxies().UseSqlServer(KeyVaultService.GetSecretByName("ConnectionStrings--justlearnitdb"))); services.AddSession(); services.AddDistributedMemoryCache(); services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); var symmetricKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(KeyVaultService.GetSecretByName("JWT--Key"))); services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(opt => { opt.TokenValidationParameters = new TokenValidationParameters { ValidateIssuer = true, ValidateAudience = false, ValidateIssuerSigningKey = true, ValidIssuer = "INO", IssuerSigningKey = symmetricKey }; }); services.AddAuthorization(); }