Merge remote-tracking branch 'origin/v8/dev' into v9/dev
# Conflicts: # src/Umbraco.Core/Composing/CompositionExtensions/Services.cs # src/Umbraco.Core/Constants-AppSettings.cs # src/Umbraco.Core/Dashboards/ContentDashboardSettings.cs # src/Umbraco.Core/Dashboards/IContentDashboardSettings.cs # src/Umbraco.Core/Manifest/ManifestParser.cs # src/Umbraco.Core/Manifest/PackageManifest.cs # src/Umbraco.Core/Migrations/Install/DatabaseDataCreator.cs # src/Umbraco.Core/Migrations/Upgrade/UmbracoPlan.cs # src/Umbraco.Core/Models/PropertyTagsExtensions.cs # src/Umbraco.Core/PropertyEditors/ComplexPropertyEditorContentEventHandler.cs # src/Umbraco.Core/PropertyEditors/ConfigurationEditor.cs # src/Umbraco.Core/PropertyEditors/DataValueEditor.cs # src/Umbraco.Core/PropertyEditors/ValueConverters/ImageCropperValue.cs # src/Umbraco.Core/Serialization/JsonToStringConverter.cs # src/Umbraco.Core/Sync/ApplicationUrlHelper.cs # src/Umbraco.Core/Telemetry/ITelemetryService.cs # src/Umbraco.Core/Telemetry/Models/PackageTelemetry.cs # src/Umbraco.Core/Telemetry/Models/TelemetryReportData.cs # src/Umbraco.Core/Telemetry/TelemetryService.cs # src/Umbraco.Tests/Manifest/ManifestParserTests.cs # src/Umbraco.Tests/PropertyEditors/BlockEditorComponentTests.cs # src/Umbraco.Tests/PropertyEditors/ImageCropperTest.cs # src/Umbraco.Tests/PropertyEditors/NestedContentPropertyComponentTests.cs # src/Umbraco.Tests/Web/Controllers/AuthenticationControllerTests.cs # src/Umbraco.Tests/Web/Controllers/UsersControllerTests.cs # src/Umbraco.Web.UI.Client/src/common/resources/entity.resource.js # src/Umbraco.Web.UI/Umbraco/config/lang/da.xml # src/Umbraco.Web.UI/Umbraco/config/lang/en.xml # src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml # src/Umbraco.Web.UI/web.Template.config # src/Umbraco.Web/BatchedDatabaseServerMessenger.cs # src/Umbraco.Web/Cache/DistributedCacheBinder.cs # src/Umbraco.Web/Compose/BlockEditorComponent.cs # src/Umbraco.Web/Compose/NestedContentPropertyComponent.cs # src/Umbraco.Web/Editors/AuthenticationController.cs # src/Umbraco.Web/Editors/ContentTypeController.cs # src/Umbraco.Web/Editors/DashboardController.cs # src/Umbraco.Web/Editors/EntityController.cs # src/Umbraco.Web/Editors/UsersController.cs # src/Umbraco.Web/PropertyEditors/BlockEditorPropertyEditor.cs # src/Umbraco.Web/PropertyEditors/ColorPickerConfigurationEditor.cs # src/Umbraco.Web/PropertyEditors/GridPropertyEditor.cs # src/Umbraco.Web/PropertyEditors/ImageCropperPropertyEditor.cs # src/Umbraco.Web/PropertyEditors/ImageCropperPropertyValueEditor.cs # src/Umbraco.Web/PropertyEditors/MediaPicker3PropertyEditor.cs # src/Umbraco.Web/PropertyEditors/MultiUrlPickerValueEditor.cs # src/Umbraco.Web/PropertyEditors/MultipleTextStringPropertyEditor.cs # src/Umbraco.Web/PropertyEditors/MultipleValueEditor.cs # src/Umbraco.Web/PropertyEditors/NestedContentPropertyEditor.cs # src/Umbraco.Web/PropertyEditors/RichTextPropertyEditor.cs # src/Umbraco.Web/PropertyEditors/TagsPropertyEditor.cs # src/Umbraco.Web/Telemetry/ReportSiteTask.cs # src/Umbraco.Web/Telemetry/TelemetryComponent.cs # src/Umbraco.Web/Trees/ContentTreeController.cs # src/Umbraco.Web/Umbraco.Web.csproj # src/Umbraco.Web/WebApi/EnableDetailedErrorsAttribute.cs
This commit is contained in:
@@ -0,0 +1,109 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.HealthCheck.Checks.Config;
|
||||
|
||||
namespace Umbraco.Web.HealthCheck.Checks.Security
|
||||
{
|
||||
[HealthCheck(
|
||||
"6708CA45-E96E-40B8-A40A-0607C1CA7F28",
|
||||
"Application URL Configuration",
|
||||
Description = "Checks if the Umbraco application URL is configured for your site.",
|
||||
Group = "Security")]
|
||||
public class UmbracoApplicationUrlCheck : HealthCheck
|
||||
{
|
||||
private readonly ILocalizedTextService _textService;
|
||||
private readonly IRuntimeState _runtime;
|
||||
private readonly IUmbracoSettingsSection _settings;
|
||||
|
||||
private const string SetApplicationUrlAction = "setApplicationUrl";
|
||||
|
||||
public UmbracoApplicationUrlCheck(ILocalizedTextService textService, IRuntimeState runtime, IUmbracoSettingsSection settings)
|
||||
{
|
||||
_textService = textService;
|
||||
_runtime = runtime;
|
||||
_settings = settings;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes the action and returns its status
|
||||
/// </summary>
|
||||
/// <param name="action"></param>
|
||||
/// <returns></returns>
|
||||
public override HealthCheckStatus ExecuteAction(HealthCheckAction action)
|
||||
{
|
||||
switch (action.Alias)
|
||||
{
|
||||
case SetApplicationUrlAction:
|
||||
return SetUmbracoApplicationUrl();
|
||||
default:
|
||||
throw new InvalidOperationException("UmbracoApplicationUrlCheck action requested is either not executable or does not exist");
|
||||
}
|
||||
}
|
||||
|
||||
public override IEnumerable<HealthCheckStatus> GetStatus()
|
||||
{
|
||||
//return the statuses
|
||||
return new[] { CheckUmbracoApplicationUrl() };
|
||||
}
|
||||
|
||||
private HealthCheckStatus CheckUmbracoApplicationUrl()
|
||||
{
|
||||
var url = _settings.WebRouting.UmbracoApplicationUrl;
|
||||
|
||||
string resultMessage;
|
||||
StatusResultType resultType;
|
||||
var actions = new List<HealthCheckAction>();
|
||||
|
||||
if (url.IsNullOrWhiteSpace())
|
||||
{
|
||||
resultMessage = _textService.Localize("healthcheck", "umbracoApplicationUrlCheckResultFalse");
|
||||
resultType = StatusResultType.Warning;
|
||||
|
||||
actions.Add(new HealthCheckAction(SetApplicationUrlAction, Id)
|
||||
{
|
||||
Name = _textService.Localize("healthcheck", "umbracoApplicationUrlConfigureButton"),
|
||||
Description = _textService.Localize("healthcheck", "umbracoApplicationUrlConfigureDescription")
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
resultMessage = _textService.Localize("healthcheck", "umbracoApplicationUrlCheckResultTrue", new[] { url });
|
||||
resultType = StatusResultType.Success;
|
||||
}
|
||||
|
||||
return new HealthCheckStatus(resultMessage)
|
||||
{
|
||||
ResultType = resultType,
|
||||
Actions = actions
|
||||
};
|
||||
}
|
||||
|
||||
private HealthCheckStatus SetUmbracoApplicationUrl()
|
||||
{
|
||||
var configFilePath = IOHelper.MapPath("~/config/umbracoSettings.config");
|
||||
const string xPath = "/settings/web.routing/@umbracoApplicationUrl";
|
||||
var configurationService = new ConfigurationService(configFilePath, xPath, _textService);
|
||||
var urlValue = _runtime.ApplicationUrl.ToString();
|
||||
var updateConfigFile = configurationService.UpdateConfigFile(urlValue);
|
||||
|
||||
if (updateConfigFile.Success)
|
||||
{
|
||||
return
|
||||
new HealthCheckStatus(_textService.Localize("healthcheck", "umbracoApplicationUrlConfigureSuccess", new[] { urlValue }))
|
||||
{
|
||||
ResultType = StatusResultType.Success
|
||||
};
|
||||
}
|
||||
|
||||
return
|
||||
new HealthCheckStatus(_textService.Localize("healthcheck", "umbracoApplicationUrlConfigureError", new[] { updateConfigFile.Result }))
|
||||
{
|
||||
ResultType = StatusResultType.Error
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user