diff --git a/src/Umbraco.Configuration/AspNetCoreConfigsFactory.cs b/src/Umbraco.Configuration/AspNetCoreConfigsFactory.cs new file mode 100644 index 0000000000..aa09d6cd4c --- /dev/null +++ b/src/Umbraco.Configuration/AspNetCoreConfigsFactory.cs @@ -0,0 +1,53 @@ +using Microsoft.Extensions.Configuration; +using Umbraco.Configuration.Models; +using Umbraco.Core.Configuration; +using Umbraco.Core.Configuration.HealthChecks; +using Umbraco.Core.Configuration.UmbracoSettings; +using CoreDebugSettings = Umbraco.Configuration.Models.CoreDebugSettings; + +namespace Umbraco.Configuration +{ + public class AspNetCoreConfigsFactory : IConfigsFactory + { + private readonly IConfiguration _configuration; + + public AspNetCoreConfigsFactory(IConfiguration configuration) + { + _configuration = configuration; + } + + public Configs Create() + { + var configs = new Configs(); + + configs.Add(() => new TourSettings(_configuration)); + configs.Add(() => new CoreDebugSettings(_configuration)); + configs.Add(() => new RequestHandlerSettings(_configuration)); + configs.Add(() => new SecuritySettings(_configuration)); + configs.Add(() => new UserPasswordConfigurationSettings(_configuration)); + configs.Add(() => new MemberPasswordConfigurationSettings(_configuration)); + configs.Add(() => new KeepAliveSettings(_configuration)); + configs.Add(() => new ContentSettings(_configuration)); + configs.Add(() => new HealthChecksSettingsSettings(_configuration)); + configs.Add(() => new LoggingSettings(_configuration)); + configs.Add(() => new ExceptionFilterSettings(_configuration)); + configs.Add(() => new ActiveDirectorySettings(_configuration)); + configs.Add(() => new RuntimeSettings(_configuration)); + configs.Add(() => new TypeFinderSettings(_configuration)); + configs.Add(() => new NuCacheSettings(_configuration)); + configs.Add(() => new WebRoutingSettings(_configuration)); + configs.Add(() => new IndexCreatorSettings(_configuration)); + configs.Add(() => new ModelsBuilderConfig(_configuration)); + + // configs.Add(() => GlobalSettings); + // configs.Add(() => ConnectionStrings); + // configs.Add(() => HostingSettings); + // configs.Add(() => MachineKeyConfig); + + + + + return configs; + } + } +} diff --git a/src/Umbraco.Configuration/ConfigsFactory.cs b/src/Umbraco.Configuration/ConfigsFactory.cs index 5c6eade265..2f8ea02b77 100644 --- a/src/Umbraco.Configuration/ConfigsFactory.cs +++ b/src/Umbraco.Configuration/ConfigsFactory.cs @@ -1,5 +1,6 @@ using Umbraco.Configuration; using Umbraco.Configuration.Implementations; +using Umbraco.Configuration.Legacy; using Umbraco.Core.Configuration.HealthChecks; using Umbraco.Core.Configuration.Implementations; using Umbraco.Core.Configuration.UmbracoSettings; @@ -9,7 +10,7 @@ namespace Umbraco.Core.Configuration public class ConfigsFactory : IConfigsFactory { public IHostingSettings HostingSettings { get; } = new HostingSettings(); - public ICoreDebug CoreDebug { get; } = new CoreDebug(); + public ICoreDebugSettings CoreDebugSettings { get; } = new CoreDebugSettings(); public IMachineKeyConfig MachineKeyConfig { get; } = new MachineKeyConfig(); public IIndexCreatorSettings IndexCreatorSettings { get; } = new IndexCreatorSettings(); public INuCacheSettings NuCacheSettings { get; } = new NuCacheSettings(); @@ -27,7 +28,7 @@ namespace Umbraco.Core.Configuration public IMemberPasswordConfiguration MemberPasswordConfigurationSettings { get; } = new MemberPasswordConfigurationSettings(); public IContentSettings ContentSettings { get; } = new ContentSettings(); public IGlobalSettings GlobalSettings { get; } = new GlobalSettings(); - public IHealthChecks HealthChecksSettings { get; } = new HealthChecksSettings(); + public IHealthChecksSettings HealthChecksSettingsSettings { get; } = new HealthChecksSettingsSettings(); public IConnectionStrings ConnectionStrings { get; } = new ConnectionStrings(); public IModelsBuilderConfig ModelsBuilderConfig { get; } = new ModelsBuilderConfig(); @@ -37,8 +38,8 @@ namespace Umbraco.Core.Configuration configs.Add(() => GlobalSettings); configs.Add(() => HostingSettings); - configs.Add(() => HealthChecksSettings); - configs.Add(() => CoreDebug); + configs.Add(() => HealthChecksSettingsSettings); + configs.Add(() => CoreDebugSettings); configs.Add(() => MachineKeyConfig); configs.Add(() => ConnectionStrings); configs.Add(() => ModelsBuilderConfig); diff --git a/src/Umbraco.Configuration/ActiveDirectorySettings.cs b/src/Umbraco.Configuration/Legacy/ActiveDirectorySettings.cs similarity index 90% rename from src/Umbraco.Configuration/ActiveDirectorySettings.cs rename to src/Umbraco.Configuration/Legacy/ActiveDirectorySettings.cs index d85def7f33..ef100afed6 100644 --- a/src/Umbraco.Configuration/ActiveDirectorySettings.cs +++ b/src/Umbraco.Configuration/Legacy/ActiveDirectorySettings.cs @@ -1,7 +1,7 @@ using System.Configuration; using Umbraco.Core.Configuration; -namespace Umbraco.Configuration +namespace Umbraco.Configuration.Legacy { public class ActiveDirectorySettings : IActiveDirectorySettings { diff --git a/src/Umbraco.Configuration/Implementations/ConfigurationManagerConfigBase.cs b/src/Umbraco.Configuration/Legacy/ConfigurationManagerConfigBase.cs similarity index 100% rename from src/Umbraco.Configuration/Implementations/ConfigurationManagerConfigBase.cs rename to src/Umbraco.Configuration/Legacy/ConfigurationManagerConfigBase.cs diff --git a/src/Umbraco.Configuration/Implementations/ContentSettings.cs b/src/Umbraco.Configuration/Legacy/ContentSettings.cs similarity index 100% rename from src/Umbraco.Configuration/Implementations/ContentSettings.cs rename to src/Umbraco.Configuration/Legacy/ContentSettings.cs diff --git a/src/Umbraco.Configuration/CoreDebug.cs b/src/Umbraco.Configuration/Legacy/CoreDebugSettings.cs similarity index 87% rename from src/Umbraco.Configuration/CoreDebug.cs rename to src/Umbraco.Configuration/Legacy/CoreDebugSettings.cs index 0ff3274565..4902d4489f 100644 --- a/src/Umbraco.Configuration/CoreDebug.cs +++ b/src/Umbraco.Configuration/Legacy/CoreDebugSettings.cs @@ -3,9 +3,9 @@ using System.Configuration; namespace Umbraco.Core.Configuration { - public class CoreDebug : ICoreDebug + public class CoreDebugSettings : ICoreDebugSettings { - public CoreDebug() + public CoreDebugSettings() { var appSettings = ConfigurationManager.AppSettings; LogUncompletedScopes = string.Equals("true", appSettings[Constants.AppSettings.Debug.LogUncompletedScopes], StringComparison.OrdinalIgnoreCase); diff --git a/src/Umbraco.Configuration/ExceptionFilterSettings.cs b/src/Umbraco.Configuration/Legacy/ExceptionFilterSettings.cs similarity index 92% rename from src/Umbraco.Configuration/ExceptionFilterSettings.cs rename to src/Umbraco.Configuration/Legacy/ExceptionFilterSettings.cs index 628b8755cc..50e2207485 100644 --- a/src/Umbraco.Configuration/ExceptionFilterSettings.cs +++ b/src/Umbraco.Configuration/Legacy/ExceptionFilterSettings.cs @@ -1,7 +1,7 @@ using System.Configuration; using Umbraco.Core.Configuration; -namespace Umbraco.Configuration +namespace Umbraco.Configuration.Legacy { public class ExceptionFilterSettings : IExceptionFilterSettings { diff --git a/src/Umbraco.Configuration/Implementations/HealthChecksSettings.cs b/src/Umbraco.Configuration/Legacy/HealthChecksSettingsSettings.cs similarity index 92% rename from src/Umbraco.Configuration/Implementations/HealthChecksSettings.cs rename to src/Umbraco.Configuration/Legacy/HealthChecksSettingsSettings.cs index 656a3ffc82..ee38b5791b 100644 --- a/src/Umbraco.Configuration/Implementations/HealthChecksSettings.cs +++ b/src/Umbraco.Configuration/Legacy/HealthChecksSettingsSettings.cs @@ -4,7 +4,7 @@ using Umbraco.Core.Configuration.HealthChecks; namespace Umbraco.Core.Configuration.Implementations { - public class HealthChecksSettings : IHealthChecks + public class HealthChecksSettingsSettings : IHealthChecksSettings { private HealthChecksSection _healthChecksSection; diff --git a/src/Umbraco.Configuration/IndexCreatorSettings.cs b/src/Umbraco.Configuration/Legacy/IndexCreatorSettings.cs similarity index 78% rename from src/Umbraco.Configuration/IndexCreatorSettings.cs rename to src/Umbraco.Configuration/Legacy/IndexCreatorSettings.cs index 00d1a29dba..d023d46246 100644 --- a/src/Umbraco.Configuration/IndexCreatorSettings.cs +++ b/src/Umbraco.Configuration/Legacy/IndexCreatorSettings.cs @@ -1,13 +1,13 @@ using System.Configuration; using Umbraco.Core.Configuration; -namespace Umbraco.Configuration +namespace Umbraco.Configuration.Legacy { public class IndexCreatorSettings : IIndexCreatorSettings { public IndexCreatorSettings() { - LuceneDirectoryFactory = ConfigurationManager.AppSettings["Umbraco.Examine.LuceneDirectoryFactory"]; + LuceneDirectoryFactory = ConfigurationManager.AppSettings["Umbraco.Examine.LuceneDirectoryFactory"]; } public string LuceneDirectoryFactory { get; } diff --git a/src/Umbraco.Configuration/Implementations/KeepAliveSettings.cs b/src/Umbraco.Configuration/Legacy/KeepAliveSettings.cs similarity index 100% rename from src/Umbraco.Configuration/Implementations/KeepAliveSettings.cs rename to src/Umbraco.Configuration/Legacy/KeepAliveSettings.cs diff --git a/src/Umbraco.Configuration/Implementations/LoggingSettings.cs b/src/Umbraco.Configuration/Legacy/LoggingSettings.cs similarity index 100% rename from src/Umbraco.Configuration/Implementations/LoggingSettings.cs rename to src/Umbraco.Configuration/Legacy/LoggingSettings.cs diff --git a/src/Umbraco.Configuration/Implementations/MemberPasswordConfigurationSettings.cs b/src/Umbraco.Configuration/Legacy/MemberPasswordConfigurationSettings.cs similarity index 100% rename from src/Umbraco.Configuration/Implementations/MemberPasswordConfigurationSettings.cs rename to src/Umbraco.Configuration/Legacy/MemberPasswordConfigurationSettings.cs diff --git a/src/Umbraco.Configuration/ModelsBuilderConfig.cs b/src/Umbraco.Configuration/Legacy/ModelsBuilderConfig.cs similarity index 99% rename from src/Umbraco.Configuration/ModelsBuilderConfig.cs rename to src/Umbraco.Configuration/Legacy/ModelsBuilderConfig.cs index a855d17d96..ec7046d6d8 100644 --- a/src/Umbraco.Configuration/ModelsBuilderConfig.cs +++ b/src/Umbraco.Configuration/Legacy/ModelsBuilderConfig.cs @@ -6,7 +6,7 @@ using Umbraco.Core.Configuration; using Umbraco.Core; using Umbraco.Core.IO; -namespace Umbraco.Configuration +namespace Umbraco.Configuration.Legacy { /// /// Represents the models builder configuration. diff --git a/src/Umbraco.Configuration/NuCacheSettings.cs b/src/Umbraco.Configuration/Legacy/NuCacheSettings.cs similarity index 89% rename from src/Umbraco.Configuration/NuCacheSettings.cs rename to src/Umbraco.Configuration/Legacy/NuCacheSettings.cs index c3a286d33d..25f52a5c7d 100644 --- a/src/Umbraco.Configuration/NuCacheSettings.cs +++ b/src/Umbraco.Configuration/Legacy/NuCacheSettings.cs @@ -1,7 +1,7 @@ using System.Configuration; using Umbraco.Core.Configuration; -namespace Umbraco.Configuration +namespace Umbraco.Configuration.Legacy { public class NuCacheSettings : INuCacheSettings { diff --git a/src/Umbraco.Configuration/Implementations/RequestHandlerSettings.cs b/src/Umbraco.Configuration/Legacy/RequestHandlerSettings.cs similarity index 100% rename from src/Umbraco.Configuration/Implementations/RequestHandlerSettings.cs rename to src/Umbraco.Configuration/Legacy/RequestHandlerSettings.cs diff --git a/src/Umbraco.Configuration/RuntimeSettings.cs b/src/Umbraco.Configuration/Legacy/RuntimeSettings.cs similarity index 96% rename from src/Umbraco.Configuration/RuntimeSettings.cs rename to src/Umbraco.Configuration/Legacy/RuntimeSettings.cs index 6dc8d6f832..200642a819 100644 --- a/src/Umbraco.Configuration/RuntimeSettings.cs +++ b/src/Umbraco.Configuration/Legacy/RuntimeSettings.cs @@ -1,7 +1,7 @@ using System.Configuration; using Umbraco.Core.Configuration; -namespace Umbraco.Configuration +namespace Umbraco.Configuration.Legacy { public class RuntimeSettings : IRuntimeSettings { @@ -24,6 +24,6 @@ namespace Umbraco.Configuration } public int? MaxQueryStringLength { get; } public int? MaxRequestLength { get; } - + } } diff --git a/src/Umbraco.Configuration/Implementations/SecuritySettings.cs b/src/Umbraco.Configuration/Legacy/SecuritySettings.cs similarity index 100% rename from src/Umbraco.Configuration/Implementations/SecuritySettings.cs rename to src/Umbraco.Configuration/Legacy/SecuritySettings.cs diff --git a/src/Umbraco.Configuration/Implementations/TourSettings.cs b/src/Umbraco.Configuration/Legacy/TourSettings.cs similarity index 100% rename from src/Umbraco.Configuration/Implementations/TourSettings.cs rename to src/Umbraco.Configuration/Legacy/TourSettings.cs diff --git a/src/Umbraco.Configuration/TypeFinderSettings.cs b/src/Umbraco.Configuration/Legacy/TypeFinderSettings.cs similarity index 91% rename from src/Umbraco.Configuration/TypeFinderSettings.cs rename to src/Umbraco.Configuration/Legacy/TypeFinderSettings.cs index bb3063d7bf..b1009f754b 100644 --- a/src/Umbraco.Configuration/TypeFinderSettings.cs +++ b/src/Umbraco.Configuration/Legacy/TypeFinderSettings.cs @@ -1,8 +1,8 @@ using System.Configuration; -using Umbraco.Core.Configuration; using Umbraco.Core; +using Umbraco.Core.Configuration; -namespace Umbraco.Configuration +namespace Umbraco.Configuration.Legacy { public class TypeFinderSettings : ITypeFinderSettings { diff --git a/src/Umbraco.Configuration/Implementations/UserPasswordConfigurationSettings.cs b/src/Umbraco.Configuration/Legacy/UserPasswordConfigurationSettings.cs similarity index 100% rename from src/Umbraco.Configuration/Implementations/UserPasswordConfigurationSettings.cs rename to src/Umbraco.Configuration/Legacy/UserPasswordConfigurationSettings.cs diff --git a/src/Umbraco.Configuration/Implementations/WebRoutingSettings.cs b/src/Umbraco.Configuration/Legacy/WebRoutingSettings.cs similarity index 100% rename from src/Umbraco.Configuration/Implementations/WebRoutingSettings.cs rename to src/Umbraco.Configuration/Legacy/WebRoutingSettings.cs diff --git a/src/Umbraco.Configuration/Models/ActiveDirectorySettings.cs b/src/Umbraco.Configuration/Models/ActiveDirectorySettings.cs new file mode 100644 index 0000000000..6581bbdd72 --- /dev/null +++ b/src/Umbraco.Configuration/Models/ActiveDirectorySettings.cs @@ -0,0 +1,17 @@ +using Microsoft.Extensions.Configuration; +using Umbraco.Core.Configuration; + +namespace Umbraco.Configuration.Models +{ + internal class ActiveDirectorySettings : IActiveDirectorySettings + { + private readonly IConfiguration _configuration; + + public ActiveDirectorySettings(IConfiguration configuration) + { + _configuration = configuration; + } + + public string ActiveDirectoryDomain => _configuration.GetValue("Umbraco:CMS:ActiveDirectory:Domain"); + } +} diff --git a/src/Umbraco.Configuration/Models/ContentSettings.cs b/src/Umbraco.Configuration/Models/ContentSettings.cs new file mode 100644 index 0000000000..176e424be5 --- /dev/null +++ b/src/Umbraco.Configuration/Models/ContentSettings.cs @@ -0,0 +1,89 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.Extensions.Configuration; +using Umbraco.Core.Configuration.UmbracoSettings; +using Umbraco.Core.Macros; + + +namespace Umbraco.Configuration.Models +{ + internal class ContentSettings : IContentSettings + { + + private readonly IConfiguration _configuration; + public ContentSettings(IConfiguration configuration) + { + _configuration = configuration; + } + + private const string DefaultPreviewBadge = @"
Preview modeClick to end
"; + + private static IEnumerable DefaultImagingAutoFillUploadField = new[] + { + new ImagingAutoFillUploadField() + { + Alias = "umbracoFile" + }, + }; + + public string NotificationEmailAddress => _configuration.GetValue("Umbraco:CMS:Content:Notifications:Email") ?? null; + public bool DisableHtmlEmail => _configuration.GetValue("Umbraco:CMS:Content:Notifications:DisableHtmlEmail") ?? false; + public IEnumerable ImageFileTypes => _configuration.GetValue("Umbraco:CMS:Content:Imaging:ImageFileTypes") ?? new[] {"jpeg", "jpg", "gif", "bmp", "png", "tiff", "tif"}; + public IEnumerable ImageAutoFillProperties => _configuration.GetValue("Umbraco:CMS:Core:Content:Imaging:autoFillImageProperties") ?? DefaultImagingAutoFillUploadField; + + + public bool ResolveUrlsFromTextString => _configuration.GetValue("Umbraco:CMS:Content:ResolveUrlsFromTextString") ?? false; + public IEnumerable Error404Collection => _configuration + .GetSection("Umbraco:CMS:Content:Errors:Error404") + .GetChildren() + .Select(x=> new ContentErrorPage(x)); + public string PreviewBadge => _configuration.GetValue("Umbraco:CMS:Content:PreviewBadge") ?? DefaultPreviewBadge; + public MacroErrorBehaviour MacroErrorBehaviour => _configuration.GetValue("Umbraco:CMS:Content:MacroErrors") ?? MacroErrorBehaviour.Inline; + public IEnumerable DisallowedUploadFiles => _configuration.GetValue("Umbraco:CMS:Content:DisallowedUploadFiles") ?? new[] {"ashx", "aspx", "ascx", "config", "cshtml", "vbhtml", "asmx", "air", "axd"}; + public IEnumerable AllowedUploadFiles => _configuration.GetValue("Umbraco:CMS:Content:AllowedUploadFiles") ?? Array.Empty() ; + public bool ShowDeprecatedPropertyEditors => _configuration.GetValue("Umbraco:CMS:Content:ShowDeprecatedPropertyEditors") ?? false; + public string LoginBackgroundImage => _configuration.GetValue("Umbraco:CMS:Content:LoginBackgroundImage") ?? string.Empty; + + private class ContentErrorPage : IContentErrorPage + { + public ContentErrorPage(IConfigurationSection configurationSection) + { + Culture = configurationSection.Key; + + var value = configurationSection.Value; + + if(int.TryParse(value, out var contentId)) + { + HasContentId = true; + ContentId = contentId; + } + else if(Guid.TryParse(value, out var contentKey)) + { + HasContentKey = true; + ContentKey = contentKey; + } + else + { + ContentXPath = value; + } + } + + public int ContentId { get; set; } + public Guid ContentKey { get; set;} + public string ContentXPath { get; set;} + public bool HasContentId { get; set;} + public bool HasContentKey { get; set;} + public string Culture { get; set; } + } + + private class ImagingAutoFillUploadField : IImagingAutoFillUploadField + { + public string Alias { get; set; } + public string WidthFieldAlias { get; set; } + public string HeightFieldAlias { get; set; } + public string LengthFieldAlias { get; set; } + public string ExtensionFieldAlias { get; set; } + } + } +} diff --git a/src/Umbraco.Configuration/Models/CoreDebugSettings.cs b/src/Umbraco.Configuration/Models/CoreDebugSettings.cs new file mode 100644 index 0000000000..ad01bcdd74 --- /dev/null +++ b/src/Umbraco.Configuration/Models/CoreDebugSettings.cs @@ -0,0 +1,16 @@ +using Microsoft.Extensions.Configuration; +using Umbraco.Core.Configuration; + +namespace Umbraco.Configuration.Models +{ + internal class CoreDebugSettings : ICoreDebugSettings + { + private readonly IConfiguration _configuration; + public CoreDebugSettings(IConfiguration configuration) + { + _configuration = configuration; + } + public bool LogUncompletedScopes => _configuration.GetValue("Umbraco:CMS:Core:Debug:LogUncompletedScopes") ?? false; + public bool DumpOnTimeoutThreadAbort => _configuration.GetValue("Umbraco:CMS:Core:Debug:DumpOnTimeoutThreadAbort") ?? false; + } +} diff --git a/src/Umbraco.Configuration/Models/ExceptionFilterSettings.cs b/src/Umbraco.Configuration/Models/ExceptionFilterSettings.cs new file mode 100644 index 0000000000..fdc01250ed --- /dev/null +++ b/src/Umbraco.Configuration/Models/ExceptionFilterSettings.cs @@ -0,0 +1,17 @@ +using Microsoft.Extensions.Configuration; +using Umbraco.Core.Configuration; + +namespace Umbraco.Configuration.Models +{ + internal class ExceptionFilterSettings : IExceptionFilterSettings + { + private readonly IConfiguration _configuration; + + public ExceptionFilterSettings(IConfiguration configuration) + { + _configuration = configuration; + } + + public bool Disabled => _configuration.GetValue("Umbraco:CMS:ExceptionFilter:Disabled", false); + } +} diff --git a/src/Umbraco.Configuration/Models/HealthChecksSettingsSettings.cs b/src/Umbraco.Configuration/Models/HealthChecksSettingsSettings.cs new file mode 100644 index 0000000000..300a54fb75 --- /dev/null +++ b/src/Umbraco.Configuration/Models/HealthChecksSettingsSettings.cs @@ -0,0 +1,86 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.Extensions.Configuration; +using Umbraco.Core.Configuration.HealthChecks; + +namespace Umbraco.Configuration.Models +{ + internal class HealthChecksSettingsSettings : IHealthChecksSettings + { + private readonly IConfiguration _configuration; + public HealthChecksSettingsSettings(IConfiguration configuration) + { + _configuration = configuration; + } + + public IEnumerable DisabledChecks => _configuration.GetSection("Umbraco:CMS:HealthChecks:DisabledChecks").GetChildren().Select( + x => new DisabledHealthCheck() + { + Id = x.GetValue("Id"), + DisabledOn = x.GetValue("DisabledOn"), + DisabledBy = x.GetValue("DisabledBy"), + }); + public IHealthCheckNotificationSettings NotificationSettings => new HealthCheckNotificationSettings(_configuration.GetSection("Umbraco:CMS:HealthChecks:NotificationSettings")); + + private class DisabledHealthCheck : IDisabledHealthCheck + { + public Guid Id { get; set; } + public DateTime DisabledOn { get;set; } + public int DisabledBy { get;set; } + } + + private class HealthCheckNotificationSettings : IHealthCheckNotificationSettings + { + private readonly IConfigurationSection _configurationSection; + + public HealthCheckNotificationSettings(IConfigurationSection configurationSection) + { + _configurationSection = configurationSection; + } + + public bool Enabled => _configurationSection.GetValue("Enabled", false); + public string FirstRunTime => _configurationSection.GetValue("FirstRunTime"); + public int PeriodInHours => _configurationSection.GetValue("PeriodInHours", 24); + + public IReadOnlyDictionary NotificationMethods => _configurationSection + .GetSection("NotificationMethods") + .GetChildren() + .ToDictionary(x=>x.Key, x=> (INotificationMethod) new NotificationMethod(x.Key, x)); + + public IEnumerable DisabledChecks => + _configurationSection.GetValue("DisabledChecks", Array.Empty()); + } + + private class NotificationMethod : INotificationMethod + { + private readonly IConfigurationSection _configurationSection; + + public NotificationMethod(string alias, IConfigurationSection configurationSection) + { + Alias = alias; + _configurationSection = configurationSection; + } + + public string Alias { get; } + public bool Enabled => _configurationSection.GetValue("Enabled", false); + public HealthCheckNotificationVerbosity Verbosity => _configurationSection.GetValue("Verbosity", HealthCheckNotificationVerbosity.Summary); + public bool FailureOnly => _configurationSection.GetValue("FailureOnly", true); + + public IReadOnlyDictionary Settings => _configurationSection + .GetSection("Settings").GetChildren().ToDictionary(x => x.Key, x => (INotificationMethodSettings)new NotificationMethodSettings(x.Key, x.Value)); + } + + private class NotificationMethodSettings : INotificationMethodSettings + { + public NotificationMethodSettings(string key, string value) + { + Key = key; + Value = value; + } + + public string Key { get; } + public string Value { get; } + } + } +} diff --git a/src/Umbraco.Configuration/Models/IndexCreatorSettings.cs b/src/Umbraco.Configuration/Models/IndexCreatorSettings.cs new file mode 100644 index 0000000000..b483315bf1 --- /dev/null +++ b/src/Umbraco.Configuration/Models/IndexCreatorSettings.cs @@ -0,0 +1,18 @@ +using Microsoft.Extensions.Configuration; +using Umbraco.Core.Configuration; + +namespace Umbraco.Configuration.Models +{ + internal class IndexCreatorSettings : IIndexCreatorSettings + { + private readonly IConfiguration _configuration; + + public IndexCreatorSettings(IConfiguration configuration) + { + _configuration = configuration; + } + + public string LuceneDirectoryFactory => + _configuration.GetValue("Umbraco:CMS:Examine:LuceneDirectoryFactory"); + } +} diff --git a/src/Umbraco.Configuration/Models/KeepAliveSettings.cs b/src/Umbraco.Configuration/Models/KeepAliveSettings.cs new file mode 100644 index 0000000000..4eb7f290a5 --- /dev/null +++ b/src/Umbraco.Configuration/Models/KeepAliveSettings.cs @@ -0,0 +1,16 @@ +using Microsoft.Extensions.Configuration; +using Umbraco.Core.Configuration.UmbracoSettings; + +namespace Umbraco.Configuration.Models +{ + internal class KeepAliveSettings : IKeepAliveSettings + { + private readonly IConfiguration _configuration; + public KeepAliveSettings(IConfiguration configuration) + { + _configuration = configuration; + } + public bool DisableKeepAliveTask => _configuration.GetValue("Umbraco:CMS:KeepAlive:DisableKeepAliveTask") ?? false; + public string KeepAlivePingUrl => _configuration.GetValue("Umbraco:CMS:KeepAlive:KeepAlivePingUrl") ?? "{umbracoApplicationUrl}/api/keepalive/ping"; + } +} diff --git a/src/Umbraco.Configuration/Models/LoggingSettings.cs b/src/Umbraco.Configuration/Models/LoggingSettings.cs new file mode 100644 index 0000000000..c1f3efc816 --- /dev/null +++ b/src/Umbraco.Configuration/Models/LoggingSettings.cs @@ -0,0 +1,15 @@ +using Microsoft.Extensions.Configuration; +using Umbraco.Core.Configuration.UmbracoSettings; + +namespace Umbraco.Configuration.Models +{ + internal class LoggingSettings : ILoggingSettings + { + private readonly IConfiguration _configuration; + public LoggingSettings(IConfiguration configuration) + { + _configuration = configuration; + } + public int MaxLogAge => _configuration.GetValue("Umbraco:CMS:Logging:MaxLogAge") ?? -1; + } +} diff --git a/src/Umbraco.Configuration/Models/MemberPasswordConfigurationSettings.cs b/src/Umbraco.Configuration/Models/MemberPasswordConfigurationSettings.cs new file mode 100644 index 0000000000..31ceca0062 --- /dev/null +++ b/src/Umbraco.Configuration/Models/MemberPasswordConfigurationSettings.cs @@ -0,0 +1,24 @@ +using Microsoft.Extensions.Configuration; +using Umbraco.Core.Configuration; + +namespace Umbraco.Configuration.Models +{ + internal class MemberPasswordConfigurationSettings : IMemberPasswordConfiguration + { + + private readonly IConfiguration _configuration; + public MemberPasswordConfigurationSettings(IConfiguration configuration) + { + _configuration = configuration; + } + + public int RequiredLength => _configuration.GetValue("Umbraco:CMS:Security:MemberPassword:RequiredLength") ?? 10; + public bool RequireNonLetterOrDigit => _configuration.GetValue("Umbraco:CMS:Security:MemberPassword:RequireNonLetterOrDigit") ?? false; + public bool RequireDigit => _configuration.GetValue("Umbraco:CMS:Security:MemberPassword:RequireDigit") ?? false; + public bool RequireLowercase => _configuration.GetValue("Umbraco:CMS:Security:MemberPassword:RequireLowercase") ?? false; + public bool RequireUppercase => _configuration.GetValue("Umbraco:CMS:Security:MemberPassword:RequireUppercase") ?? false; + public bool UseLegacyEncoding => _configuration.GetValue("Umbraco:CMS:Security:MemberPassword:UseLegacyEncoding") ?? false; + public string HashAlgorithmType => _configuration.GetValue("Umbraco:CMS:Security:MemberPassword:HashAlgorithmType") ?? "HMACSHA256"; + public int MaxFailedAccessAttemptsBeforeLockout => _configuration.GetValue("Umbraco:CMS:Security:MemberPassword:MaxFailedAccessAttemptsBeforeLockout") ?? 5; + } +} diff --git a/src/Umbraco.Configuration/Models/ModelsBuilderConfig.cs b/src/Umbraco.Configuration/Models/ModelsBuilderConfig.cs new file mode 100644 index 0000000000..2da86e338e --- /dev/null +++ b/src/Umbraco.Configuration/Models/ModelsBuilderConfig.cs @@ -0,0 +1,112 @@ +using System; +using System.Configuration; +using System.IO; +using System.Threading; +using Microsoft.Extensions.Configuration; +using Umbraco.Core.Configuration; +using Umbraco.Core; +using Umbraco.Core.IO; +using ConfigurationSection = System.Configuration.ConfigurationSection; + +namespace Umbraco.Configuration.Models +{ + /// + /// Represents the models builder configuration. + /// + internal class ModelsBuilderConfig : IModelsBuilderConfig + { + private readonly IConfiguration _configuration; + public string DefaultModelsDirectory => "~/App_Data/Models"; + + /// + /// Initializes a new instance of the class. + /// + public ModelsBuilderConfig(IConfiguration configuration) + { + _configuration = configuration; + } + + private static string GetModelsDirectory(string root, string config, bool acceptUnsafe) + { + // making sure it is safe, ie under the website root, + // unless AcceptUnsafeModelsDirectory and then everything is OK. + + if (!Path.IsPathRooted(root)) + throw new ConfigurationErrorsException($"Root is not rooted \"{root}\"."); + + if (config.StartsWith("~/")) + { + var dir = Path.Combine(root, config.TrimStart("~/")); + + // sanitize - GetFullPath will take care of any relative + // segments in path, eg '../../foo.tmp' - it may throw a SecurityException + // if the combined path reaches illegal parts of the filesystem + dir = Path.GetFullPath(dir); + root = Path.GetFullPath(root); + + if (!dir.StartsWith(root) && !acceptUnsafe) + throw new ConfigurationErrorsException($"Invalid models directory \"{config}\"."); + + return dir; + } + + if (acceptUnsafe) + return Path.GetFullPath(config); + + throw new ConfigurationErrorsException($"Invalid models directory \"{config}\"."); + } + + /// + /// Gets a value indicating whether the whole models experience is enabled. + /// + /// + /// If this is false then absolutely nothing happens. + /// Default value is false which means that unless we have this setting, nothing happens. + /// + public bool Enable => _configuration.GetValue("Umbraco:CMS:ModelsBuilder:Enable", false); + + /// + /// Gets the models mode. + /// + public ModelsMode ModelsMode => _configuration.GetValue("Umbraco:CMS:ModelsBuilder:ModelsMode", ModelsMode.Nothing); + + /// + /// Gets the models namespace. + /// + /// That value could be overriden by other (attribute in user's code...). Return default if no value was supplied. + public string ModelsNamespace => _configuration.GetValue("Umbraco:CMS:ModelsBuilder:ModelsNamespace"); + + /// + /// Gets a value indicating whether we should enable the models factory. + /// + /// Default value is true because no factory is enabled by default in Umbraco. + public bool EnableFactory => _configuration.GetValue("Umbraco:CMS:ModelsBuilder:EnableFactory", true); + + /// + /// Gets a value indicating whether we should flag out-of-date models. + /// + /// Models become out-of-date when data types or content types are updated. When this + /// setting is activated the ~/App_Data/Models/ood.txt file is then created. When models are + /// generated through the dashboard, the files is cleared. Default value is false. + public bool FlagOutOfDateModels => _configuration.GetValue("Umbraco:CMS:ModelsBuilder:FlagOutOfDateModels", false) && !ModelsMode.IsLive(); + + /// + /// Gets the models directory. + /// + /// Default is ~/App_Data/Models but that can be changed. + public string ModelsDirectory => GetModelsDirectory("~/",_configuration.GetValue("Umbraco:CMS:ModelsBuilder:ModelsDirectory", "~/App_Data/Models"), AcceptUnsafeModelsDirectory); + + /// + /// Gets a value indicating whether to accept an unsafe value for ModelsDirectory. + /// + /// An unsafe value is an absolute path, or a relative path pointing outside + /// of the website root. + public bool AcceptUnsafeModelsDirectory => _configuration.GetValue("Umbraco:CMS:ModelsBuilder:AcceptUnsafeModelsDirectory", false); + + /// + /// Gets a value indicating the debug log level. + /// + /// 0 means minimal (safe on live site), anything else means more and more details (maybe not safe). + public int DebugLevel => _configuration.GetValue("Umbraco:CMS:ModelsBuilder:DebugLevel", 0); + } +} diff --git a/src/Umbraco.Configuration/Models/NuCacheSettings.cs b/src/Umbraco.Configuration/Models/NuCacheSettings.cs new file mode 100644 index 0000000000..f7a3c59c68 --- /dev/null +++ b/src/Umbraco.Configuration/Models/NuCacheSettings.cs @@ -0,0 +1,17 @@ +using Microsoft.Extensions.Configuration; +using Umbraco.Core.Configuration; + +namespace Umbraco.Configuration.Models +{ + internal class NuCacheSettings : INuCacheSettings + { + private readonly IConfiguration _configuration; + + public NuCacheSettings(IConfiguration configuration) + { + _configuration = configuration; + } + + public string BTreeBlockSize => _configuration.GetValue("Umbraco:CMS:NuCache:BTreeBlockSize"); + } +} diff --git a/src/Umbraco.Configuration/Models/RequestHandlerSettings.cs b/src/Umbraco.Configuration/Models/RequestHandlerSettings.cs new file mode 100644 index 0000000000..7c7a2c0a4f --- /dev/null +++ b/src/Umbraco.Configuration/Models/RequestHandlerSettings.cs @@ -0,0 +1,41 @@ +using System.Collections.Generic; +using System.Linq; +using Microsoft.Extensions.Configuration; +using Umbraco.Core; +using Umbraco.Core.Configuration.UmbracoSettings; + +namespace Umbraco.Configuration.Models +{ + internal class RequestHandlerSettings : IRequestHandlerSettings + { + private readonly IConfiguration _configuration; + public RequestHandlerSettings(IConfiguration configuration) + { + _configuration = configuration; + } + + public bool AddTrailingSlash => _configuration.GetValue("Umbraco:CMS:RequestHandler:AddTrailingSlash") ?? true; + public bool ConvertUrlsToAscii => _configuration.GetValue("Umbraco:CMS:RequestHandler:ConvertUrlsToAscii").InvariantEquals("true"); + public bool TryConvertUrlsToAscii => _configuration.GetValue("Umbraco:CMS:RequestHandler:ConvertUrlsToAscii").InvariantEquals("try"); + + + //We need to special handle ":", as this character is special in keys + public IEnumerable CharCollection => _configuration.GetSection("Umbraco:CMS:RequestHandler:CharCollection") + .GetChildren() + .Select(kvp => new CharItem() + { + Char = kvp.Key, + Replacement = kvp.Value + }).Union(new [] + { + new CharItem(){Char = ":", Replacement = string.Empty}, + }); + + private class CharItem : IChar + { + + public string Char { get; set; } + public string Replacement { get; set; } + } + } +} diff --git a/src/Umbraco.Configuration/Models/RuntimeSettings.cs b/src/Umbraco.Configuration/Models/RuntimeSettings.cs new file mode 100644 index 0000000000..5103fcf75c --- /dev/null +++ b/src/Umbraco.Configuration/Models/RuntimeSettings.cs @@ -0,0 +1,17 @@ +using Microsoft.Extensions.Configuration; +using Umbraco.Core.Configuration; + +namespace Umbraco.Configuration.Models +{ + internal class RuntimeSettings : IRuntimeSettings + { + private readonly IConfiguration _configuration; + public RuntimeSettings(IConfiguration configuration) + { + _configuration = configuration; + } + + public int? MaxQueryStringLength => _configuration.GetValue("Umbraco:CMS:Runtime:MaxRequestLength"); + public int? MaxRequestLength => _configuration.GetValue("Umbraco:CMS:Runtime:MaxRequestLength"); + } +} diff --git a/src/Umbraco.Configuration/Models/SecuritySettings.cs b/src/Umbraco.Configuration/Models/SecuritySettings.cs new file mode 100644 index 0000000000..91721fb26a --- /dev/null +++ b/src/Umbraco.Configuration/Models/SecuritySettings.cs @@ -0,0 +1,20 @@ +using Microsoft.Extensions.Configuration; +using Umbraco.Core.Configuration.UmbracoSettings; + +namespace Umbraco.Configuration.Models +{ + internal class SecuritySettings : ISecuritySettings + { + private readonly IConfiguration _configuration; + public SecuritySettings(IConfiguration configuration) + { + _configuration = configuration; + } + public bool KeepUserLoggedIn => _configuration.GetValue("Umbraco:CMS:Security:KeepUserLoggedIn") ?? true; + public bool HideDisabledUsersInBackoffice => _configuration.GetValue("Umbraco:CMS:Security:HideDisabledUsersInBackoffice") ?? false; + public bool AllowPasswordReset => _configuration.GetValue("Umbraco:CMS:Security:AllowPasswordResetAllowPasswordReset") ?? true; + public string AuthCookieName => _configuration.GetValue("Umbraco:CMS:Security:AuthCookieName") ?? "UMB_UCONTEXT"; + public string AuthCookieDomain => _configuration.GetValue("Umbraco:CMS:Security:AuthCookieDomain") ?? null; + public bool UsernameIsEmail => _configuration.GetValue("Umbraco:CMS:Security:UsernameIsEmail") ?? true; + } +} diff --git a/src/Umbraco.Configuration/Models/TourSettings.cs b/src/Umbraco.Configuration/Models/TourSettings.cs new file mode 100644 index 0000000000..20358bd320 --- /dev/null +++ b/src/Umbraco.Configuration/Models/TourSettings.cs @@ -0,0 +1,18 @@ +using Microsoft.Extensions.Configuration; +using Umbraco.Core.Configuration.UmbracoSettings; + +namespace Umbraco.Configuration.Models +{ + internal class TourSettings : ITourSettings + { + private readonly IConfiguration _configuration; + public TourSettings(IConfiguration configuration) + { + _configuration = configuration; + } + + public bool EnableTours => _configuration.GetValue("Umbraco:CMS:Tours:EnableTours") ?? true; + + public string Type { get; set; } + } +} diff --git a/src/Umbraco.Configuration/Models/TypeFinderSettings.cs b/src/Umbraco.Configuration/Models/TypeFinderSettings.cs new file mode 100644 index 0000000000..114f028b13 --- /dev/null +++ b/src/Umbraco.Configuration/Models/TypeFinderSettings.cs @@ -0,0 +1,19 @@ +using Microsoft.Extensions.Configuration; +using Umbraco.Core.Configuration; + +namespace Umbraco.Configuration.Models +{ + internal class TypeFinderSettings : ITypeFinderSettings + { + private readonly IConfiguration _configuration; + + public TypeFinderSettings(IConfiguration configuration) + { + _configuration = configuration; + } + + public string AssembliesAcceptingLoadExceptions => + _configuration.GetValue("Umbraco:CMS:TypeFinder:AssembliesAcceptingLoadExceptions"); + } + +} diff --git a/src/Umbraco.Configuration/Models/UserPasswordConfigurationSettings.cs b/src/Umbraco.Configuration/Models/UserPasswordConfigurationSettings.cs new file mode 100644 index 0000000000..2b5e01fcd9 --- /dev/null +++ b/src/Umbraco.Configuration/Models/UserPasswordConfigurationSettings.cs @@ -0,0 +1,23 @@ +using Microsoft.Extensions.Configuration; +using Umbraco.Core.Configuration; + +namespace Umbraco.Configuration.Models +{ + internal class UserPasswordConfigurationSettings : IUserPasswordConfiguration + { + private readonly IConfiguration _configuration; + public UserPasswordConfigurationSettings(IConfiguration configuration) + { + _configuration = configuration; + } + + public int RequiredLength => _configuration.GetValue("Umbraco:CMS:Security:UserPassword:RequiredLength") ?? 10; + public bool RequireNonLetterOrDigit => _configuration.GetValue("Umbraco:CMS:Security:UserPassword:RequireNonLetterOrDigit") ?? false; + public bool RequireDigit => _configuration.GetValue("Umbraco:CMS:Security:UserPassword:RequireDigit") ?? false; + public bool RequireLowercase => _configuration.GetValue("Umbraco:CMS:Security:UserPassword:RequireLowercase") ?? false; + public bool RequireUppercase => _configuration.GetValue("Umbraco:CMS:Security:UserPassword:RequireUppercase") ?? false; + public bool UseLegacyEncoding => _configuration.GetValue("Umbraco:CMS:Security:UserPassword:UseLegacyEncoding") ?? false; + public string HashAlgorithmType => _configuration.GetValue("Umbraco:CMS:Security:UserPassword:HashAlgorithmType") ?? "HMACSHA256"; + public int MaxFailedAccessAttemptsBeforeLockout => _configuration.GetValue("Umbraco:CMS:Security:UserPassword:MaxFailedAccessAttemptsBeforeLockout") ?? 5; + } +} diff --git a/src/Umbraco.Configuration/Models/WebRoutingSettings.cs b/src/Umbraco.Configuration/Models/WebRoutingSettings.cs new file mode 100644 index 0000000000..cb78373b74 --- /dev/null +++ b/src/Umbraco.Configuration/Models/WebRoutingSettings.cs @@ -0,0 +1,24 @@ +using Microsoft.Extensions.Configuration; +using Umbraco.Core.Configuration.UmbracoSettings; +using Umbraco.Core.Models.PublishedContent; + +namespace Umbraco.Configuration.Models +{ + internal class WebRoutingSettings : IWebRoutingSettings + { + private readonly IConfiguration _configuration; + public WebRoutingSettings(IConfiguration configuration) + { + _configuration = configuration; + } + + public bool TrySkipIisCustomErrors => _configuration.GetValue("Umbraco:CMS:WebRouting:TrySkipIisCustomErrors") ?? false; + public bool InternalRedirectPreservesTemplate => _configuration.GetValue("Umbraco:CMS:WebRouting:InternalRedirectPreservesTemplate") ?? false; + public bool DisableAlternativeTemplates => _configuration.GetValue("Umbraco:CMS:WebRouting:DisableAlternativeTemplates") ?? false; + public bool ValidateAlternativeTemplates => _configuration.GetValue("Umbraco:CMS:WebRouting:ValidateAlternativeTemplates") ?? false; + public bool DisableFindContentByIdPath => _configuration.GetValue("Umbraco:CMS:WebRouting:DisableFindContentByIdPath") ?? false; + public bool DisableRedirectUrlTracking => _configuration.GetValue("Umbraco:CMS:WebRouting:DisableRedirectUrlTracking") ?? false; + public string UrlProviderMode => _configuration.GetValue("Umbraco:CMS:WebRouting:UrlProviderMode") ?? UrlMode.Auto.ToString(); + public string UmbracoApplicationUrl => _configuration.GetValue("Umbraco:CMS:WebRouting:UmbracoApplicationUrl") ?? null; + } +} diff --git a/src/Umbraco.Configuration/Umbraco.Configuration.csproj b/src/Umbraco.Configuration/Umbraco.Configuration.csproj index 57fca1dfd6..8102e9fde6 100644 --- a/src/Umbraco.Configuration/Umbraco.Configuration.csproj +++ b/src/Umbraco.Configuration/Umbraco.Configuration.csproj @@ -22,6 +22,8 @@ + + @@ -29,4 +31,8 @@ + + + + diff --git a/src/Umbraco.Core/Configuration/ConfigsExtensions.cs b/src/Umbraco.Core/Configuration/ConfigsExtensions.cs index 5019282d97..2157978dc6 100644 --- a/src/Umbraco.Core/Configuration/ConfigsExtensions.cs +++ b/src/Umbraco.Core/Configuration/ConfigsExtensions.cs @@ -37,10 +37,10 @@ namespace Umbraco.Core public static IWebRoutingSettings WebRouting(this Configs configs) => configs.GetConfig(); - public static IHealthChecks HealthChecks(this Configs configs) - => configs.GetConfig(); - public static ICoreDebug CoreDebug(this Configs configs) - => configs.GetConfig(); + public static IHealthChecksSettings HealthChecks(this Configs configs) + => configs.GetConfig(); + public static ICoreDebugSettings CoreDebug(this Configs configs) + => configs.GetConfig(); } } diff --git a/src/Umbraco.Core/Configuration/HealthChecks/IHealthChecks.cs b/src/Umbraco.Core/Configuration/HealthChecks/IHealthChecksSettings.cs similarity index 84% rename from src/Umbraco.Core/Configuration/HealthChecks/IHealthChecks.cs rename to src/Umbraco.Core/Configuration/HealthChecks/IHealthChecksSettings.cs index fa98e3b054..785e8d5651 100644 --- a/src/Umbraco.Core/Configuration/HealthChecks/IHealthChecks.cs +++ b/src/Umbraco.Core/Configuration/HealthChecks/IHealthChecksSettings.cs @@ -2,7 +2,7 @@ namespace Umbraco.Core.Configuration.HealthChecks { - public interface IHealthChecks + public interface IHealthChecksSettings { IEnumerable DisabledChecks { get; } IHealthCheckNotificationSettings NotificationSettings { get; } diff --git a/src/Umbraco.Core/Configuration/ICoreDebug.cs b/src/Umbraco.Core/Configuration/ICoreDebugSettings.cs similarity index 93% rename from src/Umbraco.Core/Configuration/ICoreDebug.cs rename to src/Umbraco.Core/Configuration/ICoreDebugSettings.cs index 4ff2a1a300..586e4bc3e4 100644 --- a/src/Umbraco.Core/Configuration/ICoreDebug.cs +++ b/src/Umbraco.Core/Configuration/ICoreDebugSettings.cs @@ -1,6 +1,6 @@ namespace Umbraco.Core.Configuration { - public interface ICoreDebug + public interface ICoreDebugSettings { /// /// When set to true, Scope logs the stack trace for any scope that gets disposed without being completed. diff --git a/src/Umbraco.Core/Configuration/IModelsBuilderConfig.cs b/src/Umbraco.Core/Configuration/IModelsBuilderConfig.cs index 6a071ac277..990bde9843 100644 --- a/src/Umbraco.Core/Configuration/IModelsBuilderConfig.cs +++ b/src/Umbraco.Core/Configuration/IModelsBuilderConfig.cs @@ -7,7 +7,6 @@ int DebugLevel { get; } bool EnableFactory { get; } bool FlagOutOfDateModels { get; } - bool IsDebug { get; } string ModelsDirectory { get; } ModelsMode ModelsMode { get; } string ModelsNamespace { get; } diff --git a/src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/EmailNotificationMethod.cs b/src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/EmailNotificationMethod.cs index f76a69c0fa..9d36b60d83 100644 --- a/src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/EmailNotificationMethod.cs +++ b/src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/EmailNotificationMethod.cs @@ -20,7 +20,7 @@ namespace Umbraco.Web.HealthCheck.NotificationMethods private readonly IGlobalSettings _globalSettings; private readonly IContentSettings _contentSettings; - public EmailNotificationMethod(ILocalizedTextService textService, IRuntimeState runtimeState, ILogger logger, IGlobalSettings globalSettings, IHealthChecks healthChecks, IContentSettings contentSettings) : base(healthChecks) + public EmailNotificationMethod(ILocalizedTextService textService, IRuntimeState runtimeState, ILogger logger, IGlobalSettings globalSettings, IHealthChecksSettings healthChecksSettings, IContentSettings contentSettings) : base(healthChecksSettings) { var recipientEmail = Settings["recipientEmail"]?.Value; if (string.IsNullOrWhiteSpace(recipientEmail)) diff --git a/src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/NotificationMethodBase.cs b/src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/NotificationMethodBase.cs index ff6fbe2371..9c3516e712 100644 --- a/src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/NotificationMethodBase.cs +++ b/src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/NotificationMethodBase.cs @@ -8,7 +8,7 @@ namespace Umbraco.Web.HealthCheck.NotificationMethods { public abstract class NotificationMethodBase : IHealthCheckNotificationMethod { - protected NotificationMethodBase(IHealthChecks healthCheckConfig) + protected NotificationMethodBase(IHealthChecksSettings healthCheckSettingsConfig) { var type = GetType(); var attribute = type.GetCustomAttribute(); @@ -18,7 +18,7 @@ namespace Umbraco.Web.HealthCheck.NotificationMethods return; } - var notificationMethods = healthCheckConfig.NotificationSettings.NotificationMethods; + var notificationMethods = healthCheckSettingsConfig.NotificationSettings.NotificationMethods; var notificationMethod = notificationMethods[attribute.Alias]; if (notificationMethod == null) { diff --git a/src/Umbraco.Infrastructure/Logging/Serilog/SerilogLogger.cs b/src/Umbraco.Infrastructure/Logging/Serilog/SerilogLogger.cs index 9dde28e95a..bb77869e28 100644 --- a/src/Umbraco.Infrastructure/Logging/Serilog/SerilogLogger.cs +++ b/src/Umbraco.Infrastructure/Logging/Serilog/SerilogLogger.cs @@ -18,7 +18,7 @@ namespace Umbraco.Core.Logging.Serilog /// public class SerilogLogger : ILogger, IDisposable { - private readonly ICoreDebug _coreDebug; + private readonly ICoreDebugSettings _coreDebugSettings; private readonly IIOHelper _ioHelper; private readonly IMarchal _marchal; @@ -26,9 +26,9 @@ namespace Umbraco.Core.Logging.Serilog /// Initialize a new instance of the class with a configuration file. ///
/// - public SerilogLogger(ICoreDebug coreDebug, IIOHelper ioHelper, IMarchal marchal, FileInfo logConfigFile) + public SerilogLogger(ICoreDebugSettings coreDebugSettings, IIOHelper ioHelper, IMarchal marchal, FileInfo logConfigFile) { - _coreDebug = coreDebug; + _coreDebugSettings = coreDebugSettings; _ioHelper = ioHelper; _marchal = marchal; @@ -37,9 +37,9 @@ namespace Umbraco.Core.Logging.Serilog .CreateLogger(); } - public SerilogLogger(ICoreDebug coreDebug, IIOHelper ioHelper, IMarchal marchal, LoggerConfiguration logConfig) + public SerilogLogger(ICoreDebugSettings coreDebugSettings, IIOHelper ioHelper, IMarchal marchal, LoggerConfiguration logConfig) { - _coreDebug = coreDebug; + _coreDebugSettings = coreDebugSettings; _ioHelper = ioHelper; _marchal = marchal; @@ -51,7 +51,7 @@ namespace Umbraco.Core.Logging.Serilog /// Creates a logger with some pre-defined configuration and remainder from config file /// /// Used by UmbracoApplicationBase to get its logger. - public static SerilogLogger CreateWithDefaultConfiguration(IHostingEnvironment hostingEnvironment, ISessionIdResolver sessionIdResolver, Func requestCacheGetter, ICoreDebug coreDebug, IIOHelper ioHelper, IMarchal marchal) + public static SerilogLogger CreateWithDefaultConfiguration(IHostingEnvironment hostingEnvironment, ISessionIdResolver sessionIdResolver, Func requestCacheGetter, ICoreDebugSettings coreDebugSettings, IIOHelper ioHelper, IMarchal marchal) { var loggerConfig = new LoggerConfiguration(); loggerConfig @@ -59,7 +59,7 @@ namespace Umbraco.Core.Logging.Serilog .ReadFromConfigFile() .ReadFromUserConfigFile(); - return new SerilogLogger(coreDebug, ioHelper, marchal, loggerConfig); + return new SerilogLogger(coreDebugSettings, ioHelper, marchal, loggerConfig); } /// @@ -179,7 +179,7 @@ namespace Umbraco.Core.Logging.Serilog messageTemplate += "\r\nThe thread has been aborted, because the request has timed out."; // dump if configured, or if stacktrace contains Monitor.ReliableEnter - dump = _coreDebug.DumpOnTimeoutThreadAbort || IsMonitorEnterThreadAbortException(exception); + dump = _coreDebugSettings.DumpOnTimeoutThreadAbort || IsMonitorEnterThreadAbortException(exception); // dump if it is ok to dump (might have a cap on number of dump...) dump &= MiniDump.OkToDump(_ioHelper); diff --git a/src/Umbraco.Infrastructure/Scheduling/HealthCheckNotifier.cs b/src/Umbraco.Infrastructure/Scheduling/HealthCheckNotifier.cs index 00bbba8bb8..04c1571b3b 100644 --- a/src/Umbraco.Infrastructure/Scheduling/HealthCheckNotifier.cs +++ b/src/Umbraco.Infrastructure/Scheduling/HealthCheckNotifier.cs @@ -15,18 +15,18 @@ namespace Umbraco.Web.Scheduling private readonly HealthCheckCollection _healthChecks; private readonly HealthCheckNotificationMethodCollection _notifications; private readonly IProfilingLogger _logger; - private readonly IHealthChecks _healthChecksConfig; + private readonly IHealthChecksSettings _healthChecksSettingsConfig; public HealthCheckNotifier(IBackgroundTaskRunner runner, int delayMilliseconds, int periodMilliseconds, HealthCheckCollection healthChecks, HealthCheckNotificationMethodCollection notifications, - IRuntimeState runtimeState, IProfilingLogger logger, IHealthChecks healthChecksConfig) + IRuntimeState runtimeState, IProfilingLogger logger, IHealthChecksSettings healthChecksSettingsConfig) : base(runner, delayMilliseconds, periodMilliseconds) { _healthChecks = healthChecks; _notifications = notifications; _runtimeState = runtimeState; _logger = logger; - _healthChecksConfig = healthChecksConfig; + _healthChecksSettingsConfig = healthChecksSettingsConfig; } public override async Task PerformRunAsync(CancellationToken token) @@ -53,7 +53,7 @@ namespace Umbraco.Web.Scheduling using (_logger.DebugDuration("Health checks executing", "Health checks complete")) { - var healthCheckConfig = _healthChecksConfig; + var healthCheckConfig = _healthChecksSettingsConfig; // Don't notify for any checks that are disabled, nor for any disabled // just for notifications diff --git a/src/Umbraco.Infrastructure/Scheduling/SchedulerComponent.cs b/src/Umbraco.Infrastructure/Scheduling/SchedulerComponent.cs index 1d4a654830..c8ff67579a 100644 --- a/src/Umbraco.Infrastructure/Scheduling/SchedulerComponent.cs +++ b/src/Umbraco.Infrastructure/Scheduling/SchedulerComponent.cs @@ -34,7 +34,7 @@ namespace Umbraco.Web.Scheduling private readonly HealthCheckCollection _healthChecks; private readonly HealthCheckNotificationMethodCollection _notifications; private readonly IUmbracoContextFactory _umbracoContextFactory; - private readonly IHealthChecks _healthChecksConfig; + private readonly IHealthChecksSettings _healthChecksSettingsConfig; private readonly IIOHelper _ioHelper; private readonly IServerMessenger _serverMessenger; private readonly IRequestAccessor _requestAccessor; @@ -56,7 +56,7 @@ namespace Umbraco.Web.Scheduling IContentService contentService, IAuditService auditService, HealthCheckCollection healthChecks, HealthCheckNotificationMethodCollection notifications, IScopeProvider scopeProvider, IUmbracoContextFactory umbracoContextFactory, IProfilingLogger logger, - IHostingEnvironment hostingEnvironment, IHealthChecks healthChecksConfig, + IHostingEnvironment hostingEnvironment, IHealthChecksSettings healthChecksSettingsConfig, IIOHelper ioHelper, IServerMessenger serverMessenger, IRequestAccessor requestAccessor, ILoggingSettings loggingSettings, IKeepAliveSettings keepAliveSettings) { @@ -70,7 +70,7 @@ namespace Umbraco.Web.Scheduling _healthChecks = healthChecks; _notifications = notifications; - _healthChecksConfig = healthChecksConfig ?? throw new ArgumentNullException(nameof(healthChecksConfig)); + _healthChecksSettingsConfig = healthChecksSettingsConfig ?? throw new ArgumentNullException(nameof(healthChecksSettingsConfig)); _ioHelper = ioHelper; _serverMessenger = serverMessenger; _requestAccessor = requestAccessor; @@ -126,7 +126,7 @@ namespace Umbraco.Web.Scheduling tasks.Add(RegisterLogScrubber(_loggingSettings)); tasks.Add(RegisterTempFileCleanup()); - var healthCheckConfig = _healthChecksConfig; + var healthCheckConfig = _healthChecksSettingsConfig; if (healthCheckConfig.NotificationSettings.Enabled) tasks.Add(RegisterHealthCheckNotifier(healthCheckConfig, _healthChecks, _notifications, _logger)); @@ -152,28 +152,28 @@ namespace Umbraco.Web.Scheduling return task; } - private IBackgroundTask RegisterHealthCheckNotifier(IHealthChecks healthCheckConfig, + private IBackgroundTask RegisterHealthCheckNotifier(IHealthChecksSettings healthCheckSettingsConfig, HealthCheckCollection healthChecks, HealthCheckNotificationMethodCollection notifications, IProfilingLogger logger) { // If first run time not set, start with just small delay after application start int delayInMilliseconds; - if (string.IsNullOrEmpty(healthCheckConfig.NotificationSettings.FirstRunTime)) + if (string.IsNullOrEmpty(healthCheckSettingsConfig.NotificationSettings.FirstRunTime)) { delayInMilliseconds = DefaultDelayMilliseconds; } else { // Otherwise start at scheduled time - delayInMilliseconds = DateTime.Now.PeriodicMinutesFrom(healthCheckConfig.NotificationSettings.FirstRunTime) * 60 * 1000; + delayInMilliseconds = DateTime.Now.PeriodicMinutesFrom(healthCheckSettingsConfig.NotificationSettings.FirstRunTime) * 60 * 1000; if (delayInMilliseconds < DefaultDelayMilliseconds) { delayInMilliseconds = DefaultDelayMilliseconds; } } - var periodInMilliseconds = healthCheckConfig.NotificationSettings.PeriodInHours * 60 * 60 * 1000; - var task = new HealthCheckNotifier(_healthCheckRunner, delayInMilliseconds, periodInMilliseconds, healthChecks, notifications, _runtime, logger, _healthChecksConfig); + var periodInMilliseconds = healthCheckSettingsConfig.NotificationSettings.PeriodInHours * 60 * 60 * 1000; + var task = new HealthCheckNotifier(_healthCheckRunner, delayInMilliseconds, periodInMilliseconds, healthChecks, notifications, _runtime, logger, _healthChecksSettingsConfig); _healthCheckRunner.TryAdd(task); return task; } diff --git a/src/Umbraco.Infrastructure/Scoping/Scope.cs b/src/Umbraco.Infrastructure/Scoping/Scope.cs index 8f7a0bf958..106c84ec3d 100644 --- a/src/Umbraco.Infrastructure/Scoping/Scope.cs +++ b/src/Umbraco.Infrastructure/Scoping/Scope.cs @@ -17,7 +17,7 @@ namespace Umbraco.Core.Scoping internal class Scope : IScope { private readonly ScopeProvider _scopeProvider; - private readonly ICoreDebug _coreDebug; + private readonly ICoreDebugSettings _coreDebugSettings; private readonly IMediaFileSystem _mediaFileSystem; private readonly ILogger _logger; private readonly ITypeFinder _typeFinder; @@ -39,7 +39,7 @@ namespace Umbraco.Core.Scoping // initializes a new scope private Scope(ScopeProvider scopeProvider, - ICoreDebug coreDebug, + ICoreDebugSettings coreDebugSettings, IMediaFileSystem mediaFileSystem, ILogger logger, ITypeFinder typeFinder, FileSystems fileSystems, Scope parent, IScopeContext scopeContext, bool detachable, IsolationLevel isolationLevel = IsolationLevel.Unspecified, @@ -50,7 +50,7 @@ namespace Umbraco.Core.Scoping bool autoComplete = false) { _scopeProvider = scopeProvider; - _coreDebug = coreDebug; + _coreDebugSettings = coreDebugSettings; _mediaFileSystem = mediaFileSystem; _logger = logger; _typeFinder = typeFinder; @@ -118,7 +118,7 @@ namespace Umbraco.Core.Scoping // initializes a new scope public Scope(ScopeProvider scopeProvider, - ICoreDebug coreDebug, + ICoreDebugSettings coreDebugSettings, IMediaFileSystem mediaFileSystem, ILogger logger, ITypeFinder typeFinder, FileSystems fileSystems, bool detachable, IScopeContext scopeContext, IsolationLevel isolationLevel = IsolationLevel.Unspecified, @@ -127,12 +127,12 @@ namespace Umbraco.Core.Scoping bool? scopeFileSystems = null, bool callContext = false, bool autoComplete = false) - : this(scopeProvider, coreDebug, mediaFileSystem, logger, typeFinder, fileSystems, null, scopeContext, detachable, isolationLevel, repositoryCacheMode, eventDispatcher, scopeFileSystems, callContext, autoComplete) + : this(scopeProvider, coreDebugSettings, mediaFileSystem, logger, typeFinder, fileSystems, null, scopeContext, detachable, isolationLevel, repositoryCacheMode, eventDispatcher, scopeFileSystems, callContext, autoComplete) { } // initializes a new scope in a nested scopes chain, with its parent public Scope(ScopeProvider scopeProvider, - ICoreDebug coreDebug, + ICoreDebugSettings coreDebugSettings, IMediaFileSystem mediaFileSystem, ILogger logger, ITypeFinder typeFinder, FileSystems fileSystems, Scope parent, IsolationLevel isolationLevel = IsolationLevel.Unspecified, @@ -141,7 +141,7 @@ namespace Umbraco.Core.Scoping bool? scopeFileSystems = null, bool callContext = false, bool autoComplete = false) - : this(scopeProvider, coreDebug, mediaFileSystem, logger, typeFinder, fileSystems, parent, null, false, isolationLevel, repositoryCacheMode, eventDispatcher, scopeFileSystems, callContext, autoComplete) + : this(scopeProvider, coreDebugSettings, mediaFileSystem, logger, typeFinder, fileSystems, parent, null, false, isolationLevel, repositoryCacheMode, eventDispatcher, scopeFileSystems, callContext, autoComplete) { } public Guid InstanceId { get; } = Guid.NewGuid(); @@ -494,9 +494,9 @@ namespace Umbraco.Core.Scoping private static bool? _logUncompletedScopes; // caching config - // true if Umbraco.CoreDebug.LogUncompletedScope appSetting is set to "true" + // true if Umbraco.CoreDebugSettings.LogUncompletedScope appSetting is set to "true" private bool LogUncompletedScopes => (_logUncompletedScopes - ?? (_logUncompletedScopes = _coreDebug.LogUncompletedScopes)).Value; + ?? (_logUncompletedScopes = _coreDebugSettings.LogUncompletedScopes)).Value; /// public void ReadLock(params int[] lockIds) => Database.SqlContext.SqlSyntax.ReadLock(Database, lockIds); diff --git a/src/Umbraco.Infrastructure/Scoping/ScopeProvider.cs b/src/Umbraco.Infrastructure/Scoping/ScopeProvider.cs index 0dba73b55b..610f308b96 100644 --- a/src/Umbraco.Infrastructure/Scoping/ScopeProvider.cs +++ b/src/Umbraco.Infrastructure/Scoping/ScopeProvider.cs @@ -26,14 +26,14 @@ namespace Umbraco.Core.Scoping private readonly ITypeFinder _typeFinder; private readonly IRequestCache _requestCache; private readonly FileSystems _fileSystems; - private readonly ICoreDebug _coreDebug; + private readonly ICoreDebugSettings _coreDebugSettings; private readonly IMediaFileSystem _mediaFileSystem; - public ScopeProvider(IUmbracoDatabaseFactory databaseFactory, FileSystems fileSystems, ICoreDebug coreDebug, IMediaFileSystem mediaFileSystem, ILogger logger, ITypeFinder typeFinder, IRequestCache requestCache) + public ScopeProvider(IUmbracoDatabaseFactory databaseFactory, FileSystems fileSystems, ICoreDebugSettings coreDebugSettings, IMediaFileSystem mediaFileSystem, ILogger logger, ITypeFinder typeFinder, IRequestCache requestCache) { DatabaseFactory = databaseFactory; _fileSystems = fileSystems; - _coreDebug = coreDebug; + _coreDebugSettings = coreDebugSettings; _mediaFileSystem = mediaFileSystem; _logger = logger; _typeFinder = typeFinder; @@ -255,7 +255,7 @@ namespace Umbraco.Core.Scoping IEventDispatcher eventDispatcher = null, bool? scopeFileSystems = null) { - return new Scope(this, _coreDebug, _mediaFileSystem, _logger, _typeFinder, _fileSystems, true, null, isolationLevel, repositoryCacheMode, eventDispatcher, scopeFileSystems); + return new Scope(this, _coreDebugSettings, _mediaFileSystem, _logger, _typeFinder, _fileSystems, true, null, isolationLevel, repositoryCacheMode, eventDispatcher, scopeFileSystems); } /// @@ -311,13 +311,13 @@ namespace Umbraco.Core.Scoping { var ambientContext = AmbientContext; var newContext = ambientContext == null ? new ScopeContext() : null; - var scope = new Scope(this, _coreDebug, _mediaFileSystem, _logger, _typeFinder, _fileSystems, false, newContext, isolationLevel, repositoryCacheMode, eventDispatcher, scopeFileSystems, callContext, autoComplete); + var scope = new Scope(this, _coreDebugSettings, _mediaFileSystem, _logger, _typeFinder, _fileSystems, false, newContext, isolationLevel, repositoryCacheMode, eventDispatcher, scopeFileSystems, callContext, autoComplete); // assign only if scope creation did not throw! SetAmbient(scope, newContext ?? ambientContext); return scope; } - var nested = new Scope(this, _coreDebug, _mediaFileSystem, _logger, _typeFinder, _fileSystems, ambientScope, isolationLevel, repositoryCacheMode, eventDispatcher, scopeFileSystems, callContext, autoComplete); + var nested = new Scope(this, _coreDebugSettings, _mediaFileSystem, _logger, _typeFinder, _fileSystems, ambientScope, isolationLevel, repositoryCacheMode, eventDispatcher, scopeFileSystems, callContext, autoComplete); SetAmbient(nested, AmbientContext); return nested; } diff --git a/src/Umbraco.Tests.Common/TestHelperBase.cs b/src/Umbraco.Tests.Common/TestHelperBase.cs index a5810715fb..d21aff89d9 100644 --- a/src/Umbraco.Tests.Common/TestHelperBase.cs +++ b/src/Umbraco.Tests.Common/TestHelperBase.cs @@ -93,7 +93,7 @@ namespace Umbraco.Tests.Common public abstract IDbProviderFactoryCreator DbProviderFactoryCreator { get; } public abstract IBulkSqlInsertProvider BulkSqlInsertProvider { get; } public abstract IMarchal Marchal { get; } - public ICoreDebug CoreDebug { get; } = new CoreDebug(); + public ICoreDebugSettings CoreDebugSettings { get; } = new CoreDebugSettings(); public IIOHelper IOHelper { get; } diff --git a/src/Umbraco.Tests/Components/ComponentTests.cs b/src/Umbraco.Tests/Components/ComponentTests.cs index a41d86ee2e..cb8da6e23d 100644 --- a/src/Umbraco.Tests/Components/ComponentTests.cs +++ b/src/Umbraco.Tests/Components/ComponentTests.cs @@ -35,7 +35,7 @@ namespace Umbraco.Tests.Components var typeFinder = TestHelper.GetTypeFinder(); var f = new UmbracoDatabaseFactory(logger, SettingsForTests.GetDefaultGlobalSettings(), Mock.Of(), new Lazy(() => new MapperCollection(Enumerable.Empty())), TestHelper.DbProviderFactoryCreator); var fs = new FileSystems(mock.Object, logger, TestHelper.IOHelper, SettingsForTests.GenerateMockGlobalSettings()); - var coreDebug = Mock.Of(); + var coreDebug = Mock.Of(); var mediaFileSystem = Mock.Of(); var p = new ScopeProvider(f, fs, coreDebug, mediaFileSystem, logger, typeFinder, NoAppCache.Instance); diff --git a/src/Umbraco.Tests/ModelsBuilder/ConfigTests.cs b/src/Umbraco.Tests/ModelsBuilder/ConfigTests.cs index 260fe37953..97b4d881a4 100644 --- a/src/Umbraco.Tests/ModelsBuilder/ConfigTests.cs +++ b/src/Umbraco.Tests/ModelsBuilder/ConfigTests.cs @@ -1,6 +1,7 @@ using System.Configuration; using NUnit.Framework; using Umbraco.Configuration; +using Umbraco.Configuration.Legacy; using Umbraco.Core; using Umbraco.Tests.TestHelpers; diff --git a/src/Umbraco.Tests/TestHelpers/TestHelper.cs b/src/Umbraco.Tests/TestHelpers/TestHelper.cs index 693fd73231..95e211db24 100644 --- a/src/Umbraco.Tests/TestHelpers/TestHelper.cs +++ b/src/Umbraco.Tests/TestHelpers/TestHelper.cs @@ -85,7 +85,7 @@ namespace Umbraco.Tests.TestHelpers public static IDbProviderFactoryCreator DbProviderFactoryCreator => _testHelperInternal.DbProviderFactoryCreator; public static IBulkSqlInsertProvider BulkSqlInsertProvider => _testHelperInternal.BulkSqlInsertProvider; public static IMarchal Marchal => _testHelperInternal.Marchal; - public static ICoreDebug CoreDebug => _testHelperInternal.CoreDebug; + public static ICoreDebugSettings CoreDebugSettings => _testHelperInternal.CoreDebugSettings; public static IIOHelper IOHelper => _testHelperInternal.IOHelper; diff --git a/src/Umbraco.Tests/TestHelpers/TestObjects.cs b/src/Umbraco.Tests/TestHelpers/TestObjects.cs index be8f7db7e8..33e477df2c 100644 --- a/src/Umbraco.Tests/TestHelpers/TestObjects.cs +++ b/src/Umbraco.Tests/TestHelpers/TestObjects.cs @@ -255,7 +255,7 @@ namespace Umbraco.Tests.TestHelpers typeFinder = typeFinder ?? new TypeFinder(logger, new DefaultUmbracoAssemblyProvider(GetType().Assembly)); fileSystems = fileSystems ?? new FileSystems(Current.Factory, logger, TestHelper.IOHelper, SettingsForTests.GenerateMockGlobalSettings()); - var coreDebug = TestHelper.CoreDebug; + var coreDebug = TestHelper.CoreDebugSettings; var mediaFileSystem = Mock.Of(); var scopeProvider = new ScopeProvider(databaseFactory, fileSystems, coreDebug, mediaFileSystem, logger, typeFinder, NoAppCache.Instance); return scopeProvider; diff --git a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs index 72c8d8b981..ca36a6049e 100644 --- a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs +++ b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs @@ -266,7 +266,7 @@ namespace Umbraco.Tests.Testing profiler = Mock.Of(); break; case UmbracoTestOptions.Logger.Serilog: - logger = new SerilogLogger(TestHelper.CoreDebug, IOHelper, TestHelper.Marchal, new FileInfo(TestHelper.MapPathForTest("~/unit-test.config"))); + logger = new SerilogLogger(TestHelper.CoreDebugSettings, IOHelper, TestHelper.Marchal, new FileInfo(TestHelper.MapPathForTest("~/unit-test.config"))); profiler = new LogProfiler(logger); break; case UmbracoTestOptions.Logger.Console: diff --git a/src/Umbraco.Tests/UmbracoExamine/ExamineBaseTest.cs b/src/Umbraco.Tests/UmbracoExamine/ExamineBaseTest.cs index 98c4dc96ca..91cb843eb1 100644 --- a/src/Umbraco.Tests/UmbracoExamine/ExamineBaseTest.cs +++ b/src/Umbraco.Tests/UmbracoExamine/ExamineBaseTest.cs @@ -17,7 +17,7 @@ namespace Umbraco.Tests.UmbracoExamine [OneTimeSetUp] public void InitializeFixture() { - var logger = new SerilogLogger(TestHelper.CoreDebug, IOHelper, TestHelper.Marchal, new FileInfo(TestHelper.MapPathForTest("~/unit-test.config"))); + var logger = new SerilogLogger(TestHelper.CoreDebugSettings, IOHelper, TestHelper.Marchal, new FileInfo(TestHelper.MapPathForTest("~/unit-test.config"))); _profilingLogger = new ProfilingLogger(logger, new LogProfiler(logger)); } diff --git a/src/Umbraco.Web.BackOffice/AspNetCore/UmbracoBackOfficeServiceCollectionExtensions.cs b/src/Umbraco.Web.BackOffice/AspNetCore/UmbracoBackOfficeServiceCollectionExtensions.cs index c05f4af4f8..6e336fd912 100644 --- a/src/Umbraco.Web.BackOffice/AspNetCore/UmbracoBackOfficeServiceCollectionExtensions.cs +++ b/src/Umbraco.Web.BackOffice/AspNetCore/UmbracoBackOfficeServiceCollectionExtensions.cs @@ -1,16 +1,16 @@ -using System.Configuration; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Umbraco.Composing; -using Umbraco.Core; +using Umbraco.Configuration; using Umbraco.Core.Cache; using Umbraco.Core.Configuration; +using Umbraco.Core.Configuration.HealthChecks; using Umbraco.Core.IO; using Umbraco.Core.Logging; using Umbraco.Core.Logging.Serilog; -using Umbraco.Core.Runtime; namespace Umbraco.Web.BackOffice.AspNetCore { @@ -18,28 +18,43 @@ namespace Umbraco.Web.BackOffice.AspNetCore { public static IServiceCollection AddUmbracoBackOffice(this IServiceCollection services) { - - services.AddSingleton(); - CreateCompositionRoot(services); - - return services; - } - - - private static void CreateCompositionRoot(IServiceCollection services) - { var serviceProvider = services.BuildServiceProvider(); var httpContextAccessor = serviceProvider.GetService(); var webHostEnvironment = serviceProvider.GetService(); var hostApplicationLifetime = serviceProvider.GetService(); + var configuration = serviceProvider.GetService(); + var configsFactory = new AspNetCoreConfigsFactory(configuration); + var configs = configsFactory.Create(); + + var settings = configs.GetConfig(); + + var x =settings.ModelsDirectory; + + + services.CreateCompositionRoot( + httpContextAccessor, + webHostEnvironment, + hostApplicationLifetime, + configsFactory); + + return services; + } + + + public static IServiceCollection CreateCompositionRoot( + this IServiceCollection services, + IHttpContextAccessor httpContextAccessor, + IWebHostEnvironment webHostEnvironment, + IHostApplicationLifetime hostApplicationLifetime, + IConfigsFactory configsFactory) + { var configFactory = new ConfigsFactory(); - var hostingSettings = configFactory.HostingSettings; - var coreDebug = configFactory.CoreDebug; + var coreDebug = configFactory.CoreDebugSettings; var globalSettings = configFactory.GlobalSettings; var hostingEnvironment = new AspNetCoreHostingEnvironment(hostingSettings, webHostEnvironment, httpContextAccessor, hostApplicationLifetime); @@ -51,6 +66,8 @@ namespace Umbraco.Web.BackOffice.AspNetCore var profiler = new LogProfiler(logger); Current.Initialize(logger, configs, ioHelper, hostingEnvironment, backOfficeInfo, profiler); + + return services; } } } diff --git a/src/Umbraco.Web.UI.Client/src/views/components/content/umb-content-node-info.html b/src/Umbraco.Web.UI.Client/src/views/components/content/umb-content-node-info.html index d8241b4dd7..416cf9d508 100644 --- a/src/Umbraco.Web.UI.Client/src/views/components/content/umb-content-node-info.html +++ b/src/Umbraco.Web.UI.Client/src/views/components/content/umb-content-node-info.html @@ -26,7 +26,7 @@
-
+

The following URLs redirect to this content item:

@@ -44,7 +44,7 @@ - +
- @@ -79,7 +79,7 @@
- {{ item.comment }} - +
@@ -126,7 +126,7 @@
- + diff --git a/src/Umbraco.Web.UI.NetCore/Program.cs b/src/Umbraco.Web.UI.NetCore/Program.cs index 21eb1b6585..bbe78907f1 100644 --- a/src/Umbraco.Web.UI.NetCore/Program.cs +++ b/src/Umbraco.Web.UI.NetCore/Program.cs @@ -1,11 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; + namespace Umbraco.Web.UI.BackOffice { diff --git a/src/Umbraco.Web.UI.NetCore/Startup.cs b/src/Umbraco.Web.UI.NetCore/Startup.cs index 8e4da28917..fb9ab608a3 100644 --- a/src/Umbraco.Web.UI.NetCore/Startup.cs +++ b/src/Umbraco.Web.UI.NetCore/Startup.cs @@ -5,6 +5,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Umbraco.Web.BackOffice.AspNetCore; @@ -15,6 +16,7 @@ namespace Umbraco.Web.UI.BackOffice { public class Startup { + // This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) diff --git a/src/Umbraco.Web.UI.NetCore/appsettings.json b/src/Umbraco.Web.UI.NetCore/appsettings.json index d9d9a9bff6..6880b3fe89 100644 --- a/src/Umbraco.Web.UI.NetCore/appsettings.json +++ b/src/Umbraco.Web.UI.NetCore/appsettings.json @@ -1,10 +1,91 @@ { - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information" + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + }, + "AllowedHosts": "*", + "Umbraco": { + "CMS": { + "HealthChecks": { + "DisabledChecks": [ + { + "id": "1B5D221B-CE99-4193-97CB-5F3261EC73DF", + "disabledBy": 1, + "disabledOn": "2020-03-15 19:19:10" + } + ], + "NotificationSettings": { + "Enabled": true, + "FirstRunTime" : "", + "PeriodInHours": 24, + "NotificationMethods": { + "Email": { + "Enabled" : true, + "Verbosity" : "Summary", + "Settings": { + "RecipientEmail": "" + } + } + }, + "DisabledChecks": [ + { + "id": "1B5D221B-CE99-4193-97CB-5F3261EC73DF", + "disabledBy": 1, + "disabledOn": "2020-03-15 19:19:10" + } + ] + } + }, + "Tours": { + "EnableTours": true + }, + "Core": { + "Debug": { + + } + }, + "Content": { + "Errors": { + "Error404" : { + "default": "1047", + "en-US":"$site/error [@name = 'error']", + "en-UK" : "8560867F-B88F-4C74-A9A4-679D8E5B3BFC" + } + } + }, + "RequestHandler": { + "AddTrailingSlash": true, + "CharCollection": { + " ": "-", + "\"":"", + "'":"", + "%":"", + ".":"", + ";":"", + "/":"", + "\\":"", + ":":"", + "#":"", + "+":"plus", + "*":"star", + "&":"", + "?":"", + "æ":"ae", + "ø":"oe", + "å":"aa", + "ä":"ae", + "ö":"oe", + "ü":"ue", + "ß":"ss", + "|":"-", + "<":"", + ">":"" + } + } + }, + } - }, - "AllowedHosts": "*" } diff --git a/src/Umbraco.Web/HealthCheck/HealthCheckController.cs b/src/Umbraco.Web/HealthCheck/HealthCheckController.cs index 251c5c0ae4..bfd33399d2 100644 --- a/src/Umbraco.Web/HealthCheck/HealthCheckController.cs +++ b/src/Umbraco.Web/HealthCheck/HealthCheckController.cs @@ -20,12 +20,12 @@ namespace Umbraco.Web.HealthCheck private readonly IList _disabledCheckIds; private readonly ILogger _logger; - public HealthCheckController(HealthCheckCollection checks, ILogger logger, IHealthChecks healthChecks) + public HealthCheckController(HealthCheckCollection checks, ILogger logger, IHealthChecksSettings healthChecksSettings) { _checks = checks ?? throw new ArgumentNullException(nameof(checks)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); - var healthCheckConfig = healthChecks ?? throw new ArgumentNullException(nameof(healthChecks)); + var healthCheckConfig = healthChecksSettings ?? throw new ArgumentNullException(nameof(healthChecksSettings)); _disabledCheckIds = healthCheckConfig.DisabledChecks .Select(x => x.Id) .ToList(); diff --git a/src/Umbraco.Web/UmbracoApplicationBase.cs b/src/Umbraco.Web/UmbracoApplicationBase.cs index 889cae5002..1b76c75223 100644 --- a/src/Umbraco.Web/UmbracoApplicationBase.cs +++ b/src/Umbraco.Web/UmbracoApplicationBase.cs @@ -34,7 +34,7 @@ namespace Umbraco.Web var configFactory = new ConfigsFactory(); var hostingSettings = configFactory.HostingSettings; - var coreDebug = configFactory.CoreDebug; + var coreDebug = configFactory.CoreDebugSettings; var globalSettings = configFactory.GlobalSettings; var hostingEnvironment = new AspNetHostingEnvironment(hostingSettings);