diff --git a/src/Umbraco.Configuration/AspNetCoreConfigsFactory.cs b/src/Umbraco.Configuration/AspNetCoreConfigsFactory.cs index 600a7075b8..1e9f7976d5 100644 --- a/src/Umbraco.Configuration/AspNetCoreConfigsFactory.cs +++ b/src/Umbraco.Configuration/AspNetCoreConfigsFactory.cs @@ -42,7 +42,6 @@ namespace Umbraco.Configuration configs.Add(() => new HostingSettings(_configuration)); configs.Add(() => new GlobalSettings(_configuration)); configs.Add(() => new ConnectionStrings(_configuration)); - configs.Add(() => new MachineKeyConfig(_configuration)); configs.Add(() => new ImagingSettings(_configuration)); return configs; diff --git a/src/Umbraco.Configuration/ConfigsFactory.cs b/src/Umbraco.Configuration/ConfigsFactory.cs index 46528b102f..be6cee2d0c 100644 --- a/src/Umbraco.Configuration/ConfigsFactory.cs +++ b/src/Umbraco.Configuration/ConfigsFactory.cs @@ -11,7 +11,6 @@ namespace Umbraco.Core.Configuration { public IHostingSettings HostingSettings { get; } = new HostingSettings(); public ICoreDebugSettings CoreDebugSettings { get; } = new CoreDebugSettings(); - public IMachineKeyConfig MachineKeyConfig { get; } = new MachineKeyConfig(); public IIndexCreatorSettings IndexCreatorSettings { get; } = new IndexCreatorSettings(); public INuCacheSettings NuCacheSettings { get; } = new NuCacheSettings(); public ITypeFinderSettings TypeFinderSettings { get; } = new TypeFinderSettings(); @@ -40,7 +39,6 @@ namespace Umbraco.Core.Configuration configs.Add(() => HostingSettings); configs.Add(() => HealthChecksSettings); configs.Add(() => CoreDebugSettings); - configs.Add(() => MachineKeyConfig); configs.Add(() => ConnectionStrings); configs.Add(() => ModelsBuilderConfig); configs.Add(() => IndexCreatorSettings); diff --git a/src/Umbraco.Configuration/Legacy/MachineKeyConfig.cs b/src/Umbraco.Configuration/Legacy/MachineKeyConfig.cs deleted file mode 100644 index ba5880e3ad..0000000000 --- a/src/Umbraco.Configuration/Legacy/MachineKeyConfig.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Configuration; -using Umbraco.Core.Configuration; - -namespace Umbraco.Configuration.Legacy -{ - public class MachineKeyConfig : IMachineKeyConfig - { - //TODO all the machineKey stuff should be replaced: https://docs.microsoft.com/en-us/aspnet/core/security/data-protection/compatibility/replacing-machinekey?view=aspnetcore-3.1 - - public bool HasMachineKey - { - get - { - var machineKeySection = - ConfigurationManager.GetSection("system.web/machineKey") as ConfigurationSection; - return !(machineKeySection?.ElementInformation?.Source is null); - } - } - } -} diff --git a/src/Umbraco.Configuration/Models/MachineKeyConfig.cs b/src/Umbraco.Configuration/Models/MachineKeyConfig.cs deleted file mode 100644 index 621827d5a3..0000000000 --- a/src/Umbraco.Configuration/Models/MachineKeyConfig.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using Microsoft.Extensions.Configuration; -using Umbraco.Core.Configuration; - -namespace Umbraco.Configuration.Models -{ - internal class MachineKeyConfig : IMachineKeyConfig - { - private readonly IConfiguration _configuration; - - public MachineKeyConfig(IConfiguration configuration) - { - _configuration = configuration; - } - - //TODO all the machineKey stuff should be replaced: https://docs.microsoft.com/en-us/aspnet/core/security/data-protection/compatibility/replacing-machinekey?view=aspnetcore-3.1 - - public bool HasMachineKey => throw new NotImplementedException("TODO we need to figure out what to do here"); - } -} diff --git a/src/Umbraco.Core/Configuration/IMachineKeyConfig.cs b/src/Umbraco.Core/Configuration/IMachineKeyConfig.cs deleted file mode 100644 index 35969e668a..0000000000 --- a/src/Umbraco.Core/Configuration/IMachineKeyConfig.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Umbraco.Core.Configuration -{ - public interface IMachineKeyConfig - { - bool HasMachineKey { get;} - } -} diff --git a/src/Umbraco.Infrastructure/Intall/InstallSteps/ConfigureMachineKey.cs b/src/Umbraco.Infrastructure/Intall/InstallSteps/ConfigureMachineKey.cs deleted file mode 100644 index fb8201600c..0000000000 --- a/src/Umbraco.Infrastructure/Intall/InstallSteps/ConfigureMachineKey.cs +++ /dev/null @@ -1,71 +0,0 @@ -using System.Linq; -using System.Threading.Tasks; -using System.Xml.Linq; -using Umbraco.Core.Configuration; -using Umbraco.Core.IO; -using Umbraco.Core.Security; -using Umbraco.Web.Install.Models; - -namespace Umbraco.Web.Install.InstallSteps -{ - [InstallSetupStep(InstallationType.NewInstall, - "ConfigureMachineKey", "machinekey", 2, - "Updating some security settings...", - PerformsAppRestart = true)] - public class ConfigureMachineKey : InstallSetupStep - { - private readonly IIOHelper _ioHelper; - private readonly IMachineKeyConfig _machineKeyConfig; - - public ConfigureMachineKey(IIOHelper ioHelper, IMachineKeyConfig machineKeyConfig) - { - _ioHelper = ioHelper; - _machineKeyConfig = machineKeyConfig; - } - - public override string View => HasMachineKey() == false ? base.View : ""; - - /// - /// Don't display the view or execute if a machine key already exists - /// - /// - private bool HasMachineKey() - { - return _machineKeyConfig.HasMachineKey; - } - - /// - /// The step execution method - /// - /// - /// - public override Task ExecuteAsync(bool? model) - { - if (model.HasValue && model.Value == false) return Task.FromResult(null); - - //install the machine key - var fileName = _ioHelper.MapPath($"{_ioHelper.Root}/web.config"); - var xml = XDocument.Load(fileName, LoadOptions.PreserveWhitespace); - - // we only want to get the element that is under the root, (there may be more under tags we don't want them) - var systemWeb = xml.Root.Element("system.web"); - - // Update appSetting if it exists, or else create a new appSetting for the given key and value - var machineKey = systemWeb.Descendants("machineKey").FirstOrDefault(); - if (machineKey != null) return Task.FromResult(null); - - var generator = new MachineKeyGenerator(); - var generatedSection = generator.GenerateConfigurationBlock(); - systemWeb.Add(XElement.Parse(generatedSection)); - - xml.Save(fileName, SaveOptions.DisableFormatting); - - return Task.FromResult(null); - } - - public override bool RequiresExecution(bool? model) - { - return HasMachineKey() == false; - } - } -} diff --git a/src/Umbraco.Web/Composing/CompositionExtensions/Installer.cs b/src/Umbraco.Web/Composing/CompositionExtensions/Installer.cs index 9a3e8d98f8..64f91939a7 100644 --- a/src/Umbraco.Web/Composing/CompositionExtensions/Installer.cs +++ b/src/Umbraco.Web/Composing/CompositionExtensions/Installer.cs @@ -14,7 +14,6 @@ namespace Umbraco.Web.Composing.CompositionExtensions composition.Register(Lifetime.Scope); composition.Register(Lifetime.Scope); composition.Register(Lifetime.Scope); - composition.Register(Lifetime.Scope); composition.Register(Lifetime.Scope); composition.Register(Lifetime.Scope); composition.Register(Lifetime.Scope); diff --git a/src/Umbraco.Web/Install/InstallStepCollection.cs b/src/Umbraco.Web/Install/InstallStepCollection.cs index ece9f0be12..f31f5f7dbb 100644 --- a/src/Umbraco.Web/Install/InstallStepCollection.cs +++ b/src/Umbraco.Web/Install/InstallStepCollection.cs @@ -21,7 +21,6 @@ namespace Umbraco.Web.Install a.OfType().First(), a.OfType().First(), a.OfType().First(), - a.OfType().First(), a.OfType().First(), a.OfType().First(), a.OfType().First(),