Merge remote-tracking branch 'origin/netcore/netcore' into netcore/task/6973-migrating-authenticationcontroller-merge

# Conflicts:
#	src/Umbraco.Infrastructure/HostedServices/ScheduledPublishing.cs
#	src/Umbraco.Infrastructure/Runtime/CoreInitialComposer.cs
#	src/Umbraco.Infrastructure/Scheduling/SchedulerComponent.cs
#	src/Umbraco.Infrastructure/Scheduling/SchedulerComposer.cs
#	src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs
#	src/Umbraco.Tests/Testing/UmbracoTestBase.cs
#	src/Umbraco.Web.BackOffice/Extensions/BackOfficeApplicationBuilderExtensions.cs
#	src/Umbraco.Web.BackOffice/Runtime/BackOfficeComposer.cs
#	src/Umbraco.Web.Common/Runtime/AspNetCoreComposer.cs
#	src/Umbraco.Web.Common/UmbracoContext/UmbracoContext.cs
#	src/Umbraco.Web.UI.NetCore/appsettings.json
#	src/Umbraco.Web/Editors/BackOfficeController.cs
#	src/Umbraco.Web/Runtime/WebInitialComponent.cs
This commit is contained in:
Bjarke Berg
2020-11-12 13:10:19 +01:00
435 changed files with 6275 additions and 9816 deletions

View File

@@ -0,0 +1,10 @@
using System;
namespace Umbraco.Core.Configuration
{
public interface ICronTabParser
{
bool IsValidCronTab(string cronTab);
DateTime GetNextOccurrence(string cronTab, DateTime time);
}
}

View File

@@ -0,0 +1,27 @@
using System;
namespace Umbraco.Core.Configuration.Models
{
public class DatabaseServerMessengerSettings
{
/// <summary>
/// The maximum number of instructions that can be processed at startup; otherwise the server cold-boots (rebuilds its caches).
/// </summary>
public int MaxProcessingInstructionCount { get; set; } = 1000;
/// <summary>
/// The time to keep instructions in the database; records older than this number will be pruned.
/// </summary>
public TimeSpan TimeToRetainInstructions { get; set; } = TimeSpan.FromDays(2);
/// <summary>
/// The time to wait between each sync operations.
/// </summary>
public TimeSpan TimeBetweenSyncOperations { get; set; } = TimeSpan.FromSeconds(5);
/// <summary>
/// The time to wait between each prune operations.
/// </summary>
public TimeSpan TimeBetweenPruneOperations { get; set; } = TimeSpan.FromMinutes(1);
}
}

View File

@@ -0,0 +1,17 @@
using System;
namespace Umbraco.Core.Configuration.Models
{
public class DatabaseServerRegistrarSettings
{
/// <summary>
/// The amount of time to wait between calls to the database on the background thread.
/// </summary>
public TimeSpan WaitTimeBetweenCalls { get; set; } = TimeSpan.FromMinutes(1);
/// <summary>
/// The time span to wait before considering a server stale, after it has last been accessed.
/// </summary>
public TimeSpan StaleServerTimeout { get; set; } = TimeSpan.FromMinutes(2);
}
}

View File

@@ -0,0 +1,13 @@
using System;
namespace Umbraco.Core.Configuration.Models
{
public class DisabledHealthCheckSettings
{
public Guid Id { get; set; }
public DateTime DisabledOn { get; set; }
public int DisabledBy { get; set; }
}
}

View File

@@ -49,13 +49,17 @@
public bool DisableElectionForSingleServer { get; set; } = false;
public DatabaseServerRegistrarSettings DatabaseServerRegistrar { get; set; } = new DatabaseServerRegistrarSettings();
public DatabaseServerMessengerSettings DatabaseServerMessenger { get; set; } = new DatabaseServerMessengerSettings();
public string RegisterType { get; set; } = string.Empty;
public string DatabaseFactoryServerVersion { get; set; } = string.Empty;
public string MainDomLock { get; set; } = string.Empty;
public string NoNodesViewPath { get; set; } = "~/config/splashes/NoNodes.cshtml";
public string NoNodesViewPath { get; set; } = "~/umbraco/UmbracoWebsite/NoNodes.cshtml";
public bool IsSmtpServerConfigured => !string.IsNullOrWhiteSpace(Smtp?.Host);

View File

@@ -0,0 +1,16 @@
using System.Collections.Generic;
using Umbraco.Core.HealthCheck;
namespace Umbraco.Core.Configuration.Models
{
public class HealthChecksNotificationMethodSettings
{
public bool Enabled { get; set; } = false;
public HealthCheckNotificationVerbosity Verbosity { get; set; } = HealthCheckNotificationVerbosity.Summary;
public bool FailureOnly { get; set; } = false;
public IDictionary<string, string> Settings { get; set; } = new Dictionary<string, string>();
}
}

View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace Umbraco.Core.Configuration.Models
{
public class HealthChecksNotificationSettings
{
public bool Enabled { get; set; } = false;
public string FirstRunTime { get; set; } = string.Empty;
public TimeSpan Period { get; set; } = TimeSpan.FromHours(24);
public IDictionary<string, HealthChecksNotificationMethodSettings> NotificationMethods { get; set; } = new Dictionary<string, HealthChecksNotificationMethodSettings>();
public IEnumerable<DisabledHealthCheckSettings> DisabledChecks { get; set; } = Enumerable.Empty<DisabledHealthCheckSettings>();
}
}

View File

@@ -1,27 +1,12 @@
using System.Collections.Generic;
using System.Linq;
using Umbraco.Core.HealthCheck;
using Umbraco.Core.HealthCheck.Checks;
namespace Umbraco.Core.Configuration.Models
{
public class HealthChecksSettings
{
public IEnumerable<DisabledHealthCheck> DisabledChecks { get; set; } = Enumerable.Empty<DisabledHealthCheck>();
public IEnumerable<DisabledHealthCheckSettings> DisabledChecks { get; set; } = Enumerable.Empty<DisabledHealthCheckSettings>();
public HealthCheckNotificationSettings NotificationSettings { get; set; } = new HealthCheckNotificationSettings();
public class HealthCheckNotificationSettings
{
public bool Enabled { get; set; } = false;
public string FirstRunTime { get; set; }
public int PeriodInHours { get; set; } = 24;
public IReadOnlyDictionary<string, INotificationMethod> NotificationMethods { get; set; } = new Dictionary<string, INotificationMethod>();
public IEnumerable<DisabledHealthCheck> DisabledChecks { get; set; } = Enumerable.Empty<DisabledHealthCheck>();
}
public HealthChecksNotificationSettings Notification { get; set; } = new HealthChecksNotificationSettings();
}
}

View File

@@ -2,7 +2,7 @@ namespace Umbraco.Core.Configuration.Models
{
public class KeepAliveSettings
{
public bool DisableKeepAliveTask => false;
public bool DisableKeepAliveTask { get; set; } = false;
public string KeepAlivePingUrl => "{umbracoApplicationUrl}/api/keepalive/ping";
}

View File

@@ -1,7 +1,9 @@
namespace Umbraco.Core.Configuration.Models
using System;
namespace Umbraco.Core.Configuration.Models
{
public class LoggingSettings
{
public int MaxLogAge { get; set; } = -1;
public TimeSpan MaxLogAge { get; set; } = TimeSpan.FromHours(24);
}
}

View File

@@ -1,10 +1,22 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.Net.Mail;
using Umbraco.Core.Configuration.Models.Validation;
namespace Umbraco.Core.Configuration.Models
{
/// <summary>
/// Matches MailKit.Security.SecureSocketOptions and defined locally to avoid having to take
/// thi
/// </summary>
public enum SecureSocketOptions
{
None = 0,
Auto = 1,
SslOnConnect = 2,
StartTls = 3,
StartTlsWhenAvailable = 4
}
public class SmtpSettings : ValidatableEntryBase
{
[Required]
@@ -15,6 +27,8 @@ namespace Umbraco.Core.Configuration.Models
public int Port { get; set; }
public SecureSocketOptions SecureSocketOptions { get; set; } = SecureSocketOptions.Auto;
public string PickupDirectoryLocation { get; set; }
public SmtpDeliveryMethod DeliveryMethod { get; set; } = SmtpDeliveryMethod.Network;

View File

@@ -41,5 +41,8 @@ namespace Umbraco.Core.Configuration.Models.Validation
message = string.Empty;
return true;
}
}
}

View File

@@ -1,6 +1,5 @@
using System.Collections.Generic;
using Microsoft.Extensions.Options;
using Umbraco.Core.Macros;
namespace Umbraco.Core.Configuration.Models.Validation
{

View File

@@ -0,0 +1,41 @@
using Microsoft.Extensions.Options;
namespace Umbraco.Core.Configuration.Models.Validation
{
public class HealthChecksSettingsValidator : ConfigurationValidatorBase, IValidateOptions<HealthChecksSettings>
{
private readonly ICronTabParser _cronTabParser;
public HealthChecksSettingsValidator(ICronTabParser cronTabParser)
{
_cronTabParser = cronTabParser;
}
public ValidateOptionsResult Validate(string name, HealthChecksSettings options)
{
if (!ValidateNotificationFirstRunTime(options.Notification.FirstRunTime, out var message))
{
return ValidateOptionsResult.Fail(message);
}
return ValidateOptionsResult.Success;
}
private bool ValidateNotificationFirstRunTime(string value, out string message)
{
return ValidateOptionalCronTab($"{Constants.Configuration.ConfigHealthChecks}:{nameof(HealthChecksSettings.Notification)}:{nameof(HealthChecksSettings.Notification.FirstRunTime)}", value, out message);
}
public bool ValidateOptionalCronTab(string configPath, string value, out string message)
{
if (!string.IsNullOrEmpty(value) && !_cronTabParser.IsValidCronTab(value))
{
message = $"Configuration entry {configPath} contains an invalid cron expression.";
return false;
}
message = string.Empty;
return true;
}
}
}