Removed Machine key stuff
This commit is contained in:
@@ -42,7 +42,6 @@ namespace Umbraco.Configuration
|
||||
configs.Add<IHostingSettings>(() => new HostingSettings(_configuration));
|
||||
configs.Add<IGlobalSettings>(() => new GlobalSettings(_configuration));
|
||||
configs.Add<IConnectionStrings>(() => new ConnectionStrings(_configuration));
|
||||
configs.Add<IMachineKeyConfig>(() => new MachineKeyConfig(_configuration));
|
||||
configs.Add<IImagingSettings>(() => new ImagingSettings(_configuration));
|
||||
|
||||
return configs;
|
||||
|
||||
@@ -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<IHostingSettings>(() => HostingSettings);
|
||||
configs.Add<IHealthChecksSettings>(() => HealthChecksSettings);
|
||||
configs.Add<ICoreDebugSettings>(() => CoreDebugSettings);
|
||||
configs.Add<IMachineKeyConfig>(() => MachineKeyConfig);
|
||||
configs.Add<IConnectionStrings>(() => ConnectionStrings);
|
||||
configs.Add<IModelsBuilderConfig>(() => ModelsBuilderConfig);
|
||||
configs.Add<IIndexCreatorSettings>(() => IndexCreatorSettings);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
namespace Umbraco.Core.Configuration
|
||||
{
|
||||
public interface IMachineKeyConfig
|
||||
{
|
||||
bool HasMachineKey { get;}
|
||||
}
|
||||
}
|
||||
@@ -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<bool?>
|
||||
{
|
||||
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 : "";
|
||||
|
||||
/// <summary>
|
||||
/// Don't display the view or execute if a machine key already exists
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private bool HasMachineKey()
|
||||
{
|
||||
return _machineKeyConfig.HasMachineKey;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The step execution method
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public override Task<InstallSetupResult> ExecuteAsync(bool? model)
|
||||
{
|
||||
if (model.HasValue && model.Value == false) return Task.FromResult<InstallSetupResult>(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 <location> 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<InstallSetupResult>(null);
|
||||
|
||||
var generator = new MachineKeyGenerator();
|
||||
var generatedSection = generator.GenerateConfigurationBlock();
|
||||
systemWeb.Add(XElement.Parse(generatedSection));
|
||||
|
||||
xml.Save(fileName, SaveOptions.DisableFormatting);
|
||||
|
||||
return Task.FromResult<InstallSetupResult>(null);
|
||||
}
|
||||
|
||||
public override bool RequiresExecution(bool? model)
|
||||
{
|
||||
return HasMachineKey() == false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,6 @@ namespace Umbraco.Web.Composing.CompositionExtensions
|
||||
composition.Register<NewInstallStep>(Lifetime.Scope);
|
||||
composition.Register<UpgradeStep>(Lifetime.Scope);
|
||||
composition.Register<FilePermissionsStep>(Lifetime.Scope);
|
||||
composition.Register<ConfigureMachineKey>(Lifetime.Scope);
|
||||
composition.Register<DatabaseConfigureStep>(Lifetime.Scope);
|
||||
composition.Register<DatabaseInstallStep>(Lifetime.Scope);
|
||||
composition.Register<DatabaseUpgradeStep>(Lifetime.Scope);
|
||||
|
||||
@@ -21,7 +21,6 @@ namespace Umbraco.Web.Install
|
||||
a.OfType<NewInstallStep>().First(),
|
||||
a.OfType<UpgradeStep>().First(),
|
||||
a.OfType<FilePermissionsStep>().First(),
|
||||
a.OfType<ConfigureMachineKey>().First(),
|
||||
a.OfType<DatabaseConfigureStep>().First(),
|
||||
a.OfType<DatabaseInstallStep>().First(),
|
||||
a.OfType<DatabaseUpgradeStep>().First(),
|
||||
|
||||
Reference in New Issue
Block a user