From 8292010388c462f261c8867a98fd3d6bfe7c14ff Mon Sep 17 00:00:00 2001 From: Corey Date: Thu, 14 Jan 2021 14:18:38 +0000 Subject: [PATCH 01/21] [CON-2991] Add shared Configuration class --- .../Configuration/RedisConnectionSettings.cs | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/Shared/Recruit.Shared.Web/Configuration/RedisConnectionSettings.cs diff --git a/src/Shared/Recruit.Shared.Web/Configuration/RedisConnectionSettings.cs b/src/Shared/Recruit.Shared.Web/Configuration/RedisConnectionSettings.cs new file mode 100644 index 0000000000..005f7807a7 --- /dev/null +++ b/src/Shared/Recruit.Shared.Web/Configuration/RedisConnectionSettings.cs @@ -0,0 +1,8 @@ +namespace Esfa.Recruit.Shared.Web.Configuration +{ + public class RedisConnectionSettings + { + public string RedisConnectionString { get; set; } + public string DataProtectionKeysDatabase { get; set; } + } +} From ea1673f78fb9cae13bf3badf9a0c1e5b28ecefc6 Mon Sep 17 00:00:00 2001 From: Corey Date: Thu, 14 Jan 2021 14:19:35 +0000 Subject: [PATCH 02/21] [CON-2991] Add extension method for Redis cache data protection --- src/Employer/Employer.Web/Employer.Web.csproj | 1 + .../DataProtectionStartupExtensions.cs | 36 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 src/Employer/Employer.Web/Extensions/DataProtectionStartupExtensions.cs diff --git a/src/Employer/Employer.Web/Employer.Web.csproj b/src/Employer/Employer.Web/Employer.Web.csproj index 8d5866a0af..bdaf5de30a 100644 --- a/src/Employer/Employer.Web/Employer.Web.csproj +++ b/src/Employer/Employer.Web/Employer.Web.csproj @@ -11,6 +11,7 @@ + diff --git a/src/Employer/Employer.Web/Extensions/DataProtectionStartupExtensions.cs b/src/Employer/Employer.Web/Extensions/DataProtectionStartupExtensions.cs new file mode 100644 index 0000000000..367b5b70ad --- /dev/null +++ b/src/Employer/Employer.Web/Extensions/DataProtectionStartupExtensions.cs @@ -0,0 +1,36 @@ +using Esfa.Recruit.Shared.Web.Configuration; +using Microsoft.AspNetCore.DataProtection; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using StackExchange.Redis; + +namespace Esfa.Recruit.Employer.Web.Extensions +{ + public static class DataProtectionStartupExtensions + { + public static IServiceCollection AddDataProtection(this IServiceCollection services, IConfiguration configuration, IHostingEnvironment environment) + { + if (!environment.IsDevelopment()) + { + var redisConfiguration = configuration.GetSection("RedisConnectionSettings") + .Get(); + + if (redisConfiguration != null) + { + var redisConnectionString = redisConfiguration.RedisConnectionString; + var dataProtectionKeysDatabase = redisConfiguration.DataProtectionKeysDatabase; + + var redis = ConnectionMultiplexer + .Connect($"{redisConnectionString},{dataProtectionKeysDatabase}"); + + services.AddDataProtection() + .SetApplicationName("das-employer-recruit") + .PersistKeysToStackExchangeRedis(redis, "DataProtection-Keys"); + } + } + + return services; + } + } +} From 2472f91b3be26cce6f024fc1fcda572d65339d43 Mon Sep 17 00:00:00 2001 From: Corey Date: Thu, 14 Jan 2021 14:20:01 +0000 Subject: [PATCH 03/21] [CON-2991] Use new extension in Employer Web startup --- src/Employer/Employer.Web/Startup.ConfigureServices.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Employer/Employer.Web/Startup.ConfigureServices.cs b/src/Employer/Employer.Web/Startup.ConfigureServices.cs index 40212ee7c7..35162788cb 100644 --- a/src/Employer/Employer.Web/Startup.ConfigureServices.cs +++ b/src/Employer/Employer.Web/Startup.ConfigureServices.cs @@ -1,6 +1,7 @@ using Esfa.Recruit.Employer.Web.Configuration; using Esfa.Recruit.Shared.Web.FeatureToggle; using Esfa.Recruit.Vacancies.Client.Infrastructure.Client; +using Esfa.Recruit.Employer.Web.Extensions; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc.Razor; using Microsoft.Extensions.Configuration; @@ -57,7 +58,9 @@ public void ConfigureServices(IServiceCollection services) services.AddAuthenticationService(_authConfig, sp.GetService(), sp.GetService(), sp.GetService()); services.AddAuthorizationService(); - } + } + + services.AddDataProtection(_configuration, _hostingEnvironment); } } } From b25290bd6022ec2572bd19d7af9e4008443e9375 Mon Sep 17 00:00:00 2001 From: Corey Date: Thu, 14 Jan 2021 14:20:53 +0000 Subject: [PATCH 04/21] [CON-2991] Update employer web local config. Remove unused StorageRedis connection string and add config section for RedisConnectionSettings --- src/Employer/Employer.Web/appsettings.Development.json | 5 ++++- src/Employer/Employer.Web/appsettings.json | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Employer/Employer.Web/appsettings.Development.json b/src/Employer/Employer.Web/appsettings.Development.json index 6688fba79b..e2008f8b3a 100644 --- a/src/Employer/Employer.Web/appsettings.Development.json +++ b/src/Employer/Employer.Web/appsettings.Development.json @@ -25,9 +25,12 @@ "Features": { "SetNotificationPreferences": true }, + "RedisConnectionSettings": { + "RedisConnectionString": "localhost:6379", + "DataProtectionKeysDatabase" + } "ConnectionStrings": { "Redis": "localhost:6379", - "StorageRedis": "localhost:6379", "MongoDb": "mongodb://dbadmin:changeme@localhost:27017/admin/?ssl=false&authMechanism=SCRAM-SHA-1", "QueueStorage": "UseDevelopmentStorage=true", "TableStorage": "UseDevelopmentStorage=true" diff --git a/src/Employer/Employer.Web/appsettings.json b/src/Employer/Employer.Web/appsettings.json index 028796bdd5..a0c983f787 100644 --- a/src/Employer/Employer.Web/appsettings.json +++ b/src/Employer/Employer.Web/appsettings.json @@ -78,7 +78,6 @@ }, "ConnectionStrings": { "Redis": "", - "StorageRedis": "", "MongoDb": "", "QueueStorage": "", "TableStorage": "" From 72ae7434d3a86a1a73e96cb0198c75a2d9919a25 Mon Sep 17 00:00:00 2001 From: Corey Date: Thu, 14 Jan 2021 15:09:36 +0000 Subject: [PATCH 05/21] [CON-2991] Fix config --- src/Employer/Employer.Web/appsettings.Development.json | 4 ++-- src/Employer/Employer.Web/appsettings.json | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Employer/Employer.Web/appsettings.Development.json b/src/Employer/Employer.Web/appsettings.Development.json index e2008f8b3a..edc57e0e0a 100644 --- a/src/Employer/Employer.Web/appsettings.Development.json +++ b/src/Employer/Employer.Web/appsettings.Development.json @@ -27,8 +27,8 @@ }, "RedisConnectionSettings": { "RedisConnectionString": "localhost:6379", - "DataProtectionKeysDatabase" - } + "DataProtectionKeysDatabase": "abc123" + }, "ConnectionStrings": { "Redis": "localhost:6379", "MongoDb": "mongodb://dbadmin:changeme@localhost:27017/admin/?ssl=false&authMechanism=SCRAM-SHA-1", diff --git a/src/Employer/Employer.Web/appsettings.json b/src/Employer/Employer.Web/appsettings.json index a0c983f787..c6cf1eae67 100644 --- a/src/Employer/Employer.Web/appsettings.json +++ b/src/Employer/Employer.Web/appsettings.json @@ -39,11 +39,15 @@ "FindProviderUrl": "https://findapprenticeshiptraining.apprenticeships.education.gov.uk/provider/search", "CommitmentsSiteUrl": "https://manage-apprenticeships.service.gov.uk/", "NationalMinimumWageRates": "https://www.gov.uk/national-minimum-wage-rates", - "EmployerFavouritesUrl": "https://test-employerfavourites.apprenticeships.education.gov.uk" + "EmployerFavouritesUrl": "https://test-employerfavourites.apprenticeships.education.gov.uk" }, "Features": { "SetNotificationPreferences": false }, + "RedisConnectionSettings": { + "RedisConnectionString": "", + "DataProtectionKeysDatabase": "" + }, "ManageApprenticeshipsRoutes": { "ManageApprenticeshipSiteAccountsHomeRoute": "/accounts/{0}/teams", "ManageApprenticeshipSiteHelpRoute": "/service/help", From edb59022f860f88bb8108dae64dfe6c0eb98c48a Mon Sep 17 00:00:00 2001 From: Corey Date: Thu, 14 Jan 2021 15:10:11 +0000 Subject: [PATCH 06/21] [CON-2991] Configure Redis connection settings in IoC --- src/Employer/Employer.Web/Configuration/IoC.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Employer/Employer.Web/Configuration/IoC.cs b/src/Employer/Employer.Web/Configuration/IoC.cs index 9fd556b14c..848b955ebb 100644 --- a/src/Employer/Employer.Web/Configuration/IoC.cs +++ b/src/Employer/Employer.Web/Configuration/IoC.cs @@ -41,6 +41,7 @@ public static void AddIoC(this IServiceCollection services, IConfiguration confi services.Configure(configuration.GetSection("PostcodeAnywhere")); services.Configure(configuration.GetSection("FaaConfiguration")); services.Configure(configuration.GetSection("ZenDesk")); + services.Configure(configuration.GetSection("RedisConnectionSettings")); services.AddFeatureToggle(); From 397b8b03aa59192d27fe73a6b70e85e33438bed4 Mon Sep 17 00:00:00 2001 From: Corey Date: Thu, 14 Jan 2021 16:01:27 +0000 Subject: [PATCH 07/21] [CON-2991] Update template json for employer recruit --- azure/template.json | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/azure/template.json b/azure/template.json index ef0246df7c..14a96dcb17 100644 --- a/azure/template.json +++ b/azure/template.json @@ -106,6 +106,10 @@ "type": "securestring", "defaultValue": "" }, + "DataProtectionKeysDatabase": { + "type": "string", + "defaultValue": "" + }, "ApprenticeshipProgrammesApiBaseUrl": { "type": "string", "defaultValue": "" @@ -191,6 +195,7 @@ "CobrowsingSnippetKey": "" } }, + "FaaConfiguration": { "type": "secureObject", "defaultValue": { @@ -621,7 +626,15 @@ { "name": "ZenDesk:CobrowsingSnippetKey", "value": "[parameters('ZenDesk').CobrowsingSnippetKey]" - } + }, + { + "name": "RedisConnectionSettings:RedisConnectionString", + "value": "[parameters('StorageRedisConnectionString')]" + }, + { + "name": "RedisConnectionSettings:DataProtectionKeysDatabase", + "value": "[parameters('DataProtectionKeysDatabase')]" + } ] } }, @@ -633,11 +646,6 @@ "connectionString": "[parameters('LoggingRedisConnectionString')]", "type": "Custom" }, - { - "name": "StorageRedis", - "connectionString": "[parameters('StorageRedisConnectionString')]", - "type": "Custom" - }, { "name": "MongoDb", "connectionString": "[concat('mongodb://', variables('CosmosDbName'), ':', reference(variables('CosmosDbName')).outputs.PrimaryMasterKey.value,'@', variables('CosmosDbName'), '.documents.azure.com:10255/?ssl=true&replicaSet=globaldb')]", From d4bd69158929372fe2678a42779e6cb41db63315 Mon Sep 17 00:00:00 2001 From: Corey Date: Thu, 14 Jan 2021 16:15:55 +0000 Subject: [PATCH 08/21] [CON-2991] Update sourcelink nuget package --- src/Communication/Communication.Core/Communication.Core.csproj | 2 +- .../Communication.Types/Communication.Types.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Communication/Communication.Core/Communication.Core.csproj b/src/Communication/Communication.Core/Communication.Core.csproj index 70efc6c51c..ea7112a222 100644 --- a/src/Communication/Communication.Core/Communication.Core.csproj +++ b/src/Communication/Communication.Core/Communication.Core.csproj @@ -22,7 +22,7 @@ - + diff --git a/src/Communication/Communication.Types/Communication.Types.csproj b/src/Communication/Communication.Types/Communication.Types.csproj index c42e90e706..77926608eb 100644 --- a/src/Communication/Communication.Types/Communication.Types.csproj +++ b/src/Communication/Communication.Types/Communication.Types.csproj @@ -22,7 +22,7 @@ - + From caacfa34c7753c077a1afa8fecea5f789e5a8e96 Mon Sep 17 00:00:00 2001 From: Corey Date: Fri, 15 Jan 2021 14:20:54 +0000 Subject: [PATCH 09/21] [CON-2991] Move redis data protection setup to shared as a pre-cursor to it being used in multiple web projects --- .../IntegrationTests/IntegrationTests.csproj | 2 +- src/Provider/Provider.Web/Provider.Web.csproj | 4 +-- src/Provider/UnitTests/UnitTests.csproj | 2 +- src/QA/QA.Web/QA.Web.csproj | 12 +++---- src/QA/UnitTests/UnitTests.csproj | 2 +- .../DataProtectionStartupExtensions.cs | 36 +++++++++++++++++++ .../Recruit.Shared.Web.csproj | 4 ++- 7 files changed, 50 insertions(+), 12 deletions(-) create mode 100644 src/Shared/Recruit.Shared.Web/Extensions/DataProtectionStartupExtensions.cs diff --git a/src/Employer/IntegrationTests/IntegrationTests.csproj b/src/Employer/IntegrationTests/IntegrationTests.csproj index ef852dd225..6305dc272c 100644 --- a/src/Employer/IntegrationTests/IntegrationTests.csproj +++ b/src/Employer/IntegrationTests/IntegrationTests.csproj @@ -1,6 +1,6 @@ - netcoreapp2.1 + netcoreapp2.2 false Esfa.Recruit.Employer.IntegrationTests diff --git a/src/Provider/Provider.Web/Provider.Web.csproj b/src/Provider/Provider.Web/Provider.Web.csproj index a2b2e1847c..99b48cbc26 100644 --- a/src/Provider/Provider.Web/Provider.Web.csproj +++ b/src/Provider/Provider.Web/Provider.Web.csproj @@ -1,6 +1,6 @@  - netcoreapp2.1 + netcoreapp2.2 recruit-provider-web Esfa.Recruit.Provider.Web @@ -17,7 +17,7 @@ - + diff --git a/src/Provider/UnitTests/UnitTests.csproj b/src/Provider/UnitTests/UnitTests.csproj index b4c1f6c2b1..4f354fb8f7 100644 --- a/src/Provider/UnitTests/UnitTests.csproj +++ b/src/Provider/UnitTests/UnitTests.csproj @@ -1,7 +1,7 @@ - netcoreapp2.1 + netcoreapp2.2 false diff --git a/src/QA/QA.Web/QA.Web.csproj b/src/QA/QA.Web/QA.Web.csproj index 607c323440..ef51fced43 100644 --- a/src/QA/QA.Web/QA.Web.csproj +++ b/src/QA/QA.Web/QA.Web.csproj @@ -1,6 +1,6 @@  - netcoreapp2.1 + netcoreapp2.2 recruit-qa-web Esfa.Recruit.Qa.Web @@ -10,11 +10,11 @@ - - - - - + + + + + diff --git a/src/QA/UnitTests/UnitTests.csproj b/src/QA/UnitTests/UnitTests.csproj index 3a247cbc49..8795c44b98 100644 --- a/src/QA/UnitTests/UnitTests.csproj +++ b/src/QA/UnitTests/UnitTests.csproj @@ -1,7 +1,7 @@ - netcoreapp2.1 + netcoreapp2.2 false diff --git a/src/Shared/Recruit.Shared.Web/Extensions/DataProtectionStartupExtensions.cs b/src/Shared/Recruit.Shared.Web/Extensions/DataProtectionStartupExtensions.cs new file mode 100644 index 0000000000..a3efed6dba --- /dev/null +++ b/src/Shared/Recruit.Shared.Web/Extensions/DataProtectionStartupExtensions.cs @@ -0,0 +1,36 @@ +using Esfa.Recruit.Shared.Web.Configuration; +using Microsoft.AspNetCore.DataProtection; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using StackExchange.Redis; + +namespace Esfa.Recruit.Shared.Web.Extensions +{ + public static class DataProtectionStartupExtensions + { + public static IServiceCollection AddDataProtection(this IServiceCollection services, IConfiguration configuration, IHostingEnvironment environment) + { + if (!environment.IsDevelopment()) + { + var redisConfiguration = configuration.GetSection("RedisConnectionSettings") + .Get(); + + if (redisConfiguration != null) + { + var redisConnectionString = redisConfiguration.RedisConnectionString; + var dataProtectionKeysDatabase = redisConfiguration.DataProtectionKeysDatabase; + + var redis = ConnectionMultiplexer + .Connect($"{redisConnectionString},{dataProtectionKeysDatabase}"); + + services.AddDataProtection() + .SetApplicationName("das-employer-recruit") + .PersistKeysToStackExchangeRedis(redis, "DataProtection-Keys"); + } + } + + return services; + } + } +} diff --git a/src/Shared/Recruit.Shared.Web/Recruit.Shared.Web.csproj b/src/Shared/Recruit.Shared.Web/Recruit.Shared.Web.csproj index 28920856f9..75f685806e 100644 --- a/src/Shared/Recruit.Shared.Web/Recruit.Shared.Web.csproj +++ b/src/Shared/Recruit.Shared.Web/Recruit.Shared.Web.csproj @@ -8,7 +8,9 @@ - + + + From 503aef4ec63c24e1d6b2b61287822757047a7673 Mon Sep 17 00:00:00 2001 From: Corey Date: Fri, 15 Jan 2021 14:21:19 +0000 Subject: [PATCH 10/21] [CON-2991] Change employer startup to use shared extension method --- src/Employer/Employer.Web/Startup.ConfigureServices.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Employer/Employer.Web/Startup.ConfigureServices.cs b/src/Employer/Employer.Web/Startup.ConfigureServices.cs index 35162788cb..b91560aef3 100644 --- a/src/Employer/Employer.Web/Startup.ConfigureServices.cs +++ b/src/Employer/Employer.Web/Startup.ConfigureServices.cs @@ -1,7 +1,7 @@ using Esfa.Recruit.Employer.Web.Configuration; +using Esfa.Recruit.Shared.Web.Extensions; using Esfa.Recruit.Shared.Web.FeatureToggle; using Esfa.Recruit.Vacancies.Client.Infrastructure.Client; -using Esfa.Recruit.Employer.Web.Extensions; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc.Razor; using Microsoft.Extensions.Configuration; From 9aa45d554bd63c1d9a3ac1416a02e27ab75f266e Mon Sep 17 00:00:00 2001 From: Corey Date: Fri, 15 Jan 2021 14:23:56 +0000 Subject: [PATCH 11/21] [CON-2991] Remove extension from Employer.web --- .../DataProtectionStartupExtensions.cs | 36 ------------------- 1 file changed, 36 deletions(-) delete mode 100644 src/Employer/Employer.Web/Extensions/DataProtectionStartupExtensions.cs diff --git a/src/Employer/Employer.Web/Extensions/DataProtectionStartupExtensions.cs b/src/Employer/Employer.Web/Extensions/DataProtectionStartupExtensions.cs deleted file mode 100644 index 367b5b70ad..0000000000 --- a/src/Employer/Employer.Web/Extensions/DataProtectionStartupExtensions.cs +++ /dev/null @@ -1,36 +0,0 @@ -using Esfa.Recruit.Shared.Web.Configuration; -using Microsoft.AspNetCore.DataProtection; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using StackExchange.Redis; - -namespace Esfa.Recruit.Employer.Web.Extensions -{ - public static class DataProtectionStartupExtensions - { - public static IServiceCollection AddDataProtection(this IServiceCollection services, IConfiguration configuration, IHostingEnvironment environment) - { - if (!environment.IsDevelopment()) - { - var redisConfiguration = configuration.GetSection("RedisConnectionSettings") - .Get(); - - if (redisConfiguration != null) - { - var redisConnectionString = redisConfiguration.RedisConnectionString; - var dataProtectionKeysDatabase = redisConfiguration.DataProtectionKeysDatabase; - - var redis = ConnectionMultiplexer - .Connect($"{redisConnectionString},{dataProtectionKeysDatabase}"); - - services.AddDataProtection() - .SetApplicationName("das-employer-recruit") - .PersistKeysToStackExchangeRedis(redis, "DataProtection-Keys"); - } - } - - return services; - } - } -} From 5f011f4d4714e98570089d9e79dbc4e3909b4b18 Mon Sep 17 00:00:00 2001 From: Corey Date: Fri, 15 Jan 2021 14:42:44 +0000 Subject: [PATCH 12/21] [CON-2991] Add redis data protection to QA web --- src/QA/QA.Web/Startup.ConfigureServices.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/QA/QA.Web/Startup.ConfigureServices.cs b/src/QA/QA.Web/Startup.ConfigureServices.cs index b17db99a2f..4f9603d462 100644 --- a/src/QA/QA.Web/Startup.ConfigureServices.cs +++ b/src/QA/QA.Web/Startup.ConfigureServices.cs @@ -7,11 +7,13 @@ using Esfa.Recruit.QA.Web.Filters; using Esfa.Recruit.QA.Web.Orchestrators; using Esfa.Recruit.Shared.Web.Configuration; +using Esfa.Recruit.Shared.Web.Extensions; using Esfa.Recruit.Shared.Web.Mappers; using Esfa.Recruit.Shared.Web.RuleTemplates; using Esfa.Recruit.Shared.Web.Services; using Esfa.Recruit.Vacancies.Client.Application.Configuration; using Esfa.Recruit.Vacancies.Client.Ioc; +using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc.Razor; using Microsoft.Extensions.Configuration; @@ -23,15 +25,17 @@ namespace Esfa.Recruit.Qa.Web public partial class Startup { private readonly IConfiguration _configuration; + private readonly IHostingEnvironment _hostingEnvironment; private readonly AuthenticationConfiguration _authenticationConfig; private readonly AuthorizationConfiguration _legacyAuthorizationConfig; private readonly AuthorizationConfiguration _authorizationConfig; private readonly ExternalLinksConfiguration _externalLinks; private readonly ILoggerFactory _loggerFactory; - public Startup(IConfiguration configuration, ILoggerFactory loggerFactory) + public Startup(IConfiguration configuration, IHostingEnvironment env, ILoggerFactory loggerFactory) { _configuration = configuration; + _hostingEnvironment = env; _authenticationConfig = _configuration.GetSection("Authentication").Get(); _legacyAuthorizationConfig = _configuration.GetSection("LegacyAuthorization").Get(); _authorizationConfig = _configuration.GetSection("Authorization").Get(); @@ -54,6 +58,7 @@ public void ConfigureServices(IServiceCollection services) }); services.AddMvcService(_loggerFactory); + services.AddDataProtection(_configuration, _hostingEnvironment); services.AddAntiforgery( options => From 2b3ec0875dc680988c4427b80cb9270631264eee Mon Sep 17 00:00:00 2001 From: Corey Date: Fri, 15 Jan 2021 14:43:08 +0000 Subject: [PATCH 13/21] [CON-2991] Add new redis connection settings config --- src/QA/QA.Web/appsettings.Development.json | 7 +++++-- src/QA/QA.Web/appsettings.json | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/QA/QA.Web/appsettings.Development.json b/src/QA/QA.Web/appsettings.Development.json index 24ff105d1a..0f4dfe1f49 100644 --- a/src/QA/QA.Web/appsettings.Development.json +++ b/src/QA/QA.Web/appsettings.Development.json @@ -17,13 +17,16 @@ "Slack": { "FindAnApprenticeshipDetailPrefixUrl": "https://www.findapprenticeship.service.gov.uk/apprenticeship/" }, + "RedisConnectionSettings": { + "RedisConnectionString": "localhost:6379", + "DataProtectionKeysDatabase": "abc123" + }, "ConnectionStrings": { "Redis": "localhost:6379", - "StorageRedis": "localhost:6379", "MongoDb": "mongodb://dbadmin:changeme@localhost:27017/admin/?ssl=false&authMechanism=SCRAM-SHA-1", "QueueStorage": "UseDevelopmentStorage=true", "TableStorage": "UseDevelopmentStorage=true", - "CommunicationsStorage": "UseDevelopmentStorage=true", + "CommunicationsStorage": "UseDevelopmentStorage=true" }, "ExternalLinks": { "StaffIdamsUrl": "https://adfs.preprod.skillsfunding.service.gov.uk" diff --git a/src/QA/QA.Web/appsettings.json b/src/QA/QA.Web/appsettings.json index 7f2841b99a..9e9b5bf749 100644 --- a/src/QA/QA.Web/appsettings.json +++ b/src/QA/QA.Web/appsettings.json @@ -52,5 +52,9 @@ "UseTableStorageQueryStore": false, "FaaConfiguration": { "StorageConnectionString": "" + }, + "RedisConnectionSettings": { + "RedisConnectionString": "", + "DataProtectionKeysDatabase": "" } } From 064c2d03283a501dfbdda384286f92b6d9764cc3 Mon Sep 17 00:00:00 2001 From: Corey Date: Fri, 15 Jan 2021 14:44:10 +0000 Subject: [PATCH 14/21] [CON-2991] Template json update for QA web --- azure/template.json | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/azure/template.json b/azure/template.json index 14a96dcb17..18f7974370 100644 --- a/azure/template.json +++ b/azure/template.json @@ -799,7 +799,15 @@ { "name": "FaaConfiguration:StorageConnectionString", "value": "[parameters('FaaConfiguration').StorageConnectionString]" - } + }, + { + "name": "RedisConnectionSettings:RedisConnectionString", + "value": "[parameters('StorageRedisConnectionString')]" + }, + { + "name": "RedisConnectionSettings:DataProtectionKeysDatabase", + "value": "[parameters('DataProtectionKeysDatabase')]" + } ] } }, @@ -811,11 +819,6 @@ "connectionString": "[parameters('LoggingRedisConnectionString')]", "type": "Custom" }, - { - "name": "StorageRedis", - "connectionString": "[parameters('StorageRedisConnectionString')]", - "type": "Custom" - }, { "name": "MongoDb", "connectionString": "[concat('mongodb://', variables('CosmosDbName'), ':', reference(variables('CosmosDbName')).outputs.PrimaryMasterKey.value,'@', variables('CosmosDbName'), '.documents.azure.com:10255/?ssl=true&replicaSet=globaldb')]", From a0054f8b2165a524b225bacd20e61935ea742e48 Mon Sep 17 00:00:00 2001 From: Corey Date: Fri, 15 Jan 2021 14:56:46 +0000 Subject: [PATCH 15/21] [CON-2991] Remove storage redis connection config as not used --- src/QA/QA.Web/appsettings.json | 1 - 1 file changed, 1 deletion(-) diff --git a/src/QA/QA.Web/appsettings.json b/src/QA/QA.Web/appsettings.json index 9e9b5bf749..59fbb3fbdb 100644 --- a/src/QA/QA.Web/appsettings.json +++ b/src/QA/QA.Web/appsettings.json @@ -16,7 +16,6 @@ }, "ConnectionStrings": { "Redis": "", - "StorageRedis": "", "MongoDb": "", "QueueStorage": "", "TableStorage": "", From 0829c6570f43155e0e26e97db6b7b7310605ab65 Mon Sep 17 00:00:00 2001 From: Corey Date: Fri, 15 Jan 2021 14:57:30 +0000 Subject: [PATCH 16/21] [CON-2991] Add redis data protection for Provider web --- src/Provider/Provider.Web/Startup.ConfigureServices.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Provider/Provider.Web/Startup.ConfigureServices.cs b/src/Provider/Provider.Web/Startup.ConfigureServices.cs index 16bca1f93b..f13fc5fe06 100644 --- a/src/Provider/Provider.Web/Startup.ConfigureServices.cs +++ b/src/Provider/Provider.Web/Startup.ConfigureServices.cs @@ -1,4 +1,5 @@ using Esfa.Recruit.Provider.Web.Configuration; +using Esfa.Recruit.Shared.Web.Extensions; using Esfa.Recruit.Vacancies.Client.Infrastructure.Client; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc.Razor; @@ -43,6 +44,7 @@ public void ConfigureServices(IServiceCollection services) }); services.AddMvcService(_hostingEnvironment, _loggerFactory); + services.AddDataProtection(_configuration, _hostingEnvironment); services.AddApplicationInsightsTelemetry(_configuration); From c16922fb904a491c25868aade0a7c6b3764f9266 Mon Sep 17 00:00:00 2001 From: Corey Date: Fri, 15 Jan 2021 15:19:06 +0000 Subject: [PATCH 17/21] [CON-2991] Remove employer web unnecessary ioc --- src/Employer/Employer.Web/Configuration/IoC.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Employer/Employer.Web/Configuration/IoC.cs b/src/Employer/Employer.Web/Configuration/IoC.cs index 848b955ebb..9fd556b14c 100644 --- a/src/Employer/Employer.Web/Configuration/IoC.cs +++ b/src/Employer/Employer.Web/Configuration/IoC.cs @@ -41,7 +41,6 @@ public static void AddIoC(this IServiceCollection services, IConfiguration confi services.Configure(configuration.GetSection("PostcodeAnywhere")); services.Configure(configuration.GetSection("FaaConfiguration")); services.Configure(configuration.GetSection("ZenDesk")); - services.Configure(configuration.GetSection("RedisConnectionSettings")); services.AddFeatureToggle(); From 7d14c43cdad498c1346983cd96f05b6c05d4ec14 Mon Sep 17 00:00:00 2001 From: Corey Date: Fri, 15 Jan 2021 15:19:39 +0000 Subject: [PATCH 18/21] [CON-2911] Local config for Provider web --- src/Provider/Provider.Web/appsettings.Development.json | 6 +++++- src/Provider/Provider.Web/appsettings.json | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Provider/Provider.Web/appsettings.Development.json b/src/Provider/Provider.Web/appsettings.Development.json index 8d422b6333..6e26154f1d 100644 --- a/src/Provider/Provider.Web/appsettings.Development.json +++ b/src/Provider/Provider.Web/appsettings.Development.json @@ -30,5 +30,9 @@ "QueueStorage": "UseDevelopmentStorage=true", "TableStorage": "UseDevelopmentStorage=true" }, - "UseTableStorageQueryStore": false + "UseTableStorageQueryStore": false, + "RedisConnectionSettings": { + "RedisConnectionString": "localhost:6379", + "DataProtectionKeysDatabase": "abc123" + } } diff --git a/src/Provider/Provider.Web/appsettings.json b/src/Provider/Provider.Web/appsettings.json index af954c6282..4dd285fc8e 100644 --- a/src/Provider/Provider.Web/appsettings.json +++ b/src/Provider/Provider.Web/appsettings.json @@ -69,7 +69,6 @@ }, "ConnectionStrings": { "Redis": "", - "StorageRedis": "", "MongoDb": "", "QueueStorage": "", "TableStorage": "" @@ -93,5 +92,9 @@ "ClientId": "", "ClientSecret": "", "ApiBaseUrl": "" + }, + "RedisConnectionSettings": { + "RedisConnectionString": "", + "DataProtectionKeysDatabase": "" } } From 467d2b3255d311dc16be24aa23a4532e5bbe4af4 Mon Sep 17 00:00:00 2001 From: Corey Date: Fri, 15 Jan 2021 15:21:18 +0000 Subject: [PATCH 19/21] [CON-2991] Update template json for Provider web Redis connection settings --- azure/template.json | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/azure/template.json b/azure/template.json index 18f7974370..5e44d2f969 100644 --- a/azure/template.json +++ b/azure/template.json @@ -1040,7 +1040,15 @@ { "name": "ProviderRelationshipsApiConfiguration:Tenant", "value": "[parameters('ProviderRelationshipsApiConfiguration').Tenant]" - } + }, + { + "name": "RedisConnectionSettings:RedisConnectionString", + "value": "[parameters('StorageRedisConnectionString')]" + }, + { + "name": "RedisConnectionSettings:DataProtectionKeysDatabase", + "value": "[parameters('DataProtectionKeysDatabase')]" + } ] } }, @@ -1052,11 +1060,6 @@ "connectionString": "[parameters('LoggingRedisConnectionString')]", "type": "Custom" }, - { - "name": "StorageRedis", - "connectionString": "[parameters('StorageRedisConnectionString')]", - "type": "Custom" - }, { "name": "MongoDb", "connectionString": "[concat('mongodb://', variables('CosmosDbName'), ':', reference(variables('CosmosDbName')).outputs.PrimaryMasterKey.value,'@', variables('CosmosDbName'), '.documents.azure.com:10255/?ssl=true&replicaSet=globaldb')]", From 66bd53a39f9cbc008681bf56c918ecf620eb269a Mon Sep 17 00:00:00 2001 From: Corey Date: Mon, 18 Jan 2021 09:15:33 +0000 Subject: [PATCH 20/21] [CON-2991] Pass application name into shared extnsion for Redis Data Protection --- src/Employer/Employer.Web/Startup.ConfigureServices.cs | 2 +- src/Provider/Provider.Web/Startup.ConfigureServices.cs | 2 +- src/QA/QA.Web/Startup.ConfigureServices.cs | 2 +- .../Extensions/DataProtectionStartupExtensions.cs | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Employer/Employer.Web/Startup.ConfigureServices.cs b/src/Employer/Employer.Web/Startup.ConfigureServices.cs index b91560aef3..e1665366b8 100644 --- a/src/Employer/Employer.Web/Startup.ConfigureServices.cs +++ b/src/Employer/Employer.Web/Startup.ConfigureServices.cs @@ -60,7 +60,7 @@ public void ConfigureServices(IServiceCollection services) services.AddAuthorizationService(); } - services.AddDataProtection(_configuration, _hostingEnvironment); + services.AddDataProtection(_configuration, _hostingEnvironment, applicationName: "das-employer-recruit-web"); } } } diff --git a/src/Provider/Provider.Web/Startup.ConfigureServices.cs b/src/Provider/Provider.Web/Startup.ConfigureServices.cs index f13fc5fe06..7608ce2419 100644 --- a/src/Provider/Provider.Web/Startup.ConfigureServices.cs +++ b/src/Provider/Provider.Web/Startup.ConfigureServices.cs @@ -44,7 +44,7 @@ public void ConfigureServices(IServiceCollection services) }); services.AddMvcService(_hostingEnvironment, _loggerFactory); - services.AddDataProtection(_configuration, _hostingEnvironment); + services.AddDataProtection(_configuration, _hostingEnvironment, applicationName: "das-provider-recruit-web"); services.AddApplicationInsightsTelemetry(_configuration); diff --git a/src/QA/QA.Web/Startup.ConfigureServices.cs b/src/QA/QA.Web/Startup.ConfigureServices.cs index 4f9603d462..9bd44903d2 100644 --- a/src/QA/QA.Web/Startup.ConfigureServices.cs +++ b/src/QA/QA.Web/Startup.ConfigureServices.cs @@ -58,7 +58,7 @@ public void ConfigureServices(IServiceCollection services) }); services.AddMvcService(_loggerFactory); - services.AddDataProtection(_configuration, _hostingEnvironment); + services.AddDataProtection(_configuration, _hostingEnvironment, applicationName: "das-qa-recruit-web"); services.AddAntiforgery( options => diff --git a/src/Shared/Recruit.Shared.Web/Extensions/DataProtectionStartupExtensions.cs b/src/Shared/Recruit.Shared.Web/Extensions/DataProtectionStartupExtensions.cs index a3efed6dba..0a81bce6e8 100644 --- a/src/Shared/Recruit.Shared.Web/Extensions/DataProtectionStartupExtensions.cs +++ b/src/Shared/Recruit.Shared.Web/Extensions/DataProtectionStartupExtensions.cs @@ -9,7 +9,7 @@ namespace Esfa.Recruit.Shared.Web.Extensions { public static class DataProtectionStartupExtensions { - public static IServiceCollection AddDataProtection(this IServiceCollection services, IConfiguration configuration, IHostingEnvironment environment) + public static IServiceCollection AddDataProtection(this IServiceCollection services, IConfiguration configuration, IHostingEnvironment environment, string applicationName) { if (!environment.IsDevelopment()) { @@ -25,7 +25,7 @@ public static IServiceCollection AddDataProtection(this IServiceCollection servi .Connect($"{redisConnectionString},{dataProtectionKeysDatabase}"); services.AddDataProtection() - .SetApplicationName("das-employer-recruit") + .SetApplicationName(applicationName) .PersistKeysToStackExchangeRedis(redis, "DataProtection-Keys"); } } From 3351eff06c29327be6d88d37ccd07aed97994f00 Mon Sep 17 00:00:00 2001 From: Corey Date: Tue, 19 Jan 2021 15:19:45 +0000 Subject: [PATCH 21/21] [CON-2991] Downgrade stack exchange redis version to alleviate dependency mismatch --- src/Shared/Recruit.Shared.Web/Recruit.Shared.Web.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Shared/Recruit.Shared.Web/Recruit.Shared.Web.csproj b/src/Shared/Recruit.Shared.Web/Recruit.Shared.Web.csproj index 75f685806e..21662a18c6 100644 --- a/src/Shared/Recruit.Shared.Web/Recruit.Shared.Web.csproj +++ b/src/Shared/Recruit.Shared.Web/Recruit.Shared.Web.csproj @@ -9,7 +9,7 @@ - +