From 90a2a5543813db1582288d492c121834a24d7913 Mon Sep 17 00:00:00 2001 From: Thomas Rittson <31796059+eliykat@users.noreply.github.com> Date: Mon, 29 Nov 2021 10:01:51 +1000 Subject: [PATCH] Fix Stripe object lock timeouts (#1735) * Fix Stripe object lock timeouts * Move stripe config into globalSetting.stripe * add MaxNetworkRetries config option with smart defaults * Rename stripeApiKey to apiKey --- bitwarden_license/src/Sso/Startup.cs | 3 ++- bitwarden_license/src/Sso/appsettings.json | 4 +++- src/Admin/Startup.cs | 3 ++- src/Admin/appsettings.json | 4 +++- src/Api/Startup.cs | 3 ++- src/Api/appsettings.json | 4 +++- src/Billing/Startup.cs | 3 ++- src/Billing/appsettings.json | 4 +++- src/Core/Settings/GlobalSettings.cs | 8 +++++++- src/Identity/appsettings.json | 4 +++- 10 files changed, 30 insertions(+), 10 deletions(-) diff --git a/bitwarden_license/src/Sso/Startup.cs b/bitwarden_license/src/Sso/Startup.cs index 0abfeaf852..95d9d6ce01 100644 --- a/bitwarden_license/src/Sso/Startup.cs +++ b/bitwarden_license/src/Sso/Startup.cs @@ -36,7 +36,8 @@ namespace Bit.Sso var globalSettings = services.AddGlobalSettingsServices(Configuration); // Stripe Billing - StripeConfiguration.ApiKey = globalSettings.StripeApiKey; + StripeConfiguration.ApiKey = globalSettings.Stripe.ApiKey; + StripeConfiguration.MaxNetworkRetries = globalSettings.Stripe.MaxNetworkRetries; // Data Protection services.AddCustomDataProtectionServices(Environment, globalSettings); diff --git a/bitwarden_license/src/Sso/appsettings.json b/bitwarden_license/src/Sso/appsettings.json index 7e1d1be5e4..3bf02cd869 100644 --- a/bitwarden_license/src/Sso/appsettings.json +++ b/bitwarden_license/src/Sso/appsettings.json @@ -3,7 +3,9 @@ "selfHosted": false, "siteName": "Bitwarden", "projectName": "SSO", - "stripeApiKey": "SECRET", + "stripe": { + "apiKey": "SECRET" + }, "oidcIdentityClientKey": "SECRET", "sqlServer": { "connectionString": "SECRET" diff --git a/src/Admin/Startup.cs b/src/Admin/Startup.cs index 285a35ad3b..90837b9137 100644 --- a/src/Admin/Startup.cs +++ b/src/Admin/Startup.cs @@ -44,7 +44,8 @@ namespace Bit.Admin services.AddCustomDataProtectionServices(Environment, globalSettings); // Stripe Billing - StripeConfiguration.ApiKey = globalSettings.StripeApiKey; + StripeConfiguration.ApiKey = globalSettings.Stripe.ApiKey; + StripeConfiguration.MaxNetworkRetries = globalSettings.Stripe.MaxNetworkRetries; // Repositories services.AddSqlServerRepositories(globalSettings); diff --git a/src/Admin/appsettings.json b/src/Admin/appsettings.json index 728a298b5c..79bede763f 100644 --- a/src/Admin/appsettings.json +++ b/src/Admin/appsettings.json @@ -3,7 +3,9 @@ "selfHosted": false, "siteName": "Bitwarden", "projectName": "Admin", - "stripeApiKey": "SECRET", + "stripe": { + "apiKey": "SECRET" + }, "sqlServer": { "connectionString": "SECRET" }, diff --git a/src/Api/Startup.cs b/src/Api/Startup.cs index 367152444a..23eb6a34f0 100644 --- a/src/Api/Startup.cs +++ b/src/Api/Startup.cs @@ -61,7 +61,8 @@ namespace Bit.Api } // Stripe Billing - StripeConfiguration.ApiKey = globalSettings.StripeApiKey; + StripeConfiguration.ApiKey = globalSettings.Stripe.ApiKey; + StripeConfiguration.MaxNetworkRetries = globalSettings.Stripe.MaxNetworkRetries; // Repositories services.AddSqlServerRepositories(globalSettings); diff --git a/src/Api/appsettings.json b/src/Api/appsettings.json index 8a2d67665f..92922d104f 100644 --- a/src/Api/appsettings.json +++ b/src/Api/appsettings.json @@ -3,7 +3,9 @@ "selfHosted": false, "siteName": "Bitwarden", "projectName": "Api", - "stripeApiKey": "SECRET", + "stripe": { + "apiKey": "SECRET" + }, "sqlServer": { "connectionString": "SECRET" }, diff --git a/src/Billing/Startup.cs b/src/Billing/Startup.cs index 237b826a7b..ec520f0624 100644 --- a/src/Billing/Startup.cs +++ b/src/Billing/Startup.cs @@ -35,7 +35,8 @@ namespace Bit.Billing services.Configure(Configuration.GetSection("BillingSettings")); // Stripe Billing - StripeConfiguration.ApiKey = globalSettings.StripeApiKey; + StripeConfiguration.ApiKey = globalSettings.Stripe.ApiKey; + StripeConfiguration.MaxNetworkRetries = globalSettings.Stripe.MaxNetworkRetries; // Repositories services.AddSqlServerRepositories(globalSettings); diff --git a/src/Billing/appsettings.json b/src/Billing/appsettings.json index c25c3940e7..e0e4c162fb 100644 --- a/src/Billing/appsettings.json +++ b/src/Billing/appsettings.json @@ -3,7 +3,9 @@ "selfHosted": false, "siteName": "Bitwarden", "projectName": "Billing", - "stripeApiKey": "SECRET", + "stripe": { + "apiKey": "SECRET" + }, "sqlServer": { "connectionString": "SECRET" }, diff --git a/src/Core/Settings/GlobalSettings.cs b/src/Core/Settings/GlobalSettings.cs index 12aa01f872..b41e5e790d 100644 --- a/src/Core/Settings/GlobalSettings.cs +++ b/src/Core/Settings/GlobalSettings.cs @@ -18,7 +18,6 @@ namespace Bit.Core.Settings public bool SelfHosted { get; set; } public virtual string KnownProxies { get; set; } public virtual string SiteName { get; set; } - public virtual string StripeApiKey { get; set; } public virtual string ProjectName { get; set; } public virtual string LogDirectory { @@ -68,6 +67,7 @@ namespace Bit.Core.Settings public virtual ServiceBusSettings ServiceBus { get; set; } = new ServiceBusSettings(); public virtual AppleIapSettings AppleIap { get; set; } = new AppleIapSettings(); public virtual SsoSettings Sso { get; set; } = new SsoSettings(); + public virtual StripeSettings Stripe { get; set; } = new StripeSettings(); public string BuildExternalUri(string explicitValue, string name) { @@ -465,5 +465,11 @@ namespace Bit.Core.Settings public string HCaptchaSecretKey { get; set; } public string HCaptchaSiteKey { get; set; } } + + public class StripeSettings + { + public string ApiKey { get; set; } + public int MaxNetworkRetries { get; set; } = 2; + } } } diff --git a/src/Identity/appsettings.json b/src/Identity/appsettings.json index edbc1d1188..fb3469b5fe 100644 --- a/src/Identity/appsettings.json +++ b/src/Identity/appsettings.json @@ -3,7 +3,9 @@ "selfHosted": false, "siteName": "Bitwarden", "projectName": "Identity", - "stripeApiKey": "SECRET", + "stripe": { + "apiKey": "SECRET" + }, "oidcIdentityClientKey": "SECRET", "sqlServer": { "connectionString": "SECRET"