diff --git a/src/Umbraco.Configuration/AspNetCoreConfigsFactory.cs b/src/Umbraco.Configuration/AspNetCoreConfigsFactory.cs
index d8b5e666b9..f957074881 100644
--- a/src/Umbraco.Configuration/AspNetCoreConfigsFactory.cs
+++ b/src/Umbraco.Configuration/AspNetCoreConfigsFactory.cs
@@ -3,6 +3,7 @@ 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
{
diff --git a/src/Umbraco.Configuration/Umbraco.Configuration.csproj b/src/Umbraco.Configuration/Umbraco.Configuration.csproj
index 8d7a0e7f01..a4dac22386 100644
--- a/src/Umbraco.Configuration/Umbraco.Configuration.csproj
+++ b/src/Umbraco.Configuration/Umbraco.Configuration.csproj
@@ -10,25 +10,15 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Umbraco.Core/Configuration/Models/MemberPasswordConfigurationSettings.cs b/src/Umbraco.Core/Configuration/Models/MemberPasswordConfigurationSettings.cs
index 1f2808ef7e..52bba6f4b8 100644
--- a/src/Umbraco.Core/Configuration/Models/MemberPasswordConfigurationSettings.cs
+++ b/src/Umbraco.Core/Configuration/Models/MemberPasswordConfigurationSettings.cs
@@ -1,7 +1,4 @@
-using Umbraco.Core;
-using Umbraco.Core.Configuration;
-
-namespace Umbraco.Core.Configuration.Models
+namespace Umbraco.Core.Configuration.Models
{
public class MemberPasswordConfigurationSettings : IPasswordConfiguration
{
diff --git a/src/Umbraco.Core/Configuration/Models/UserPasswordConfigurationSettings.cs b/src/Umbraco.Core/Configuration/Models/UserPasswordConfigurationSettings.cs
index a0c26b2410..445a0f545c 100644
--- a/src/Umbraco.Core/Configuration/Models/UserPasswordConfigurationSettings.cs
+++ b/src/Umbraco.Core/Configuration/Models/UserPasswordConfigurationSettings.cs
@@ -1,7 +1,4 @@
-using Umbraco.Core;
-using Umbraco.Core.Configuration;
-
-namespace Umbraco.Core.Configuration.Models
+namespace Umbraco.Core.Configuration.Models
{
public class UserPasswordConfigurationSettings : IPasswordConfiguration
{
diff --git a/src/Umbraco.Infrastructure/Umbraco.Infrastructure.csproj b/src/Umbraco.Infrastructure/Umbraco.Infrastructure.csproj
index fa0ac89c61..d9cd6bf498 100644
--- a/src/Umbraco.Infrastructure/Umbraco.Infrastructure.csproj
+++ b/src/Umbraco.Infrastructure/Umbraco.Infrastructure.csproj
@@ -97,7 +97,6 @@
-
diff --git a/src/Umbraco.ModelsBuilder.Embedded/Building/Builder.cs b/src/Umbraco.ModelsBuilder.Embedded/Building/Builder.cs
index f64e5ed1ce..dc093d3c2d 100644
--- a/src/Umbraco.ModelsBuilder.Embedded/Building/Builder.cs
+++ b/src/Umbraco.ModelsBuilder.Embedded/Building/Builder.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using Umbraco.Core;
using Umbraco.Core.Configuration;
+using Umbraco.Core.Configuration.Models;
namespace Umbraco.ModelsBuilder.Embedded.Building
{
@@ -70,7 +71,7 @@ namespace Umbraco.ModelsBuilder.Embedded.Building
///
/// The list of models to generate.
/// The models namespace.
- protected Builder(IModelsBuilderConfig config, IList typeModels)
+ protected Builder(ModelsBuilderConfig config, IList typeModels)
{
_typeModels = typeModels ?? throw new ArgumentNullException(nameof(typeModels));
@@ -87,7 +88,7 @@ namespace Umbraco.ModelsBuilder.Embedded.Building
protected Builder()
{ }
- protected IModelsBuilderConfig Config { get; }
+ protected ModelsBuilderConfig Config { get; }
///
/// Prepares generation by processing the result of code parsing.
diff --git a/src/Umbraco.ModelsBuilder.Embedded/Building/ModelsGenerator.cs b/src/Umbraco.ModelsBuilder.Embedded/Building/ModelsGenerator.cs
index 648a2e76fa..1572fc9b92 100644
--- a/src/Umbraco.ModelsBuilder.Embedded/Building/ModelsGenerator.cs
+++ b/src/Umbraco.ModelsBuilder.Embedded/Building/ModelsGenerator.cs
@@ -1,6 +1,8 @@
using System.IO;
using System.Text;
+using Microsoft.Extensions.Options;
using Umbraco.Core.Configuration;
+using Umbraco.Core.Configuration.Models;
using Umbraco.Core.IO;
namespace Umbraco.ModelsBuilder.Embedded.Building
@@ -8,14 +10,14 @@ namespace Umbraco.ModelsBuilder.Embedded.Building
public class ModelsGenerator
{
private readonly UmbracoServices _umbracoService;
- private readonly IModelsBuilderConfig _config;
+ private readonly ModelsBuilderConfig _config;
private readonly OutOfDateModelsStatus _outOfDateModels;
private readonly IIOHelper _ioHelper;
- public ModelsGenerator(UmbracoServices umbracoService, IModelsBuilderConfig config, OutOfDateModelsStatus outOfDateModels, IIOHelper ioHelper)
+ public ModelsGenerator(UmbracoServices umbracoService, IOptionsSnapshot config, OutOfDateModelsStatus outOfDateModels, IIOHelper ioHelper)
{
_umbracoService = umbracoService;
- _config = config;
+ _config = config.Value;
_outOfDateModels = outOfDateModels;
_ioHelper = ioHelper;
}
diff --git a/src/Umbraco.ModelsBuilder.Embedded/Building/TextBuilder.cs b/src/Umbraco.ModelsBuilder.Embedded/Building/TextBuilder.cs
index 723ee10f35..9a2ad6f600 100644
--- a/src/Umbraco.ModelsBuilder.Embedded/Building/TextBuilder.cs
+++ b/src/Umbraco.ModelsBuilder.Embedded/Building/TextBuilder.cs
@@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using Umbraco.Core.Configuration;
+using Umbraco.Core.Configuration.Models;
namespace Umbraco.ModelsBuilder.Embedded.Building
{
@@ -17,7 +18,7 @@ namespace Umbraco.ModelsBuilder.Embedded.Building
/// and the result of code parsing.
///
/// The list of models to generate.
- public TextBuilder(IModelsBuilderConfig config, IList typeModels)
+ public TextBuilder(ModelsBuilderConfig config, IList typeModels)
: base(config, typeModels)
{ }
diff --git a/src/Umbraco.ModelsBuilder.Embedded/Compose/ModelsBuilderComposer.cs b/src/Umbraco.ModelsBuilder.Embedded/Compose/ModelsBuilderComposer.cs
index e582301740..3873080605 100644
--- a/src/Umbraco.ModelsBuilder.Embedded/Compose/ModelsBuilderComposer.cs
+++ b/src/Umbraco.ModelsBuilder.Embedded/Compose/ModelsBuilderComposer.cs
@@ -6,15 +6,22 @@ using Umbraco.Core.Logging;
using Umbraco.Core.Composing;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.ModelsBuilder.Embedded.Building;
+using Umbraco.Core.Configuration.Models;
+using Microsoft.Extensions.Options;
namespace Umbraco.ModelsBuilder.Embedded.Compose
{
-
-
[ComposeBefore(typeof(IPublishedCacheComposer))]
[RuntimeLevel(MinLevel = RuntimeLevel.Run)]
public sealed class ModelsBuilderComposer : ICoreComposer
{
+ private readonly ModelsBuilderConfig _config;
+
+ public ModelsBuilderComposer(IOptionsSnapshot config)
+ {
+ _config = config.Value;
+ }
+
public void Compose(Composition composition)
{
var isLegacyModelsBuilderInstalled = IsLegacyModelsBuilderInstalled();
@@ -32,9 +39,9 @@ namespace Umbraco.ModelsBuilder.Embedded.Compose
composition.RegisterUnique();
composition.RegisterUnique();
- if (composition.Configs.ModelsBuilder().ModelsMode == ModelsMode.PureLive)
+ if (_config.ModelsMode == ModelsMode.PureLive)
ComposeForLiveModels(composition);
- else if (composition.Configs.ModelsBuilder().EnableFactory)
+ else if (_config.EnableFactory)
ComposeForDefaultModelsFactory(composition);
}
diff --git a/src/Umbraco.ModelsBuilder.Embedded/ModelsGenerationError.cs b/src/Umbraco.ModelsBuilder.Embedded/ModelsGenerationError.cs
index f8f6e8c7bc..92c73e2c6d 100644
--- a/src/Umbraco.ModelsBuilder.Embedded/ModelsGenerationError.cs
+++ b/src/Umbraco.ModelsBuilder.Embedded/ModelsGenerationError.cs
@@ -1,19 +1,21 @@
using System;
using System.IO;
using System.Text;
+using Microsoft.Extensions.Options;
using Umbraco.Core.Configuration;
+using Umbraco.Core.Configuration.Models;
using Umbraco.Core.IO;
namespace Umbraco.ModelsBuilder.Embedded
{
public sealed class ModelsGenerationError
{
- private readonly IModelsBuilderConfig _config;
+ private readonly ModelsBuilderConfig _config;
private readonly IIOHelper _ioHelper;
- public ModelsGenerationError(IModelsBuilderConfig config, IIOHelper ioHelper)
+ public ModelsGenerationError(IOptionsSnapshot config, IIOHelper ioHelper)
{
- _config = config;
+ _config = config.Value;
_ioHelper = ioHelper;
}
diff --git a/src/Umbraco.ModelsBuilder.Embedded/OutOfDateModelsStatus.cs b/src/Umbraco.ModelsBuilder.Embedded/OutOfDateModelsStatus.cs
index b8105eeef2..4fb23ad5b3 100644
--- a/src/Umbraco.ModelsBuilder.Embedded/OutOfDateModelsStatus.cs
+++ b/src/Umbraco.ModelsBuilder.Embedded/OutOfDateModelsStatus.cs
@@ -1,5 +1,6 @@
using System.IO;
using Umbraco.Core.Configuration;
+using Umbraco.Core.Configuration.Models;
using Umbraco.Core.IO;
using Umbraco.Web.Cache;
@@ -7,10 +8,10 @@ namespace Umbraco.ModelsBuilder.Embedded
{
public sealed class OutOfDateModelsStatus
{
- private readonly IModelsBuilderConfig _config;
+ private readonly ModelsBuilderConfig _config;
private readonly IIOHelper _ioHelper;
- public OutOfDateModelsStatus(IModelsBuilderConfig config, IIOHelper ioHelper)
+ public OutOfDateModelsStatus(ModelsBuilderConfig config, IIOHelper ioHelper)
{
_config = config;
_ioHelper = ioHelper;
diff --git a/src/Umbraco.ModelsBuilder.Embedded/PureLiveModelFactory.cs b/src/Umbraco.ModelsBuilder.Embedded/PureLiveModelFactory.cs
index 7809d2bf48..da48621c7d 100644
--- a/src/Umbraco.ModelsBuilder.Embedded/PureLiveModelFactory.cs
+++ b/src/Umbraco.ModelsBuilder.Embedded/PureLiveModelFactory.cs
@@ -19,6 +19,8 @@ using Umbraco.Core.Logging;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.ModelsBuilder.Embedded.Building;
using File = System.IO.File;
+using Umbraco.Core.Configuration.Models;
+using Microsoft.Extensions.Options;
namespace Umbraco.ModelsBuilder.Embedded
{
@@ -41,7 +43,7 @@ namespace Umbraco.ModelsBuilder.Embedded
private const string ProjVirt = "~/App_Data/Models/all.generated.cs";
private static readonly string[] OurFiles = { "models.hash", "models.generated.cs", "all.generated.cs", "all.dll.path", "models.err" };
- private readonly IModelsBuilderConfig _config;
+ private readonly ModelsBuilderConfig _config;
private readonly IApplicationShutdownRegistry _hostingLifetime;
private readonly IIOHelper _ioHelper;
private readonly ModelsGenerationError _errors;
@@ -49,14 +51,14 @@ namespace Umbraco.ModelsBuilder.Embedded
public PureLiveModelFactory(
Lazy umbracoServices,
IProfilingLogger logger,
- IModelsBuilderConfig config,
+ IOptionsSnapshot config,
IHostingEnvironment hostingEnvironment,
IApplicationShutdownRegistry hostingLifetime,
IIOHelper ioHelper)
{
_umbracoServices = umbracoServices;
_logger = logger;
- _config = config;
+ _config = config.Value;
_hostingLifetime = hostingLifetime;
_ioHelper = ioHelper;
_errors = new ModelsGenerationError(config, ioHelper);
diff --git a/src/Umbraco.Web.Common/Extensions/UmbracoCoreServiceCollectionExtensions.cs b/src/Umbraco.Web.Common/Extensions/UmbracoCoreServiceCollectionExtensions.cs
index 1c7f8156f4..4653bc7bbd 100644
--- a/src/Umbraco.Web.Common/Extensions/UmbracoCoreServiceCollectionExtensions.cs
+++ b/src/Umbraco.Web.Common/Extensions/UmbracoCoreServiceCollectionExtensions.cs
@@ -28,6 +28,7 @@ using Umbraco.Core.Persistence.SqlSyntax;
using Umbraco.Core.Runtime;
using Umbraco.Web.Common.AspNetCore;
using Umbraco.Web.Common.Profiler;
+using ConnectionStrings = Umbraco.Core.Configuration.Models.ConnectionStrings;
using CoreDebugSettings = Umbraco.Core.Configuration.Models.CoreDebugSettings;
namespace Umbraco.Extensions
@@ -124,6 +125,9 @@ namespace Umbraco.Extensions
services.Configure(configuration.GetSection(Constants.Configuration.ConfigModelsBuilderPrefix));
services.Configure(configuration.GetSection(Constants.Configuration.ConfigPrefix + "Imaging:"));
+ // TODO: HealthChecksSettings (+ one other?)
+
+ // TODO: remove this
var configsFactory = new AspNetCoreConfigsFactory(configuration);
var configs = configsFactory.Create();
services.AddSingleton(configs);
diff --git a/src/Umbraco.Web/AppBuilderExtensions.cs b/src/Umbraco.Web/AppBuilderExtensions.cs
index c8c6cbdf5c..18eb3a54fe 100644
--- a/src/Umbraco.Web/AppBuilderExtensions.cs
+++ b/src/Umbraco.Web/AppBuilderExtensions.cs
@@ -4,8 +4,7 @@ using Microsoft.Owin.Logging;
using Owin;
using Umbraco.Core.Configuration;
using Umbraco.Core.Hosting;
-using Umbraco.Core.IO;
-using Umbraco.Web.Composing;
+using Umbraco.Web.Configuration;
using Umbraco.Web.Logging;
namespace Umbraco.Web
@@ -48,7 +47,7 @@ namespace Umbraco.Web
///
public static IAppBuilder UseSignalR(this IAppBuilder app, IGlobalSettings globalSettings, IHostingEnvironment hostingEnvironment)
{
- var umbracoPath = globalSettings.GetUmbracoMvcArea(hostingEnvironment);
+ var umbracoPath = ConfigModelConversions.ConvertGlobalSettings(globalSettings).GetUmbracoMvcArea(hostingEnvironment);
var signalrPath = HttpRuntime.AppDomainAppVirtualPath + umbracoPath + "/BackOffice/signalr";
return app.MapSignalR(signalrPath, new HubConfiguration { EnableDetailedErrors = true });
}
diff --git a/src/Umbraco.Web/Compose/AuditEventsComponent.cs b/src/Umbraco.Web/Compose/AuditEventsComponent.cs
index 51c47233c7..9b9a1671f3 100644
--- a/src/Umbraco.Web/Compose/AuditEventsComponent.cs
+++ b/src/Umbraco.Web/Compose/AuditEventsComponent.cs
@@ -11,6 +11,7 @@ using Umbraco.Net;
using Umbraco.Core.Services;
using Umbraco.Core.Services.Implement;
using Umbraco.Extensions;
+using Umbraco.Web.Configuration;
namespace Umbraco.Core.Compose
{
@@ -49,7 +50,7 @@ namespace Umbraco.Core.Compose
public void Terminate()
{ }
- public static IUser UnknownUser(IGlobalSettings globalSettings) => new User(globalSettings) { Id = Constants.Security.UnknownUserId, Name = Constants.Security.UnknownUserName, Email = "" };
+ public static IUser UnknownUser(IGlobalSettings globalSettings) => new User(ConfigModelConversions.ConvertGlobalSettings(globalSettings)) { Id = Constants.Security.UnknownUserId, Name = Constants.Security.UnknownUserName, Email = "" };
private IUser CurrentPerformingUser
{
diff --git a/src/Umbraco.Web/Configuration/ConfigModelConversions.cs b/src/Umbraco.Web/Configuration/ConfigModelConversions.cs
new file mode 100644
index 0000000000..752983c7c9
--- /dev/null
+++ b/src/Umbraco.Web/Configuration/ConfigModelConversions.cs
@@ -0,0 +1,99 @@
+using Microsoft.AspNetCore.Identity;
+using Microsoft.Extensions.Options;
+using Umbraco.Core;
+using Umbraco.Core.BackOffice;
+using Umbraco.Core.Configuration;
+using Umbraco.Core.Configuration.Models;
+
+namespace Umbraco.Web.Configuration
+{
+ ///
+ /// TEMPORARY: this class has been added just to ensure Umbraco.Web functionality continues to compile, by
+ /// converting between (used by
+ /// legacy configuration and (used by Netcore/IOptions configuration).
+ ///
+ public static class ConfigModelConversions
+ {
+ public static GlobalSettings ConvertGlobalSettings(IGlobalSettings globalSettings)
+ {
+ return new GlobalSettings
+ {
+ DatabaseFactoryServerVersion = globalSettings.DatabaseFactoryServerVersion,
+ DefaultUILanguage = globalSettings.DefaultUILanguage,
+ DisableElectionForSingleServer = globalSettings.DisableElectionForSingleServer,
+ HideTopLevelNodeFromPath = globalSettings.HideTopLevelNodeFromPath,
+ InstallEmptyDatabase = globalSettings.InstallEmptyDatabase,
+ InstallMissingDatabase = globalSettings.InstallMissingDatabase,
+ MainDomLock = globalSettings.MainDomLock,
+ NoNodesViewPath = globalSettings.NoNodesViewPath,
+ RegisterType = globalSettings.RegisterType,
+ ReservedPaths = globalSettings.ReservedPaths,
+ ReservedUrls = globalSettings.ReservedUrls,
+ SmtpSettings = new SmtpSettings
+ {
+ DeliveryMethod = globalSettings.SmtpSettings.DeliveryMethod,
+ From = globalSettings.SmtpSettings.From,
+ Host = globalSettings.SmtpSettings.Host,
+ Password = globalSettings.SmtpSettings.Password,
+ PickupDirectoryLocation = globalSettings.SmtpSettings.PickupDirectoryLocation,
+ Port = globalSettings.SmtpSettings.Port,
+ Username = globalSettings.SmtpSettings.Username,
+ },
+ TimeOutInMinutes = globalSettings.TimeOutInMinutes,
+ UmbracoCssPath = globalSettings.UmbracoCssPath,
+ UmbracoMediaPath = globalSettings.UmbracoMediaPath,
+ UmbracoPath = globalSettings.UmbracoPath,
+ UmbracoScriptsPath = globalSettings.UmbracoScriptsPath,
+ UseHttps = globalSettings.UseHttps,
+ VersionCheckPeriod = globalSettings.VersionCheckPeriod,
+ };
+ }
+
+ public static Umbraco.Core.Configuration.Models.ConnectionStrings ConvertConnectionStrings(IConnectionStrings connectionStrings)
+ {
+ return new Umbraco.Core.Configuration.Models.ConnectionStrings
+ {
+ UmbracoConnectionString = connectionStrings[Constants.System.UmbracoConnectionName].ConnectionString
+ };
+ }
+
+ public static IOptions ConvertToOptionsOfUserPasswordConfigurationSettings(IOptions identityOptions)
+ {
+ var passwordOptions = identityOptions.Value.Password;
+ var lockOutOptions = identityOptions.Value.Lockout;
+ var passwordConfiguration = new UserPasswordConfigurationSettings
+ {
+ MaxFailedAccessAttemptsBeforeLockout = lockOutOptions.MaxFailedAccessAttempts,
+ HashAlgorithmType = Constants.Security.AspNetCoreV3PasswordHashAlgorithmName, // TODO: not sure where to map this from.
+ RequireDigit = passwordOptions.RequireDigit,
+ RequiredLength = passwordOptions.RequiredLength,
+ RequireLowercase = passwordOptions.RequireLowercase,
+ RequireNonLetterOrDigit = passwordOptions.RequireNonAlphanumeric,
+ RequireUppercase = passwordOptions.RequireUppercase,
+ };
+
+ return Options.Create(passwordConfiguration);
+ }
+
+ public static IOptions ConvertToOptionsOfBackOfficeIdentityOptions(IUserPasswordConfiguration passwordConfiguration)
+ {
+ var identityOptions = new BackOfficeIdentityOptions
+ {
+ Lockout = new LockoutOptions
+ {
+ MaxFailedAccessAttempts = passwordConfiguration.MaxFailedAccessAttemptsBeforeLockout,
+ },
+ Password = new PasswordOptions
+ {
+ RequireDigit = passwordConfiguration.RequireDigit,
+ RequiredLength = passwordConfiguration.RequiredLength,
+ RequireLowercase = passwordConfiguration.RequireLowercase,
+ RequireNonAlphanumeric = passwordConfiguration.RequireNonLetterOrDigit,
+ RequireUppercase = passwordConfiguration.RequireUppercase,
+ }
+ };
+
+ return Options.Create(identityOptions);
+ }
+ }
+}
diff --git a/src/Umbraco.Web/Editors/BackOfficeController.cs b/src/Umbraco.Web/Editors/BackOfficeController.cs
index b963871a58..3106d02dc8 100644
--- a/src/Umbraco.Web/Editors/BackOfficeController.cs
+++ b/src/Umbraco.Web/Editors/BackOfficeController.cs
@@ -11,6 +11,7 @@ using Umbraco.Core.Configuration;
using Umbraco.Core.Logging;
using Umbraco.Web.Mvc;
using Umbraco.Core.Services;
+using Umbraco.Web.Configuration;
using Umbraco.Web.Features;
using Umbraco.Web.Security;
using Constants = Umbraco.Core.Constants;
@@ -139,7 +140,7 @@ namespace Umbraco.Web.Editors
if (defaultResponse == null) throw new ArgumentNullException("defaultResponse");
if (externalSignInResponse == null) throw new ArgumentNullException("externalSignInResponse");
- ViewData.SetUmbracoPath(GlobalSettings.GetUmbracoMvcArea(_hostingEnvironment));
+ ViewData.SetUmbracoPath(ConfigModelConversions.ConvertGlobalSettings(GlobalSettings).GetUmbracoMvcArea(_hostingEnvironment));
//check if there is the TempData with the any token name specified, if so, assign to view bag and render the view
if (ViewData.FromTempData(TempData, ViewDataExtensions.TokenExternalSignInError) ||
@@ -254,7 +255,7 @@ namespace Umbraco.Web.Editors
var groups = Services.UserService.GetUserGroupsByAlias(autoLinkOptions.GetDefaultUserGroups(UmbracoContext, loginInfo));
var autoLinkUser = BackOfficeIdentityUser.CreateNew(
- GlobalSettings,
+ ConfigModelConversions.ConvertGlobalSettings(GlobalSettings),
loginInfo.Email,
loginInfo.Email,
autoLinkOptions.GetDefaultCulture(UmbracoContext, loginInfo));
diff --git a/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs b/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs
index 454338112c..ec8d7e5dd5 100644
--- a/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs
+++ b/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs
@@ -7,6 +7,7 @@ using System.Web;
using System.Web.Mvc;
using Umbraco.Core;
using Umbraco.Core.Configuration;
+using Umbraco.Web.Configuration;
using Umbraco.Web.Features;
using Umbraco.Web.HealthCheck;
using Umbraco.Web.Models.ContentEditing;
@@ -143,7 +144,7 @@ namespace Umbraco.Web.Editors
{
"umbracoSettings", new Dictionary
{
- {"umbracoPath", _globalSettings.GetBackOfficePath(_hostingEnvironment)},
+ {"umbracoPath", ConfigModelConversions.ConvertGlobalSettings(_globalSettings).GetBackOfficePath(_hostingEnvironment)},
{"mediaPath", _hostingEnvironment.ToAbsolute(globalSettings.UmbracoMediaPath).TrimEnd('/')},
{"appPluginsPath", _hostingEnvironment.ToAbsolute(Constants.SystemDirectories.AppPlugins).TrimEnd('/')},
{
@@ -167,8 +168,8 @@ namespace Umbraco.Web.Editors
{"cssPath", _hostingEnvironment.ToAbsolute(globalSettings.UmbracoCssPath).TrimEnd('/')},
{"allowPasswordReset", _securitySettings.AllowPasswordReset},
{"loginBackgroundImage", _contentSettings.LoginBackgroundImage},
- {"showUserInvite", EmailSender.CanSendRequiredEmail(globalSettings)},
- {"canSendRequiredEmail", EmailSender.CanSendRequiredEmail(globalSettings)},
+ {"showUserInvite", EmailSender.CanSendRequiredEmail(ConfigModelConversions.ConvertGlobalSettings(globalSettings))},
+ {"canSendRequiredEmail", EmailSender.CanSendRequiredEmail(ConfigModelConversions.ConvertGlobalSettings(globalSettings))},
{"showAllowSegmentationForDocumentTypes", false},
}
},
diff --git a/src/Umbraco.Web/Mvc/AreaRegistrationExtensions.cs b/src/Umbraco.Web/Mvc/AreaRegistrationExtensions.cs
index 118c53a7f0..eee675e9fd 100644
--- a/src/Umbraco.Web/Mvc/AreaRegistrationExtensions.cs
+++ b/src/Umbraco.Web/Mvc/AreaRegistrationExtensions.cs
@@ -10,6 +10,7 @@ using Umbraco.Core.Exceptions;
using Umbraco.Core.Hosting;
using Umbraco.Core.IO;
using Umbraco.Web.Composing;
+using Umbraco.Web.Configuration;
using Umbraco.Web.WebApi;
namespace Umbraco.Web.Mvc
@@ -60,7 +61,7 @@ namespace Umbraco.Web.Mvc
if (routes == null) throw new ArgumentNullException(nameof(routes));
if (defaultId == null) throw new ArgumentNullException(nameof(defaultId));
- var umbracoArea = globalSettings.GetUmbracoMvcArea(hostingEnvironment);
+ var umbracoArea = ConfigModelConversions.ConvertGlobalSettings(globalSettings).GetUmbracoMvcArea(hostingEnvironment);
//routes are explicitly named with controller names and IDs
var url = umbracoArea + "/" +
diff --git a/src/Umbraco.Web/Mvc/BackOfficeArea.cs b/src/Umbraco.Web/Mvc/BackOfficeArea.cs
index 156a896bb5..4a4202b42b 100644
--- a/src/Umbraco.Web/Mvc/BackOfficeArea.cs
+++ b/src/Umbraco.Web/Mvc/BackOfficeArea.cs
@@ -3,6 +3,7 @@ using Umbraco.Web.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.Hosting;
using Umbraco.Core.IO;
+using Umbraco.Web.Configuration;
using Umbraco.Web.Editors;
namespace Umbraco.Web.Mvc
@@ -50,6 +51,6 @@ namespace Umbraco.Web.Mvc
new[] {typeof (BackOfficeController).Namespace});
}
- public override string AreaName => _globalSettings.GetUmbracoMvcArea(_hostingEnvironment);
+ public override string AreaName => ConfigModelConversions.ConvertGlobalSettings(_globalSettings).GetUmbracoMvcArea(_hostingEnvironment);
}
}
diff --git a/src/Umbraco.Web/Mvc/UmbracoAuthorizeAttribute.cs b/src/Umbraco.Web/Mvc/UmbracoAuthorizeAttribute.cs
index b5c6185069..9fc58a208f 100644
--- a/src/Umbraco.Web/Mvc/UmbracoAuthorizeAttribute.cs
+++ b/src/Umbraco.Web/Mvc/UmbracoAuthorizeAttribute.cs
@@ -4,6 +4,7 @@ using System.Web.Mvc;
using Umbraco.Core;
using Umbraco.Web.Composing;
using Umbraco.Core.Configuration;
+using Umbraco.Web.Configuration;
using Umbraco.Web.Security;
namespace Umbraco.Web.Mvc
@@ -55,7 +56,7 @@ namespace Umbraco.Web.Mvc
{
if (redirectToUmbracoLogin)
{
- _redirectUrl = Current.Configs.Global().GetBackOfficePath(Current.HostingEnvironment).EnsureStartsWith("~");
+ _redirectUrl = ConfigModelConversions.ConvertGlobalSettings(Current.Configs.Global()).GetBackOfficePath(Current.HostingEnvironment).EnsureStartsWith("~");
}
}
diff --git a/src/Umbraco.Web/Runtime/WebInitialComponent.cs b/src/Umbraco.Web/Runtime/WebInitialComponent.cs
index dbd0a1fb3a..5ad51acbc0 100644
--- a/src/Umbraco.Web/Runtime/WebInitialComponent.cs
+++ b/src/Umbraco.Web/Runtime/WebInitialComponent.cs
@@ -11,6 +11,7 @@ using Umbraco.Core.Configuration;
using Umbraco.Core.Hosting;
using Umbraco.Core.Strings;
using Umbraco.Core.IO;
+using Umbraco.Web.Configuration;
using Umbraco.Web.Install;
using Umbraco.Web.Mvc;
using Umbraco.Web.WebApi;
@@ -117,7 +118,7 @@ namespace Umbraco.Web.Runtime
UmbracoApiControllerTypeCollection apiControllerTypes,
IHostingEnvironment hostingEnvironment)
{
- var umbracoPath = globalSettings.GetUmbracoMvcArea(hostingEnvironment);
+ var umbracoPath = ConfigModelConversions.ConvertGlobalSettings(globalSettings).GetUmbracoMvcArea(hostingEnvironment);
// create the front-end route
var defaultRoute = RouteTable.Routes.MapRoute(
@@ -154,7 +155,7 @@ namespace Umbraco.Web.Runtime
UmbracoApiControllerTypeCollection apiControllerTypes,
IHostingEnvironment hostingEnvironment)
{
- var umbracoPath = globalSettings.GetUmbracoMvcArea(hostingEnvironment);
+ var umbracoPath = ConfigModelConversions.ConvertGlobalSettings(globalSettings).GetUmbracoMvcArea(hostingEnvironment);
// need to find the plugin controllers and route them
var pluginControllers = surfaceControllerTypes.Concat(apiControllerTypes).ToArray();
diff --git a/src/Umbraco.Web/Security/BackOfficeOwinUserManager.cs b/src/Umbraco.Web/Security/BackOfficeOwinUserManager.cs
index 771c3239b6..92e4fca420 100644
--- a/src/Umbraco.Web/Security/BackOfficeOwinUserManager.cs
+++ b/src/Umbraco.Web/Security/BackOfficeOwinUserManager.cs
@@ -12,6 +12,7 @@ using Umbraco.Core.Mapping;
using Umbraco.Core.Security;
using Umbraco.Core.Services;
using Umbraco.Net;
+using Umbraco.Web.Configuration;
namespace Umbraco.Web.Security
{
@@ -20,7 +21,7 @@ namespace Umbraco.Web.Security
public const string OwinMarkerKey = "Umbraco.Web.Security.Identity.BackOfficeUserManagerMarker";
public BackOfficeOwinUserManager(
- IUserPasswordConfiguration passwordConfiguration,
+ IOptions passwordConfiguration,
IIpResolver ipResolver,
IUserStore store,
IOptions optionsAccessor,
@@ -30,9 +31,9 @@ namespace Umbraco.Web.Security
BackOfficeIdentityErrorDescriber errors,
IDataProtectionProvider dataProtectionProvider,
ILogger> logger)
- : base(ipResolver, store, optionsAccessor, null, userValidators, passwordValidators, keyNormalizer, errors, null, logger, passwordConfiguration)
+ : base(ipResolver, store, optionsAccessor, null, userValidators, passwordValidators, keyNormalizer, errors, null, logger, ConfigModelConversions.ConvertToOptionsOfUserPasswordConfigurationSettings(passwordConfiguration))
{
- PasswordConfiguration = passwordConfiguration;
+ PasswordConfiguration = ConfigModelConversions.ConvertToOptionsOfUserPasswordConfigurationSettings(passwordConfiguration).Value;
InitUserManager(this, dataProtectionProvider);
}
@@ -53,7 +54,7 @@ namespace Umbraco.Web.Security
IDataProtectionProvider dataProtectionProvider,
ILogger> logger)
{
- var store = new BackOfficeUserStore(userService, entityService, externalLoginService, globalSettings, mapper);
+ var store = new BackOfficeUserStore(userService, entityService, externalLoginService, ConfigModelConversions.ConvertGlobalSettings(globalSettings), mapper);
return Create(
passwordConfiguration,
@@ -103,7 +104,7 @@ namespace Umbraco.Web.Security
options.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromDays(30);
return new BackOfficeOwinUserManager(
- passwordConfiguration,
+ ConfigModelConversions.ConvertToOptionsOfBackOfficeIdentityOptions(passwordConfiguration),
ipResolver,
customUserStore,
new OptionsWrapper(options),
diff --git a/src/Umbraco.Web/Security/BackOfficeSignInManager.cs b/src/Umbraco.Web/Security/BackOfficeSignInManager.cs
index 021adaed97..c998b579a1 100644
--- a/src/Umbraco.Web/Security/BackOfficeSignInManager.cs
+++ b/src/Umbraco.Web/Security/BackOfficeSignInManager.cs
@@ -11,6 +11,7 @@ using Umbraco.Core;
using Umbraco.Core.BackOffice;
using Umbraco.Core.Configuration;
using Umbraco.Core.BackOffice;
+using Umbraco.Web.Configuration;
namespace Umbraco.Web.Security
{
@@ -78,7 +79,7 @@ namespace Umbraco.Web.Security
var user = await _userManager.FindByNameAsync(userName);
//if the user is null, create an empty one which can be used for auto-linking
- if (user == null) user = BackOfficeIdentityUser.CreateNew(_globalSettings, userName, null, _globalSettings.DefaultUILanguage);
+ if (user == null) user = BackOfficeIdentityUser.CreateNew(ConfigModelConversions.ConvertGlobalSettings(_globalSettings), userName, null, _globalSettings.DefaultUILanguage);
//check the password for the user, this will allow a developer to auto-link
//an account if they have specified an IBackOfficeUserPasswordChecker
diff --git a/src/Umbraco.Web/Security/GetUserSecondsMiddleWare.cs b/src/Umbraco.Web/Security/GetUserSecondsMiddleWare.cs
index 3ab37f0f70..f73f25f859 100644
--- a/src/Umbraco.Web/Security/GetUserSecondsMiddleWare.cs
+++ b/src/Umbraco.Web/Security/GetUserSecondsMiddleWare.cs
@@ -11,6 +11,7 @@ using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.Hosting;
using Umbraco.Core.IO;
using Umbraco.Core.Security;
+using Umbraco.Web.Configuration;
namespace Umbraco.Web.Security
{
@@ -53,7 +54,7 @@ namespace Umbraco.Web.Security
if (request.Uri.Scheme.InvariantStartsWith("http")
&& request.Uri.AbsolutePath.InvariantEquals(
- $"{_globalSettings.GetBackOfficePath(_hostingEnvironment)}/backoffice/UmbracoApi/Authentication/GetRemainingTimeoutSeconds"))
+ $"{ConfigModelConversions.ConvertGlobalSettings(_globalSettings).GetBackOfficePath(_hostingEnvironment)}/backoffice/UmbracoApi/Authentication/GetRemainingTimeoutSeconds"))
{
var cookie = _authOptions.CookieManager.GetRequestCookie(context, _security.AuthCookieName);
if (cookie.IsNullOrWhiteSpace() == false)
diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj
index 64fc7b5886..82af69a21c 100644
--- a/src/Umbraco.Web/Umbraco.Web.csproj
+++ b/src/Umbraco.Web/Umbraco.Web.csproj
@@ -148,6 +148,7 @@
+
diff --git a/src/Umbraco.Web/UmbracoApplication.cs b/src/Umbraco.Web/UmbracoApplication.cs
index 6334f96d4b..4cdcecc1ce 100644
--- a/src/Umbraco.Web/UmbracoApplication.cs
+++ b/src/Umbraco.Web/UmbracoApplication.cs
@@ -14,6 +14,7 @@ using Umbraco.Core.Hosting;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Web.Runtime;
+using Umbraco.Web.Configuration;
namespace Umbraco.Web
{
@@ -29,8 +30,8 @@ namespace Umbraco.Web
var dbProviderFactoryCreator = new UmbracoDbProviderFactoryCreator();
- var globalSettings = configs.Global();
- var connectionStrings = configs.ConnectionStrings();
+ var globalSettings = ConfigModelConversions.ConvertGlobalSettings(configs.Global());
+ var connectionStrings = ConfigModelConversions.ConvertConnectionStrings(configs.ConnectionStrings());
// Determine if we should use the sql main dom or the default
var appSettingMainDomLock = globalSettings.MainDomLock;
@@ -44,7 +45,7 @@ namespace Umbraco.Web
var requestCache = new HttpRequestAppCache(() => HttpContext.Current != null ? HttpContext.Current.Items : null);
var umbracoBootPermissionChecker = new AspNetUmbracoBootPermissionChecker();
- return new CoreRuntime(configs, umbracoVersion, ioHelper, logger, profiler, umbracoBootPermissionChecker, hostingEnvironment, backOfficeInfo, dbProviderFactoryCreator, mainDom,
+ return new CoreRuntime(globalSettings, connectionStrings, umbracoVersion, ioHelper, logger, profiler, umbracoBootPermissionChecker, hostingEnvironment, backOfficeInfo, dbProviderFactoryCreator, mainDom,
GetTypeFinder(hostingEnvironment, logger, profiler), requestCache);
}
diff --git a/src/Umbraco.Web/UmbracoApplicationBase.cs b/src/Umbraco.Web/UmbracoApplicationBase.cs
index 1c447b38aa..984f46bd60 100644
--- a/src/Umbraco.Web/UmbracoApplicationBase.cs
+++ b/src/Umbraco.Web/UmbracoApplicationBase.cs
@@ -16,6 +16,7 @@ using Umbraco.Core.Logging.Serilog;
using Umbraco.Core.Logging.Serilog.Enrichers;
using Umbraco.Net;
using Umbraco.Web.AspNet;
+using Umbraco.Web.Configuration;
using Umbraco.Web.Hosting;
using Umbraco.Web.Logging;
using Current = Umbraco.Web.Composing.Current;
@@ -44,7 +45,7 @@ namespace Umbraco.Web
Path.Combine(hostingEnvironment.ApplicationPhysicalPath, "App_Data\\Logs"),
Path.Combine(hostingEnvironment.ApplicationPhysicalPath, "config\\serilog.config"),
Path.Combine(hostingEnvironment.ApplicationPhysicalPath, "config\\serilog.user.config"));
- var ioHelper = new IOHelper(hostingEnvironment, globalSettings);
+ var ioHelper = new IOHelper(hostingEnvironment);
var logger = SerilogLogger.CreateWithDefaultConfiguration(hostingEnvironment, loggingConfiguration);
var configs = configFactory.Create();
@@ -127,7 +128,7 @@ namespace Umbraco.Web
///
protected virtual IRegister GetRegister(IGlobalSettings globalSettings)
{
- return RegisterFactory.Create(globalSettings);
+ return RegisterFactory.Create(ConfigModelConversions.ConvertGlobalSettings(globalSettings));
}
// events - in the order they trigger
@@ -160,7 +161,7 @@ namespace Umbraco.Web
var globalSettings = Umbraco.Composing.Current.Configs.Global();
- var umbracoVersion = new UmbracoVersion(globalSettings);
+ var umbracoVersion = new UmbracoVersion(ConfigModelConversions.ConvertGlobalSettings(globalSettings));
// create the register for the application, and boot
// the boot manager is responsible for registrations
diff --git a/src/Umbraco.Web/UmbracoContext.cs b/src/Umbraco.Web/UmbracoContext.cs
index ae1cf885b3..e94e0acc0b 100644
--- a/src/Umbraco.Web/UmbracoContext.cs
+++ b/src/Umbraco.Web/UmbracoContext.cs
@@ -5,6 +5,7 @@ using Umbraco.Core.Configuration;
using Umbraco.Core.Hosting;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Web.Composing;
+using Umbraco.Web.Configuration;
using Umbraco.Web.PublishedCache;
using Umbraco.Web.Routing;
using Umbraco.Web.Security;
@@ -181,7 +182,7 @@ namespace Umbraco.Web
{
var request = GetRequestFromContext();
if (request?.Url != null
- && request.Url.IsBackOfficeRequest(_globalSettings, _hostingEnvironment) == false
+ && request.Url.IsBackOfficeRequest(ConfigModelConversions.ConvertGlobalSettings(_globalSettings), _hostingEnvironment) == false
&& Security.CurrentUser != null)
{
var previewToken = _cookieManager.GetPreviewCookieValue(); // may be null or empty
diff --git a/src/Umbraco.Web/UmbracoInjectedModule.cs b/src/Umbraco.Web/UmbracoInjectedModule.cs
index ecb67c997d..a610d216a3 100644
--- a/src/Umbraco.Web/UmbracoInjectedModule.cs
+++ b/src/Umbraco.Web/UmbracoInjectedModule.cs
@@ -13,6 +13,7 @@ using Umbraco.Core.Logging;
using Umbraco.Web.Composing;
using Umbraco.Web.Routing;
using Umbraco.Web.Security;
+using Umbraco.Web.Configuration;
namespace Umbraco.Web
{
@@ -113,7 +114,7 @@ namespace Umbraco.Web
var umbracoContext = Current.UmbracoContext;
// re-write for the default back office path
- if (httpContext.Request.Url.IsDefaultBackOfficeRequest(_globalSettings, _hostingEnvironment))
+ if (httpContext.Request.Url.IsDefaultBackOfficeRequest(ConfigModelConversions.ConvertGlobalSettings(_globalSettings), _hostingEnvironment))
{
if (EnsureRuntime(httpContext, umbracoContext.OriginalRequestUrl))
RewriteToBackOfficeHandler(httpContext);
@@ -246,7 +247,7 @@ namespace Umbraco.Web
private void RewriteToBackOfficeHandler(HttpContextBase context)
{
// GlobalSettings.Path has already been through IOHelper.ResolveUrl() so it begins with / and vdir (if any)
- var rewritePath = _globalSettings.GetBackOfficePath(_hostingEnvironment).TrimEnd('/') + "/Default";
+ var rewritePath = ConfigModelConversions.ConvertGlobalSettings(_globalSettings).GetBackOfficePath(_hostingEnvironment).TrimEnd('/') + "/Default";
// rewrite the path to the path of the handler (i.e. /umbraco/RenderMvc)
context.RewritePath(rewritePath, "", "", false);
@@ -279,7 +280,7 @@ namespace Umbraco.Web
var query = pcr.Uri.Query.TrimStart('?');
// GlobalSettings.Path has already been through IOHelper.ResolveUrl() so it begins with / and vdir (if any)
- var rewritePath = _globalSettings.GetBackOfficePath(_hostingEnvironment).TrimEnd('/') + "/RenderMvc";
+ var rewritePath = ConfigModelConversions.ConvertGlobalSettings(_globalSettings).GetBackOfficePath(_hostingEnvironment).TrimEnd('/') + "/RenderMvc";
// rewrite the path to the path of the handler (i.e. /umbraco/RenderMvc)
context.RewritePath(rewritePath, "", query, false);
diff --git a/src/Umbraco.Web/WebApi/Filters/CheckIfUserTicketDataIsStaleAttribute.cs b/src/Umbraco.Web/WebApi/Filters/CheckIfUserTicketDataIsStaleAttribute.cs
index 09fd5e080c..bae6d00048 100644
--- a/src/Umbraco.Web/WebApi/Filters/CheckIfUserTicketDataIsStaleAttribute.cs
+++ b/src/Umbraco.Web/WebApi/Filters/CheckIfUserTicketDataIsStaleAttribute.cs
@@ -12,6 +12,7 @@ using Umbraco.Core.Security;
using Umbraco.Web.Security;
using Umbraco.Core.Mapping;
using Umbraco.Core.Models;
+using Umbraco.Web.Configuration;
namespace Umbraco.Web.WebApi.Filters
{
@@ -78,7 +79,7 @@ namespace Umbraco.Web.WebApi.Filters
() => user.Username != identity.Username,
() =>
{
- var culture = user.GetUserCulture(Current.Services.TextService, Current.Configs.Global());
+ var culture = user.GetUserCulture(Current.Services.TextService, ConfigModelConversions.ConvertGlobalSettings(Current.Configs.Global()));
return culture != null && culture.ToString() != identity.Culture;
},
() => user.AllowedSections.UnsortedSequenceEqual(identity.AllowedApplications) == false,