From a4e5029912611383f75a4380b27db8313d1e004f Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Thu, 10 Sep 2020 13:51:59 +0200 Subject: [PATCH] Refactored to remove Configs --- .../AspNetCoreConfigsFactory.cs | 48 ------ src/Umbraco.Configuration/ConfigsFactory.cs | 126 +++++++------- src/Umbraco.Core/Configuration/Configs.cs | 65 -------- .../Configuration/ConfigsExtensions.cs | 28 ---- .../Configuration/IConfigsFactory.cs | 10 -- .../LuceneFileSystemDirectoryFactory.cs | 8 +- .../UmbracoServiceProviderFactory.cs | 4 +- .../ConfigsExtensions.cs | 19 --- .../Umbraco.ModelsBuilder.Embedded.csproj | 1 - src/Umbraco.Tests.Common/TestHelperBase.cs | 4 +- .../Components/ComponentTests.cs | 1 - src/Umbraco.Tests/Models/VariationTests.cs | 8 +- .../Routing/RenderRouteHandlerTests.cs | 5 +- .../Runtimes/CoreRuntimeTests.cs | 9 - src/Umbraco.Tests/Runtimes/StandaloneTests.cs | 2 - src/Umbraco.Tests/TestHelpers/TestHelper.cs | 4 +- src/Umbraco.Tests/Testing/UmbracoTestBase.cs | 2 +- .../Controllers/BackOfficeController.cs | 5 +- .../UmbracoAuthorizedApiController.cs | 2 +- .../CheckIfUserTicketDataIsStaleAttribute.cs | 155 ++++++++++++++++++ .../SetAngularAntiForgeryTokensAttribute.cs | 43 +++-- .../Filters/HttpResponseExceptionFilter.cs | 1 - .../Filters/JsonExceptionFilterAttribute.cs | 2 +- .../AspNet/AspNetRequestAccessor.cs | 8 +- src/Umbraco.Web/Composing/Current.cs | 2 - .../Editors/AuthenticationController.cs | 6 +- .../Editors/BackOfficeController.cs | 9 +- src/Umbraco.Web/Mvc/RenderMvcController.cs | 4 +- .../Mvc/StatusCodeFilterAttribute.cs | 29 ---- .../Mvc/UmbracoAuthorizeAttribute.cs | 2 +- .../Mvc/UmbracoAuthorizedController.cs | 6 +- src/Umbraco.Web/Mvc/UmbracoController.cs | 8 +- .../Mvc/UmbracoRequireHttpsAttribute.cs | 4 +- .../Mvc/UmbracoViewPageOfTModel.cs | 16 +- src/Umbraco.Web/PublishedContentExtensions.cs | 10 +- .../Security/AppBuilderExtensions.cs | 3 +- .../Security/AuthenticationExtensions.cs | 13 +- .../Security/ExternalSignInAutoLinkOptions.cs | 2 +- src/Umbraco.Web/Umbraco.Web.csproj | 3 - src/Umbraco.Web/UmbracoApplicationBase.cs | 17 +- src/Umbraco.Web/UmbracoModule.cs | 2 +- src/Umbraco.Web/UmbracoWebService.cs | 3 +- .../CheckIfUserTicketDataIsStaleAttribute.cs | 128 --------------- .../SetAngularAntiForgeryTokensAttribute.cs | 59 ------- .../WebApi/UmbracoAuthorizedApiController.cs | 2 +- 45 files changed, 334 insertions(+), 554 deletions(-) delete mode 100644 src/Umbraco.Configuration/AspNetCoreConfigsFactory.cs delete mode 100644 src/Umbraco.Core/Configuration/Configs.cs delete mode 100644 src/Umbraco.Core/Configuration/ConfigsExtensions.cs delete mode 100644 src/Umbraco.Core/Configuration/IConfigsFactory.cs delete mode 100644 src/Umbraco.ModelsBuilder.Embedded/ConfigsExtensions.cs create mode 100644 src/Umbraco.Web.BackOffice/Filters/CheckIfUserTicketDataIsStaleAttribute.cs delete mode 100644 src/Umbraco.Web/Mvc/StatusCodeFilterAttribute.cs delete mode 100644 src/Umbraco.Web/WebApi/Filters/CheckIfUserTicketDataIsStaleAttribute.cs delete mode 100644 src/Umbraco.Web/WebApi/Filters/SetAngularAntiForgeryTokensAttribute.cs diff --git a/src/Umbraco.Configuration/AspNetCoreConfigsFactory.cs b/src/Umbraco.Configuration/AspNetCoreConfigsFactory.cs deleted file mode 100644 index f957074881..0000000000 --- a/src/Umbraco.Configuration/AspNetCoreConfigsFactory.cs +++ /dev/null @@ -1,48 +0,0 @@ -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 ?? throw new System.ArgumentNullException(nameof(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 HealthChecksSettings(_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(() => new HostingSettings(_configuration)); - configs.Add(() => new GlobalSettings(_configuration)); - configs.Add(() => new ImagingSettings(_configuration)); - - return configs; - } - } -} diff --git a/src/Umbraco.Configuration/ConfigsFactory.cs b/src/Umbraco.Configuration/ConfigsFactory.cs index be6cee2d0c..15378a5860 100644 --- a/src/Umbraco.Configuration/ConfigsFactory.cs +++ b/src/Umbraco.Configuration/ConfigsFactory.cs @@ -1,63 +1,63 @@ -using Umbraco.Configuration; -using Umbraco.Configuration.Implementations; -using Umbraco.Configuration.Legacy; -using Umbraco.Core.Configuration.HealthChecks; -using Umbraco.Core.Configuration.Legacy; -using Umbraco.Core.Configuration.UmbracoSettings; - -namespace Umbraco.Core.Configuration -{ - public class ConfigsFactory : IConfigsFactory - { - public IHostingSettings HostingSettings { get; } = new HostingSettings(); - public ICoreDebugSettings CoreDebugSettings { get; } = new CoreDebugSettings(); - public IIndexCreatorSettings IndexCreatorSettings { get; } = new IndexCreatorSettings(); - public INuCacheSettings NuCacheSettings { get; } = new NuCacheSettings(); - public ITypeFinderSettings TypeFinderSettings { get; } = new TypeFinderSettings(); - public IRuntimeSettings RuntimeSettings { get; } = new RuntimeSettings(); - public IActiveDirectorySettings ActiveDirectorySettings { get; } = new ActiveDirectorySettings(); - public IExceptionFilterSettings ExceptionFilterSettings { get; } = new ExceptionFilterSettings(); - public ITourSettings TourSettings { get; } = new TourSettings(); - public ILoggingSettings LoggingSettings { get; } = new LoggingSettings(); - public IKeepAliveSettings KeepAliveSettings { get; } = new KeepAliveSettings(); - public IWebRoutingSettings WebRoutingSettings { get; } = new WebRoutingSettings(); - public IRequestHandlerSettings RequestHandlerSettings { get; } = new RequestHandlerSettings(); - public ISecuritySettings SecuritySettings { get; } = new SecuritySettings(); - public IUserPasswordConfiguration UserPasswordConfigurationSettings { get; } = new UserPasswordConfigurationSettings(); - public IMemberPasswordConfiguration MemberPasswordConfigurationSettings { get; } = new MemberPasswordConfigurationSettings(); - public IContentSettings ContentSettings { get; } = new ContentSettings(); - public IGlobalSettings GlobalSettings { get; } = new GlobalSettings(); - public IHealthChecksSettings HealthChecksSettings { get; } = new HealthChecksSettings(); - public IConnectionStrings ConnectionStrings { get; } = new ConnectionStrings(); - public IModelsBuilderConfig ModelsBuilderConfig { get; } = new ModelsBuilderConfig(); - - public Configs Create() - { - var configs = new Configs(); - - configs.Add(() => GlobalSettings); - configs.Add(() => HostingSettings); - configs.Add(() => HealthChecksSettings); - configs.Add(() => CoreDebugSettings); - configs.Add(() => ConnectionStrings); - configs.Add(() => ModelsBuilderConfig); - configs.Add(() => IndexCreatorSettings); - configs.Add(() => NuCacheSettings); - configs.Add(() => TypeFinderSettings); - configs.Add(() => RuntimeSettings); - configs.Add(() => ActiveDirectorySettings); - configs.Add(() => ExceptionFilterSettings); - configs.Add(() => TourSettings); - configs.Add(() => LoggingSettings); - configs.Add(() => KeepAliveSettings); - configs.Add(() => WebRoutingSettings); - configs.Add(() => RequestHandlerSettings); - configs.Add(() => SecuritySettings); - configs.Add(() => UserPasswordConfigurationSettings); - configs.Add(() => MemberPasswordConfigurationSettings); - configs.Add(() => ContentSettings); - - return configs; - } - } -} +// using Umbraco.Configuration; +// using Umbraco.Configuration.Implementations; +// using Umbraco.Configuration.Legacy; +// using Umbraco.Core.Configuration.HealthChecks; +// using Umbraco.Core.Configuration.Legacy; +// using Umbraco.Core.Configuration.UmbracoSettings; +// +// namespace Umbraco.Core.Configuration +// { +// public class ConfigsFactory : IConfigsFactory +// { +// public IHostingSettings HostingSettings { get; } = new HostingSettings(); +// public ICoreDebugSettings CoreDebugSettings { get; } = new CoreDebugSettings(); +// public IIndexCreatorSettings IndexCreatorSettings { get; } = new IndexCreatorSettings(); +// public INuCacheSettings NuCacheSettings { get; } = new NuCacheSettings(); +// public ITypeFinderSettings TypeFinderSettings { get; } = new TypeFinderSettings(); +// public IRuntimeSettings RuntimeSettings { get; } = new RuntimeSettings(); +// public IActiveDirectorySettings ActiveDirectorySettings { get; } = new ActiveDirectorySettings(); +// public IExceptionFilterSettings ExceptionFilterSettings { get; } = new ExceptionFilterSettings(); +// public ITourSettings TourSettings { get; } = new TourSettings(); +// public ILoggingSettings LoggingSettings { get; } = new LoggingSettings(); +// public IKeepAliveSettings KeepAliveSettings { get; } = new KeepAliveSettings(); +// public IWebRoutingSettings WebRoutingSettings { get; } = new WebRoutingSettings(); +// public IRequestHandlerSettings RequestHandlerSettings { get; } = new RequestHandlerSettings(); +// public ISecuritySettings SecuritySettings { get; } = new SecuritySettings(); +// public IUserPasswordConfiguration UserPasswordConfigurationSettings { get; } = new UserPasswordConfigurationSettings(); +// public IMemberPasswordConfiguration MemberPasswordConfigurationSettings { get; } = new MemberPasswordConfigurationSettings(); +// public IContentSettings ContentSettings { get; } = new ContentSettings(); +// public IGlobalSettings GlobalSettings { get; } = new GlobalSettings(); +// public IHealthChecksSettings HealthChecksSettings { get; } = new HealthChecksSettings(); +// public IConnectionStrings ConnectionStrings { get; } = new ConnectionStrings(); +// public IModelsBuilderConfig ModelsBuilderConfig { get; } = new ModelsBuilderConfig(); +// +// public Configs Create() +// { +// var configs = new Configs(); +// +// configs.Add(() => GlobalSettings); +// configs.Add(() => HostingSettings); +// configs.Add(() => HealthChecksSettings); +// configs.Add(() => CoreDebugSettings); +// configs.Add(() => ConnectionStrings); +// configs.Add(() => ModelsBuilderConfig); +// configs.Add(() => IndexCreatorSettings); +// configs.Add(() => NuCacheSettings); +// configs.Add(() => TypeFinderSettings); +// configs.Add(() => RuntimeSettings); +// configs.Add(() => ActiveDirectorySettings); +// configs.Add(() => ExceptionFilterSettings); +// configs.Add(() => TourSettings); +// configs.Add(() => LoggingSettings); +// configs.Add(() => KeepAliveSettings); +// configs.Add(() => WebRoutingSettings); +// configs.Add(() => RequestHandlerSettings); +// configs.Add(() => SecuritySettings); +// configs.Add(() => UserPasswordConfigurationSettings); +// configs.Add(() => MemberPasswordConfigurationSettings); +// configs.Add(() => ContentSettings); +// +// return configs; +// } +// } +// } diff --git a/src/Umbraco.Core/Configuration/Configs.cs b/src/Umbraco.Core/Configuration/Configs.cs deleted file mode 100644 index 821ee308f0..0000000000 --- a/src/Umbraco.Core/Configuration/Configs.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System; -using System.Collections.Generic; -using Umbraco.Core.Composing; - -namespace Umbraco.Core.Configuration -{ - /// - /// Represents Umbraco configurations. - /// - /// - /// During composition, use composition.Configs. When running, either inject the required configuration, - /// or use Current.Configs. - /// - public class Configs - { - private readonly Dictionary> _configs = new Dictionary>(); - private Dictionary> _registerings = new Dictionary>(); - - /// - /// Gets a configuration. - /// - public TConfig GetConfig() - where TConfig : class - { - if (!_configs.TryGetValue(typeof(TConfig), out var configFactory)) - throw new InvalidOperationException($"No configuration of type {typeof(TConfig)} has been added."); - - return (TConfig) configFactory.Value; - } - - /// - /// Adds a configuration, provided by a factory. - /// - public void Add(Func configFactory) - where TConfig : class - { - // make sure it is not too late - if (_registerings == null) - throw new InvalidOperationException("Configurations have already been registered."); - - var typeOfConfig = typeof(TConfig); - - var lazyConfigFactory = _configs[typeOfConfig] = new Lazy(configFactory); - _registerings[typeOfConfig] = register => register.Register(_ => (TConfig) lazyConfigFactory.Value, Lifetime.Singleton); - } - - /// - /// Registers configurations in a register. - /// - public void RegisterWith(IRegister register) - { - // do it only once - if (_registerings == null) - throw new InvalidOperationException("Configurations have already been registered."); - - register.Register(this); - - foreach (var registering in _registerings.Values) - registering(register); - - // no need to keep them around - _registerings = null; - } - } -} diff --git a/src/Umbraco.Core/Configuration/ConfigsExtensions.cs b/src/Umbraco.Core/Configuration/ConfigsExtensions.cs deleted file mode 100644 index 0f63903320..0000000000 --- a/src/Umbraco.Core/Configuration/ConfigsExtensions.cs +++ /dev/null @@ -1,28 +0,0 @@ -using Umbraco.Core.Configuration; -using Umbraco.Core.Configuration.Grid; -using Umbraco.Core.Configuration.HealthChecks; -using Umbraco.Core.Configuration.UmbracoSettings; - -namespace Umbraco.Core -{ - /// - /// Provides extension methods for the class. - /// - public static class ConfigsExtensions - { - - public static IGlobalSettings Global(this Configs configs) - => configs.GetConfig(); - - - public static IConnectionStrings ConnectionStrings(this Configs configs) - => configs.GetConfig(); - - public static ISecuritySettings Security(this Configs configs) - => configs.GetConfig(); - - public static IWebRoutingSettings WebRouting(this Configs configs) - => configs.GetConfig(); - - } -} diff --git a/src/Umbraco.Core/Configuration/IConfigsFactory.cs b/src/Umbraco.Core/Configuration/IConfigsFactory.cs deleted file mode 100644 index dd2459b88c..0000000000 --- a/src/Umbraco.Core/Configuration/IConfigsFactory.cs +++ /dev/null @@ -1,10 +0,0 @@ -using Umbraco.Core.IO; -using Umbraco.Core.Logging; - -namespace Umbraco.Core.Configuration -{ - public interface IConfigsFactory - { - Configs Create(); - } -} diff --git a/src/Umbraco.Examine.Lucene/LuceneFileSystemDirectoryFactory.cs b/src/Umbraco.Examine.Lucene/LuceneFileSystemDirectoryFactory.cs index 8f3bf8bf69..32c441ab28 100644 --- a/src/Umbraco.Examine.Lucene/LuceneFileSystemDirectoryFactory.cs +++ b/src/Umbraco.Examine.Lucene/LuceneFileSystemDirectoryFactory.cs @@ -6,6 +6,8 @@ using Lucene.Net.Store; using System.IO; using System; using Examine.LuceneEngine.Directories; +using Microsoft.Extensions.Options; +using Umbraco.Core.Configuration.Models; namespace Umbraco.Examine { @@ -14,13 +16,13 @@ namespace Umbraco.Examine { private readonly ITypeFinder _typeFinder; private readonly IHostingEnvironment _hostingEnvironment; - private readonly IIndexCreatorSettings _settings; + private readonly IndexCreatorSettings _settings; - public LuceneFileSystemDirectoryFactory(ITypeFinder typeFinder, IHostingEnvironment hostingEnvironment, IIndexCreatorSettings settings) + public LuceneFileSystemDirectoryFactory(ITypeFinder typeFinder, IHostingEnvironment hostingEnvironment, IOptions settings) { _typeFinder = typeFinder; _hostingEnvironment = hostingEnvironment; - _settings = settings; + _settings = settings.Value; } public Lucene.Net.Store.Directory CreateDirectory(string indexName) => CreateFileSystemLuceneDirectory(indexName); diff --git a/src/Umbraco.Infrastructure/Composing/UmbracoServiceProviderFactory.cs b/src/Umbraco.Infrastructure/Composing/UmbracoServiceProviderFactory.cs index 51bd5e7b14..6bd0d796ec 100644 --- a/src/Umbraco.Infrastructure/Composing/UmbracoServiceProviderFactory.cs +++ b/src/Umbraco.Infrastructure/Composing/UmbracoServiceProviderFactory.cs @@ -88,8 +88,8 @@ namespace Umbraco.Core.Composing // after cross wiring, configure "Current" Current.Initialize( _container.GetInstance(), - _container.GetInstance(), - _container.GetInstance(), + _container.GetInstance>().Value, + _container.GetInstance>().Value, _container.GetInstance(), _container.GetInstance(), _container.GetInstance(), diff --git a/src/Umbraco.ModelsBuilder.Embedded/ConfigsExtensions.cs b/src/Umbraco.ModelsBuilder.Embedded/ConfigsExtensions.cs deleted file mode 100644 index d625c754c5..0000000000 --- a/src/Umbraco.ModelsBuilder.Embedded/ConfigsExtensions.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Umbraco.Core.Configuration; - -namespace Umbraco.ModelsBuilder.Embedded -{ - /// - /// Provides extension methods for the class. - /// - public static class ConfigsExtensions - { - /// - /// Gets the models builder configuration. - /// - /// Getting the models builder configuration freezes its state, - /// and any attempt at modifying the configuration using the Setup method - /// will be ignored. - public static IModelsBuilderConfig ModelsBuilder(this Configs configs) - => configs.GetConfig(); - } -} diff --git a/src/Umbraco.ModelsBuilder.Embedded/Umbraco.ModelsBuilder.Embedded.csproj b/src/Umbraco.ModelsBuilder.Embedded/Umbraco.ModelsBuilder.Embedded.csproj index 87c20eca72..608770b124 100644 --- a/src/Umbraco.ModelsBuilder.Embedded/Umbraco.ModelsBuilder.Embedded.csproj +++ b/src/Umbraco.ModelsBuilder.Embedded/Umbraco.ModelsBuilder.Embedded.csproj @@ -58,7 +58,6 @@ - diff --git a/src/Umbraco.Tests.Common/TestHelperBase.cs b/src/Umbraco.Tests.Common/TestHelperBase.cs index 803b6c0cae..234767e8af 100644 --- a/src/Umbraco.Tests.Common/TestHelperBase.cs +++ b/src/Umbraco.Tests.Common/TestHelperBase.cs @@ -46,11 +46,11 @@ namespace Umbraco.Tests.Common return new TypeLoader(Mock.Of(), Mock.Of(), new DirectoryInfo(IOHelper.MapPath("~/App_Data/TEMP")), Mock.Of()); } - public Configs GetConfigs() => GetConfigsFactory().Create(); + // public Configs GetConfigs() => GetConfigsFactory().Create(); public abstract IBackOfficeInfo GetBackOfficeInfo(); - public IConfigsFactory GetConfigsFactory() => new ConfigsFactory(); + //public IConfigsFactory GetConfigsFactory() => new ConfigsFactory(); /// /// Gets the working directory of the test project. diff --git a/src/Umbraco.Tests/Components/ComponentTests.cs b/src/Umbraco.Tests/Components/ComponentTests.cs index de99ba445f..e74516dab7 100644 --- a/src/Umbraco.Tests/Components/ComponentTests.cs +++ b/src/Umbraco.Tests/Components/ComponentTests.cs @@ -25,7 +25,6 @@ namespace Umbraco.Tests.Components private static readonly List Composed = new List(); private static readonly List Initialized = new List(); private static readonly List Terminated = new List(); - private static readonly Configs Configs = TestHelper.GetConfigs(); private static IFactory MockFactory(Action> setup = null) { diff --git a/src/Umbraco.Tests/Models/VariationTests.cs b/src/Umbraco.Tests/Models/VariationTests.cs index e67cb10cf1..1c7445a901 100644 --- a/src/Umbraco.Tests/Models/VariationTests.cs +++ b/src/Umbraco.Tests/Models/VariationTests.cs @@ -33,9 +33,9 @@ namespace Umbraco.Tests.Models Current.Reset(); - var configs = TestHelper.GetConfigs(); - configs.Add(() => SettingsForTests.DefaultGlobalSettings); - configs.Add(SettingsForTests.GenerateMockContentSettings); + // var configs = TestHelper.GetConfigs(); + // configs.Add(() => SettingsForTests.DefaultGlobalSettings); + // configs.Add(SettingsForTests.GenerateMockContentSettings); _factory = Mock.Of(); @@ -65,7 +65,7 @@ namespace Umbraco.Tests.Models .Setup(x => x.GetInstance(It.IsAny())) .Returns(x => { - if (x == typeof(Configs)) return configs; + //if (x == typeof(Configs)) return configs; if (x == typeof(PropertyEditorCollection)) return propertyEditors; if (x == typeof(ServiceContext)) return serviceContext; if (x == typeof(ILocalizedTextService)) return serviceContext.LocalizationService; diff --git a/src/Umbraco.Tests/Routing/RenderRouteHandlerTests.cs b/src/Umbraco.Tests/Routing/RenderRouteHandlerTests.cs index 3328114576..5082919dc1 100644 --- a/src/Umbraco.Tests/Routing/RenderRouteHandlerTests.cs +++ b/src/Umbraco.Tests/Routing/RenderRouteHandlerTests.cs @@ -2,6 +2,7 @@ using System.Linq; using System.Web.Mvc; using System.Web.Routing; +using Microsoft.Extensions.Options; using Moq; using NUnit.Framework; using Umbraco.Core; @@ -153,7 +154,7 @@ namespace Umbraco.Tests.Routing var handler = new RenderRouteHandler(umbracoContext, new TestControllerFactory(umbracoContextAccessor, Mock.Of(), context => { - return new CustomDocumentController(Factory.GetInstance(), + return new CustomDocumentController(Factory.GetInstance>(), umbracoContextAccessor, Factory.GetInstance(), Factory.GetInstance(), @@ -194,7 +195,7 @@ namespace Umbraco.Tests.Routing /// public class CustomDocumentController : RenderMvcController { - public CustomDocumentController(IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ServiceContext services, AppCaches appCaches, IProfilingLogger profilingLogger) + public CustomDocumentController(IOptions globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ServiceContext services, AppCaches appCaches, IProfilingLogger profilingLogger) : base(globalSettings, umbracoContextAccessor, services, appCaches, profilingLogger) { } diff --git a/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs b/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs index 4de83eed4e..1b58c93534 100644 --- a/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs +++ b/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs @@ -100,15 +100,6 @@ namespace Umbraco.Tests.Runtimes private static readonly IContentSettings _contentSettings = SettingsForTests.GenerateMockContentSettings(); private static readonly IWebRoutingSettings _settings = SettingsForTests.GenerateMockWebRoutingSettings(); - private static Configs GetConfigs() - { - var configs = new ConfigsFactory().Create(); - configs.Add(() => _globalSettings); - configs.Add(() => _contentSettings); - configs.Add(() => _hostingSettings); - return configs; - } - public IRuntime Runtime { get; private set; } protected override IRuntime GetRuntime(GlobalSettings globalSettings, ConnectionStrings connectionStrings, IUmbracoVersion umbracoVersion, IIOHelper ioHelper, ILogger logger, IProfiler profiler, IHostingEnvironment hostingEnvironment, IBackOfficeInfo backOfficeInfo) diff --git a/src/Umbraco.Tests/Runtimes/StandaloneTests.cs b/src/Umbraco.Tests/Runtimes/StandaloneTests.cs index 5f0fc607c6..7c834d7cf3 100644 --- a/src/Umbraco.Tests/Runtimes/StandaloneTests.cs +++ b/src/Umbraco.Tests/Runtimes/StandaloneTests.cs @@ -76,7 +76,6 @@ namespace Umbraco.Tests.Runtimes var umbracoVersion = TestHelper.GetUmbracoVersion(); var backOfficeInfo = TestHelper.GetBackOfficeInfo(); var runtimeState = new RuntimeState(globalSettings, umbracoVersion, databaseFactory, logger); - var configs = TestHelper.GetConfigs(); var variationContextAccessor = TestHelper.VariationContextAccessor; // create the register and the composition @@ -285,7 +284,6 @@ namespace Umbraco.Tests.Runtimes Mock.Get(runtimeState).Setup(x => x.Level).Returns(RuntimeLevel.Run); var mainDom = Mock.Of(); Mock.Get(mainDom).Setup(x => x.IsMainDom).Returns(true); - var configs = TestHelper.GetConfigs(); // create the register and the composition var register = TestHelper.GetRegister(); diff --git a/src/Umbraco.Tests/TestHelpers/TestHelper.cs b/src/Umbraco.Tests/TestHelpers/TestHelper.cs index 2131393b85..92767498bc 100644 --- a/src/Umbraco.Tests/TestHelpers/TestHelper.cs +++ b/src/Umbraco.Tests/TestHelpers/TestHelper.cs @@ -78,11 +78,11 @@ namespace Umbraco.Tests.TestHelpers public static TypeLoader GetMockedTypeLoader() => _testHelperInternal.GetMockedTypeLoader(); - public static Configs GetConfigs() => _testHelperInternal.GetConfigs(); + //public static Configs GetConfigs() => _testHelperInternal.GetConfigs(); public static IBackOfficeInfo GetBackOfficeInfo() => _testHelperInternal.GetBackOfficeInfo(); - public static IConfigsFactory GetConfigsFactory() => _testHelperInternal.GetConfigsFactory(); + // public static IConfigsFactory GetConfigsFactory() => _testHelperInternal.GetConfigsFactory(); /// /// Gets the working directory of the test project. diff --git a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs index 3d2a4496a6..ccac76fc88 100644 --- a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs +++ b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs @@ -191,7 +191,7 @@ namespace Umbraco.Tests.Testing Composition = new Composition(register, typeLoader, proflogger, ComponentTests.MockRuntimeState(RuntimeLevel.Run), TestHelper.IOHelper, AppCaches.NoCache); - TestHelper.GetConfigs().RegisterWith(register); + //TestHelper.GetConfigs().RegisterWith(register); Composition.RegisterUnique(IOHelper); diff --git a/src/Umbraco.Web.BackOffice/Controllers/BackOfficeController.cs b/src/Umbraco.Web.BackOffice/Controllers/BackOfficeController.cs index e3480984fd..141578cccd 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/BackOfficeController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/BackOfficeController.cs @@ -30,7 +30,8 @@ using Constants = Umbraco.Core.Constants; namespace Umbraco.Web.BackOffice.Controllers { - + //[UmbracoRequireHttps] //TODO Reintroduce + [DisableBrowserCache] [PluginController(Constants.Web.Mvc.BackOfficeArea)] public class BackOfficeController : Controller { @@ -80,7 +81,7 @@ namespace Umbraco.Web.BackOffice.Controllers { var viewPath = Path.Combine(_globalSettings.UmbracoPath , Constants.Web.Mvc.BackOfficeArea, nameof(Default) + ".cshtml") .Replace("\\", "/"); // convert to forward slashes since it's a virtual path - + return await RenderDefaultOrProcessExternalLoginAsync( () => View(viewPath), () => View(viewPath)); diff --git a/src/Umbraco.Web.BackOffice/Controllers/UmbracoAuthorizedApiController.cs b/src/Umbraco.Web.BackOffice/Controllers/UmbracoAuthorizedApiController.cs index c3e1a71b86..85c92d1139 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/UmbracoAuthorizedApiController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/UmbracoAuthorizedApiController.cs @@ -18,7 +18,7 @@ namespace Umbraco.Web.BackOffice.Controllers [UmbracoAuthorize] [DisableBrowserCache] [UmbracoWebApiRequireHttps] - //[CheckIfUserTicketDataIsStale] //TODO reintroduce + [CheckIfUserTicketDataIsStale] //[UnhandedExceptionLoggerConfiguration] //TODO reintroduce //[EnableDetailedErrors] //TODO reintroduce public abstract class UmbracoAuthorizedApiController : UmbracoApiController diff --git a/src/Umbraco.Web.BackOffice/Filters/CheckIfUserTicketDataIsStaleAttribute.cs b/src/Umbraco.Web.BackOffice/Filters/CheckIfUserTicketDataIsStaleAttribute.cs new file mode 100644 index 0000000000..c3bc1a56db --- /dev/null +++ b/src/Umbraco.Web.BackOffice/Filters/CheckIfUserTicketDataIsStaleAttribute.cs @@ -0,0 +1,155 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Claims; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Filters; +using Microsoft.Extensions.Options; +using Umbraco.Core; +using Umbraco.Core.BackOffice; +using Umbraco.Core.Cache; +using Umbraco.Core.Configuration.Models; +using Umbraco.Core.Mapping; +using Umbraco.Core.Models; +using Umbraco.Core.Models.Membership; +using Umbraco.Core.Services; +using Umbraco.Extensions; +using Umbraco.Web.BackOffice.Security; +using Umbraco.Web.Common.Security; + +namespace Umbraco.Web.BackOffice.Filters +{ + internal sealed class CheckIfUserTicketDataIsStaleAttribute : TypeFilterAttribute + { + public CheckIfUserTicketDataIsStaleAttribute() : base(typeof(CheckIfUserTicketDataIsStaleFilter)) + { + } + + private class CheckIfUserTicketDataIsStaleFilter : IAsyncActionFilter + { + private readonly IRequestCache _requestCache; + private readonly UmbracoMapper _umbracoMapper; + private readonly IUserService _userService; + private readonly IEntityService _entityService; + private readonly ILocalizedTextService _localizedTextService; + private readonly IOptions _globalSettings; + private readonly BackOfficeSignInManager _backOfficeSignInManager; + private readonly IBackOfficeAntiforgery _backOfficeAntiforgery; + + public CheckIfUserTicketDataIsStaleFilter( + IRequestCache requestCache, + UmbracoMapper umbracoMapper, + IUserService userService, + IEntityService entityService, + ILocalizedTextService localizedTextService, + IOptions globalSettings, + BackOfficeSignInManager backOfficeSignInManager, + IBackOfficeAntiforgery backOfficeAntiforgery) + { + _requestCache = requestCache; + _umbracoMapper = umbracoMapper; + _userService = userService; + _entityService = entityService; + _localizedTextService = localizedTextService; + _globalSettings = globalSettings; + _backOfficeSignInManager = backOfficeSignInManager; + _backOfficeAntiforgery = backOfficeAntiforgery; + } + + + public async Task OnActionExecutionAsync(ActionExecutingContext actionContext, ActionExecutionDelegate next) + { + await CheckStaleData(actionContext); + + await next(); + + await CheckStaleData(actionContext); + + //we need new tokens and append the custom header if changes have been made + if (!(_requestCache.Get(nameof(CheckIfUserTicketDataIsStaleFilter)) is null)) + return; + + var tokenFilter = + new SetAngularAntiForgeryTokensAttribute.SetAngularAntiForgeryTokensFilter(_backOfficeAntiforgery, + _globalSettings); + await tokenFilter.OnActionExecutionAsync(actionContext, () => Task.FromResult(new ActionExecutedContext(actionContext, new List(), null))); + + //add the header + AppendUserModifiedHeaderAttribute.AppendHeader(actionContext); + } + + + + private async Task CheckStaleData(ActionExecutingContext actionContext) + { + if (actionContext == null + || actionContext.HttpContext.Request == null + || actionContext.HttpContext.User == null + || actionContext.HttpContext.User.Identity == null) + { + return; + } + + //don't execute if it's already been done + if (!(_requestCache.Get(nameof(CheckIfUserTicketDataIsStaleFilter)) is null)) + return; + + var identity = actionContext.HttpContext.User.Identity as UmbracoBackOfficeIdentity; + if (identity == null) return; + + var userId = identity.Id.TryConvertTo(); + if (userId == false) return; + + var user = _userService.GetUserById(userId.Result); + if (user == null) return; + + //a list of checks to execute, if any of them pass then we resync + var checks = new Func[] + { + () => user.Username != identity.Username, + () => + { + var culture = user.GetUserCulture(_localizedTextService, _globalSettings.Value); + return culture != null && culture.ToString() != identity.Culture; + }, + () => user.AllowedSections.UnsortedSequenceEqual(identity.AllowedApplications) == false, + () => user.Groups.Select(x => x.Alias).UnsortedSequenceEqual(identity.Roles) == false, + () => + { + var startContentIds = user.CalculateContentStartNodeIds(_entityService); + return startContentIds.UnsortedSequenceEqual(identity.StartContentNodes) == false; + }, + () => + { + var startMediaIds = user.CalculateMediaStartNodeIds(_entityService); + return startMediaIds.UnsortedSequenceEqual(identity.StartMediaNodes) == false; + } + }; + + if (checks.Any(check => check())) + { + await ReSync(user, actionContext); + } + } + + /// + /// This will update the current request IPrincipal to be correct and re-create the auth ticket + /// + /// + /// + /// + private async Task ReSync(IUser user, ActionExecutingContext actionContext) + { + var backOfficeIdentityUser = _umbracoMapper.Map(user); + await _backOfficeSignInManager.SignInAsync(backOfficeIdentityUser, isPersistent: true); + + //ensure the remainder of the request has the correct principal set + actionContext.HttpContext.SetPrincipalForRequest(ClaimsPrincipal.Current); + + //flag that we've made changes + _requestCache.Set(nameof(CheckIfUserTicketDataIsStaleFilter), true); + } + } + } +} diff --git a/src/Umbraco.Web.BackOffice/Filters/SetAngularAntiForgeryTokensAttribute.cs b/src/Umbraco.Web.BackOffice/Filters/SetAngularAntiForgeryTokensAttribute.cs index c993766a6b..aaf23d1799 100644 --- a/src/Umbraco.Web.BackOffice/Filters/SetAngularAntiForgeryTokensAttribute.cs +++ b/src/Umbraco.Web.BackOffice/Filters/SetAngularAntiForgeryTokensAttribute.cs @@ -18,7 +18,7 @@ namespace Umbraco.Extensions { } - private class SetAngularAntiForgeryTokensFilter : IAsyncActionFilter + internal class SetAngularAntiForgeryTokensFilter : IAsyncActionFilter { private readonly IBackOfficeAntiforgery _antiforgery; private readonly GlobalSettings _globalSettings; @@ -55,24 +55,31 @@ namespace Umbraco.Extensions //We need to set 2 cookies: one is the cookie value that angular will use to set a header value on each request, // the 2nd is the validation value generated by the anti-forgery helper that we use to validate the header token against. - context.HttpContext.Response.Cookies.Append( - Constants.Web.AngularCookieName, headerToken, - new Microsoft.AspNetCore.Http.CookieOptions - { - Path = "/", - //must be js readable - HttpOnly = false, - Secure = _globalSettings.UseHttps - }); + if (!(headerToken is null)) + { + context.HttpContext.Response.Cookies.Append( + Constants.Web.AngularCookieName, headerToken, + new Microsoft.AspNetCore.Http.CookieOptions + { + Path = "/", + //must be js readable + HttpOnly = false, + Secure = _globalSettings.UseHttps + }); + } + + if (!(cookieToken is null)) + { + context.HttpContext.Response.Cookies.Append( + Constants.Web.CsrfValidationCookieName, cookieToken, + new Microsoft.AspNetCore.Http.CookieOptions + { + Path = "/", + HttpOnly = true, + Secure = _globalSettings.UseHttps + }); + } - context.HttpContext.Response.Cookies.Append( - Constants.Web.CsrfValidationCookieName, cookieToken, - new Microsoft.AspNetCore.Http.CookieOptions - { - Path = "/", - HttpOnly = true, - Secure = _globalSettings.UseHttps - }); } } diff --git a/src/Umbraco.Web.Common/Filters/HttpResponseExceptionFilter.cs b/src/Umbraco.Web.Common/Filters/HttpResponseExceptionFilter.cs index 46bfd6cdfa..6a5f6eaa47 100644 --- a/src/Umbraco.Web.Common/Filters/HttpResponseExceptionFilter.cs +++ b/src/Umbraco.Web.Common/Filters/HttpResponseExceptionFilter.cs @@ -1,6 +1,5 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Filters; -using Umbraco.Core.Exceptions; using Umbraco.Web.Common.Exceptions; namespace Umbraco.Web.Common.Filters diff --git a/src/Umbraco.Web.Common/Filters/JsonExceptionFilterAttribute.cs b/src/Umbraco.Web.Common/Filters/JsonExceptionFilterAttribute.cs index 1ff8ede0ab..3d25016c15 100644 --- a/src/Umbraco.Web.Common/Filters/JsonExceptionFilterAttribute.cs +++ b/src/Umbraco.Web.Common/Filters/JsonExceptionFilterAttribute.cs @@ -25,7 +25,7 @@ namespace Umbraco.Web.Common.Filters public void OnException(ExceptionContext filterContext) { - if (filterContext.Exception != null) + if (filterContext.Exception != null && !filterContext.ExceptionHandled) { filterContext.HttpContext.Response.StatusCode = (int) HttpStatusCode.InternalServerError; diff --git a/src/Umbraco.Web/AspNet/AspNetRequestAccessor.cs b/src/Umbraco.Web/AspNet/AspNetRequestAccessor.cs index aa2cba6949..ae38dc2c05 100644 --- a/src/Umbraco.Web/AspNet/AspNetRequestAccessor.cs +++ b/src/Umbraco.Web/AspNet/AspNetRequestAccessor.cs @@ -1,5 +1,7 @@ using System; using System.Collections.Generic; +using Microsoft.Extensions.Options; +using Umbraco.Core.Configuration.Models; using Umbraco.Core.Configuration.UmbracoSettings; using Umbraco.Web.Routing; @@ -8,13 +10,13 @@ namespace Umbraco.Web.AspNet public class AspNetRequestAccessor : IRequestAccessor { private readonly IHttpContextAccessor _httpContextAccessor; - private readonly IWebRoutingSettings _webRoutingSettings; + private readonly WebRoutingSettings _webRoutingSettings; private readonly ISet _applicationUrls = new HashSet(); private Uri _currentApplicationUrl; - public AspNetRequestAccessor(IHttpContextAccessor httpContextAccessor, IWebRoutingSettings webRoutingSettings) + public AspNetRequestAccessor(IHttpContextAccessor httpContextAccessor, IOptions webRoutingSettings) { _httpContextAccessor = httpContextAccessor; - _webRoutingSettings = webRoutingSettings; + _webRoutingSettings = webRoutingSettings.Value; UmbracoModule.EndRequest += OnEndRequest; UmbracoModule.RouteAttempt += OnRouteAttempt; diff --git a/src/Umbraco.Web/Composing/Current.cs b/src/Umbraco.Web/Composing/Current.cs index 68120947df..9646a10dc4 100644 --- a/src/Umbraco.Web/Composing/Current.cs +++ b/src/Umbraco.Web/Composing/Current.cs @@ -213,8 +213,6 @@ namespace Umbraco.Web.Composing public static TypeLoader TypeLoader => Factory.GetInstance(); - public static Configs Configs => Factory.GetInstance(); - public static UrlSegmentProviderCollection UrlSegmentProviders => Factory.GetInstance(); public static CacheRefresherCollection CacheRefreshers => Factory.GetInstance(); diff --git a/src/Umbraco.Web/Editors/AuthenticationController.cs b/src/Umbraco.Web/Editors/AuthenticationController.cs index c3eedaab3b..5254b91672 100644 --- a/src/Umbraco.Web/Editors/AuthenticationController.cs +++ b/src/Umbraco.Web/Editors/AuthenticationController.cs @@ -111,7 +111,7 @@ namespace Umbraco.Web.Editors /// Used to retrieve the 2FA providers for code submission /// /// - [SetAngularAntiForgeryTokens] + // [SetAngularAntiForgeryTokens] //TODO reintroduce when migrated to netcore public async Task> Get2FAProviders() { var userId = await SignInManager.GetVerifiedUserIdAsync(); @@ -127,7 +127,7 @@ namespace Umbraco.Web.Editors return userFactors; } - [SetAngularAntiForgeryTokens] + // [SetAngularAntiForgeryTokens] //TODO reintroduce when migrated to netcore public async Task PostSend2FACode([FromBody]string provider) { if (provider.IsNullOrWhiteSpace()) @@ -148,7 +148,7 @@ namespace Umbraco.Web.Editors return Ok(); } - [SetAngularAntiForgeryTokens] + // [SetAngularAntiForgeryTokens] //TODO reintroduce when migrated to netcore public async Task PostVerify2FACode(Verify2FACodeModel model) { if (ModelState.IsValid == false) diff --git a/src/Umbraco.Web/Editors/BackOfficeController.cs b/src/Umbraco.Web/Editors/BackOfficeController.cs index 34d6e49563..7e0cd7062b 100644 --- a/src/Umbraco.Web/Editors/BackOfficeController.cs +++ b/src/Umbraco.Web/Editors/BackOfficeController.cs @@ -4,10 +4,12 @@ using System.Threading.Tasks; using System.Web; using System.Web.Mvc; using Microsoft.AspNetCore.Identity; +using Microsoft.Extensions.Options; using Microsoft.Owin.Security; using Umbraco.Core; using Umbraco.Core.Cache; using Umbraco.Core.Configuration; +using Umbraco.Core.Configuration.Models; using Umbraco.Core.Logging; using Umbraco.Web.Mvc; using Umbraco.Core.Services; @@ -40,7 +42,7 @@ namespace Umbraco.Web.Editors public BackOfficeController( UmbracoFeatures features, - IGlobalSettings globalSettings, + IOptions globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ServiceContext services, AppCaches appCaches, @@ -140,7 +142,7 @@ namespace Umbraco.Web.Editors if (defaultResponse == null) throw new ArgumentNullException("defaultResponse"); if (externalSignInResponse == null) throw new ArgumentNullException("externalSignInResponse"); - ViewData.SetUmbracoPath(ConfigModelConversionsFromLegacy.ConvertGlobalSettings(GlobalSettings).GetUmbracoMvcArea(_hostingEnvironment)); + ViewData.SetUmbracoPath(GlobalSettings.Value.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,8 +256,7 @@ namespace Umbraco.Web.Editors var groups = Services.UserService.GetUserGroupsByAlias(autoLinkOptions.GetDefaultUserGroups(UmbracoContext, loginInfo)); - var autoLinkUser = BackOfficeIdentityUser.CreateNew( - ConfigModelConversionsFromLegacy.ConvertGlobalSettings(GlobalSettings), + var autoLinkUser = BackOfficeIdentityUser.CreateNew(GlobalSettings.Value, loginInfo.Email, loginInfo.Email, autoLinkOptions.GetDefaultCulture(UmbracoContext, loginInfo)); diff --git a/src/Umbraco.Web/Mvc/RenderMvcController.cs b/src/Umbraco.Web/Mvc/RenderMvcController.cs index 7286f52c64..be17bf85c2 100644 --- a/src/Umbraco.Web/Mvc/RenderMvcController.cs +++ b/src/Umbraco.Web/Mvc/RenderMvcController.cs @@ -1,7 +1,9 @@ using System; using System.Web.Mvc; +using Microsoft.Extensions.Options; using Umbraco.Core.Cache; using Umbraco.Core.Configuration; +using Umbraco.Core.Configuration.Models; using Umbraco.Core.Logging; using Umbraco.Core.Models.PublishedContent; using Umbraco.Core.Services; @@ -25,7 +27,7 @@ namespace Umbraco.Web.Mvc ActionInvoker = new RenderActionInvoker(); } - public RenderMvcController(IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ServiceContext services, AppCaches appCaches, IProfilingLogger profilingLogger) + public RenderMvcController(IOptions globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ServiceContext services, AppCaches appCaches, IProfilingLogger profilingLogger) : base(globalSettings, umbracoContextAccessor, services, appCaches, profilingLogger) { ActionInvoker = new RenderActionInvoker(); diff --git a/src/Umbraco.Web/Mvc/StatusCodeFilterAttribute.cs b/src/Umbraco.Web/Mvc/StatusCodeFilterAttribute.cs deleted file mode 100644 index 727c29b93c..0000000000 --- a/src/Umbraco.Web/Mvc/StatusCodeFilterAttribute.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System.Net; -using System.Web.Mvc; -using Umbraco.Core; -using Umbraco.Web.Composing; - -namespace Umbraco.Web.Mvc -{ - /// - /// Forces the response to have a specific http status code - /// - /// Migrated already to .Net Core - internal class StatusCodeResultAttribute : ActionFilterAttribute - { - private readonly HttpStatusCode _statusCode; - - public StatusCodeResultAttribute(HttpStatusCode statusCode) - { - _statusCode = statusCode; - } - - public override void OnActionExecuted(ActionExecutedContext filterContext) - { - base.OnActionExecuted(filterContext); - - filterContext.HttpContext.Response.StatusCode = (int)_statusCode; - filterContext.HttpContext.Response.TrySkipIisCustomErrors = Current.Configs.WebRouting().TrySkipIisCustomErrors; - } - } -} diff --git a/src/Umbraco.Web/Mvc/UmbracoAuthorizeAttribute.cs b/src/Umbraco.Web/Mvc/UmbracoAuthorizeAttribute.cs index d9baa25823..ee3596b7a5 100644 --- a/src/Umbraco.Web/Mvc/UmbracoAuthorizeAttribute.cs +++ b/src/Umbraco.Web/Mvc/UmbracoAuthorizeAttribute.cs @@ -56,7 +56,7 @@ namespace Umbraco.Web.Mvc { if (redirectToUmbracoLogin) { - _redirectUrl = ConfigModelConversionsFromLegacy.ConvertGlobalSettings(Current.Configs.Global()).GetBackOfficePath(Current.HostingEnvironment).EnsureStartsWith("~"); + _redirectUrl = ConfigModelConversionsFromLegacy.ConvertGlobalSettings(/*Current.Configs.Global()*/ null).GetBackOfficePath(Current.HostingEnvironment).EnsureStartsWith("~"); } } diff --git a/src/Umbraco.Web/Mvc/UmbracoAuthorizedController.cs b/src/Umbraco.Web/Mvc/UmbracoAuthorizedController.cs index 0724cd138d..6471656c42 100644 --- a/src/Umbraco.Web/Mvc/UmbracoAuthorizedController.cs +++ b/src/Umbraco.Web/Mvc/UmbracoAuthorizedController.cs @@ -1,5 +1,7 @@ -using Umbraco.Core.Cache; +using Microsoft.Extensions.Options; +using Umbraco.Core.Cache; using Umbraco.Core.Configuration; +using Umbraco.Core.Configuration.Models; using Umbraco.Core.Logging; using Umbraco.Core.Persistence; using Umbraco.Core.Services; @@ -21,7 +23,7 @@ namespace Umbraco.Web.Mvc { } - protected UmbracoAuthorizedController(IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ServiceContext services, AppCaches appCaches, IProfilingLogger profilingLogger) + protected UmbracoAuthorizedController(IOptions globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ServiceContext services, AppCaches appCaches, IProfilingLogger profilingLogger) : base(globalSettings, umbracoContextAccessor, services, appCaches, profilingLogger) { } diff --git a/src/Umbraco.Web/Mvc/UmbracoController.cs b/src/Umbraco.Web/Mvc/UmbracoController.cs index 9cfd93ba9d..940a9521aa 100644 --- a/src/Umbraco.Web/Mvc/UmbracoController.cs +++ b/src/Umbraco.Web/Mvc/UmbracoController.cs @@ -1,12 +1,14 @@ using System; using System.Web; using System.Web.Mvc; +using Microsoft.Extensions.Options; using Microsoft.Owin; using Umbraco.Core.Cache; using Umbraco.Web.Composing; using Umbraco.Core.Configuration; using Umbraco.Core.Logging; using Umbraco.Core; +using Umbraco.Core.Configuration.Models; using Umbraco.Core.Services; using Umbraco.Web.Security; @@ -23,7 +25,7 @@ namespace Umbraco.Web.Mvc /// /// Gets or sets the Umbraco context. /// - public IGlobalSettings GlobalSettings { get; } + public IOptions GlobalSettings { get; } /// /// Gets the Umbraco context. @@ -69,7 +71,7 @@ namespace Umbraco.Web.Mvc protected UmbracoController() : this( - Current.Factory.GetInstance(), + Current.Factory.GetInstance>(), Current.Factory.GetInstance(), Current.Factory.GetInstance(), Current.Factory.GetInstance(), @@ -78,7 +80,7 @@ namespace Umbraco.Web.Mvc { } - protected UmbracoController(IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ServiceContext services, AppCaches appCaches, IProfilingLogger profilingLogger) + protected UmbracoController(IOptions globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ServiceContext services, AppCaches appCaches, IProfilingLogger profilingLogger) { GlobalSettings = globalSettings; UmbracoContextAccessor = umbracoContextAccessor; diff --git a/src/Umbraco.Web/Mvc/UmbracoRequireHttpsAttribute.cs b/src/Umbraco.Web/Mvc/UmbracoRequireHttpsAttribute.cs index 9a0aa6b600..b88d1c0736 100644 --- a/src/Umbraco.Web/Mvc/UmbracoRequireHttpsAttribute.cs +++ b/src/Umbraco.Web/Mvc/UmbracoRequireHttpsAttribute.cs @@ -16,7 +16,7 @@ namespace Umbraco.Web.Mvc protected override void HandleNonHttpsRequest(AuthorizationContext filterContext) { // If Umbraco.Core.UseHttps is set, let base method handle redirect. Otherwise, we don't care. - if (Current.Configs.Global().UseHttps) + if (/*Current.Configs.Global().UseHttps*/ false) { base.HandleNonHttpsRequest(filterContext); } @@ -29,7 +29,7 @@ namespace Umbraco.Web.Mvc public override void OnAuthorization(AuthorizationContext filterContext) { // If umbracoSSL is set, let base method handle checking for HTTPS. Otherwise, we don't care. - if (Current.Configs.Global().UseHttps) + if (/*Current.Configs.Global().UseHttps*/ false) { base.OnAuthorization(filterContext); } diff --git a/src/Umbraco.Web/Mvc/UmbracoViewPageOfTModel.cs b/src/Umbraco.Web/Mvc/UmbracoViewPageOfTModel.cs index a687e7c9cd..4a651fd04a 100644 --- a/src/Umbraco.Web/Mvc/UmbracoViewPageOfTModel.cs +++ b/src/Umbraco.Web/Mvc/UmbracoViewPageOfTModel.cs @@ -3,9 +3,11 @@ using System.Text; using System.Web; using System.Web.Mvc; using System.Web.WebPages; +using Microsoft.Extensions.Options; using Umbraco.Core; using Umbraco.Core.Cache; using Umbraco.Core.Configuration; +using Umbraco.Core.Configuration.Models; using Umbraco.Core.Configuration.UmbracoSettings; using Umbraco.Core.Models.PublishedContent; using Umbraco.Core.Services; @@ -22,8 +24,8 @@ namespace Umbraco.Web.Mvc /// public abstract class UmbracoViewPage : WebViewPage { - private readonly IGlobalSettings _globalSettings; - private readonly IContentSettings _contentSettings; + private readonly GlobalSettings _globalSettings; + private readonly ContentSettings _contentSettings; private IUmbracoContext _umbracoContext; private UmbracoHelper _helper; @@ -105,18 +107,18 @@ namespace Umbraco.Web.Mvc : this( Current.Factory.GetInstance(), Current.Factory.GetInstance(), - Current.Factory.GetInstance(), - Current.Factory.GetInstance() + Current.Factory.GetInstance>(), + Current.Factory.GetInstance>() ) { } - protected UmbracoViewPage(ServiceContext services, AppCaches appCaches, IGlobalSettings globalSettings, IContentSettings contentSettings) + protected UmbracoViewPage(ServiceContext services, AppCaches appCaches, IOptions globalSettings, IOptions contentSettings) { Services = services; AppCaches = appCaches; - _globalSettings = globalSettings ?? throw new ArgumentNullException(nameof(globalSettings)); - _contentSettings = contentSettings ?? throw new ArgumentNullException(nameof(contentSettings)); + _globalSettings = globalSettings.Value; + _contentSettings = contentSettings.Value; } // view logic below: diff --git a/src/Umbraco.Web/PublishedContentExtensions.cs b/src/Umbraco.Web/PublishedContentExtensions.cs index 1dbe6ac556..e132b8fcdd 100644 --- a/src/Umbraco.Web/PublishedContentExtensions.cs +++ b/src/Umbraco.Web/PublishedContentExtensions.cs @@ -73,8 +73,10 @@ namespace Umbraco.Web { return content.IsAllowedTemplate( Current.Services.ContentTypeService, - Current.Configs.WebRouting().DisableAlternativeTemplates, + /*Current.Configs.WebRouting().DisableAlternativeTemplates, Current.Configs.WebRouting().ValidateAlternativeTemplates, + TODO*/ + false, false, templateId); } @@ -83,8 +85,10 @@ namespace Umbraco.Web return content.IsAllowedTemplate( Current.Services.FileService, Current.Services.ContentTypeService, - Current.Configs.WebRouting().DisableAlternativeTemplates, - Current.Configs.WebRouting().ValidateAlternativeTemplates, + /*Current.Configs.WebRouting().DisableAlternativeTemplates, + Current.Configs.WebRouting().ValidateAlternativeTemplates, + TODO*/ + false, false, templateAlias); } diff --git a/src/Umbraco.Web/Security/AppBuilderExtensions.cs b/src/Umbraco.Web/Security/AppBuilderExtensions.cs index ac5434aa4e..562c46d5e1 100644 --- a/src/Umbraco.Web/Security/AppBuilderExtensions.cs +++ b/src/Umbraco.Web/Security/AppBuilderExtensions.cs @@ -8,6 +8,7 @@ using Owin; using Umbraco.Core; using Umbraco.Core.Cache; using Umbraco.Core.Configuration; +using Umbraco.Core.Configuration.Models; using Umbraco.Core.Hosting; using Umbraco.Web.Composing; using Constants = Umbraco.Core.Constants; @@ -68,7 +69,7 @@ namespace Umbraco.Web.Security CookiePath = "/", CookieSecure = globalSettings.UseHttps ? CookieSecureOption.Always : CookieSecureOption.SameAsRequest, CookieHttpOnly = true, - CookieDomain = Current.Configs.Security().AuthCookieDomain + CookieDomain = new SecuritySettings().AuthCookieDomain // TODO inject settings }, stage); return app; diff --git a/src/Umbraco.Web/Security/AuthenticationExtensions.cs b/src/Umbraco.Web/Security/AuthenticationExtensions.cs index 2b8ba2ddfb..343579fb11 100644 --- a/src/Umbraco.Web/Security/AuthenticationExtensions.cs +++ b/src/Umbraco.Web/Security/AuthenticationExtensions.cs @@ -13,6 +13,7 @@ using Microsoft.Owin.Security; using Newtonsoft.Json; using Umbraco.Core; using Umbraco.Core.BackOffice; +using Umbraco.Core.Configuration.Models; using Umbraco.Extensions; using Umbraco.Web.Composing; using Constants = Umbraco.Core.Constants; @@ -68,7 +69,7 @@ namespace Umbraco.Web.Security if (ex is FormatException || ex is JsonReaderException) { // this will occur if the cookie data is invalid - + } else { @@ -104,7 +105,7 @@ namespace Umbraco.Web.Security /// /// This will return the current back office identity. /// - /// + /// /// /// Returns the current back office identity if an admin is authenticated otherwise null /// @@ -151,7 +152,7 @@ namespace Umbraco.Web.Security public static AuthenticationTicket GetUmbracoAuthTicket(this HttpContextBase http) { if (http == null) throw new ArgumentNullException(nameof(http)); - return GetAuthTicket(http, Current.Configs.Security().AuthCookieName); + return GetAuthTicket(http, /*Current.Configs.Security() TODO*/new SecuritySettings().AuthCookieName); } internal static AuthenticationTicket GetUmbracoAuthTicket(this HttpContext http) @@ -163,7 +164,7 @@ namespace Umbraco.Web.Security public static AuthenticationTicket GetUmbracoAuthTicket(this IOwinContext ctx) { if (ctx == null) throw new ArgumentNullException(nameof(ctx)); - return GetAuthTicket(ctx, Current.Configs.Security().AuthCookieName); + return GetAuthTicket(ctx, /*Current.Configs.Security() TODO*/new SecuritySettings().AuthCookieName); } private static AuthenticationTicket GetAuthTicket(this IOwinContext owinCtx, string cookieName) @@ -215,7 +216,7 @@ namespace Umbraco.Web.Security catch (Exception) { // occurs when decryption fails - + return null; } } @@ -236,6 +237,6 @@ namespace Umbraco.Web.Security return secureDataFormat.Unprotect(formsCookie); } - + } } diff --git a/src/Umbraco.Web/Security/ExternalSignInAutoLinkOptions.cs b/src/Umbraco.Web/Security/ExternalSignInAutoLinkOptions.cs index fc84cd270d..72b3f0abe0 100644 --- a/src/Umbraco.Web/Security/ExternalSignInAutoLinkOptions.cs +++ b/src/Umbraco.Web/Security/ExternalSignInAutoLinkOptions.cs @@ -23,7 +23,7 @@ namespace Umbraco.Web.Security { _defaultUserGroups = defaultUserGroups ?? new[] { Constants.Security.EditorGroupAlias }; _autoLinkExternalAccount = autoLinkExternalAccount; - _defaultCulture = defaultCulture ?? Current.Configs.Global().DefaultUILanguage; + _defaultCulture = defaultCulture ?? /*Current.Configs.Global().DefaultUILanguage TODO */ "en-US"; } private readonly string[] _defaultUserGroups; diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 5d663b64c2..e6c58770c0 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -176,7 +176,6 @@ - @@ -244,7 +243,6 @@ - @@ -298,7 +296,6 @@ - diff --git a/src/Umbraco.Web/UmbracoApplicationBase.cs b/src/Umbraco.Web/UmbracoApplicationBase.cs index 330f64cced..f40a230ae5 100644 --- a/src/Umbraco.Web/UmbracoApplicationBase.cs +++ b/src/Umbraco.Web/UmbracoApplicationBase.cs @@ -10,7 +10,9 @@ using Umbraco.Core; using Umbraco.Core.Cache; using Umbraco.Core.Composing; using Umbraco.Core.Configuration; +using Umbraco.Core.Configuration.Legacy; using Umbraco.Core.Configuration.Models; +using Umbraco.Core.Configuration.UmbracoSettings; using Umbraco.Core.Hosting; using Umbraco.Core.IO; using Umbraco.Core.Logging; @@ -22,6 +24,7 @@ using Umbraco.Web.Hosting; using Umbraco.Web.Logging; using ConnectionStrings = Umbraco.Core.Configuration.Models.ConnectionStrings; using Current = Umbraco.Web.Composing.Current; +using GlobalSettings = Umbraco.Core.Configuration.Models.GlobalSettings; namespace Umbraco.Web { @@ -40,11 +43,12 @@ namespace Umbraco.Web { if (!Umbraco.Composing.Current.IsInitialized) { - var configFactory = new ConfigsFactory(); + //var configFactory = new ConfigsFactory(); - var hostingSettings = configFactory.HostingSettings; - var globalSettings = configFactory.GlobalSettings; - var securitySettings = configFactory.SecuritySettings; + IHostingSettings hostingSettings = null; + IGlobalSettings globalSettings = null; + ISecuritySettings securitySettings = null; + IWebRoutingSettings webRoutingSettings = null; var hostingEnvironment = new AspNetHostingEnvironment(hostingSettings); var loggingConfiguration = new LoggingConfiguration( @@ -54,10 +58,7 @@ namespace Umbraco.Web var ioHelper = new IOHelper(hostingEnvironment); var logger = SerilogLogger.CreateWithDefaultConfiguration(hostingEnvironment, loggingConfiguration); - var configs = configFactory.Create(); - - - var backOfficeInfo = new AspNetBackOfficeInfo(globalSettings, ioHelper, logger, configFactory.WebRoutingSettings); + var backOfficeInfo = new AspNetBackOfficeInfo(globalSettings, ioHelper, logger, webRoutingSettings); var profiler = GetWebProfiler(hostingEnvironment); Umbraco.Composing.Current.Initialize(logger, ConfigModelConversionsFromLegacy.ConvertSecuritySettings(securitySettings), diff --git a/src/Umbraco.Web/UmbracoModule.cs b/src/Umbraco.Web/UmbracoModule.cs index 2dffe13851..98b6feb9b1 100644 --- a/src/Umbraco.Web/UmbracoModule.cs +++ b/src/Umbraco.Web/UmbracoModule.cs @@ -75,7 +75,7 @@ namespace Umbraco.Web else if (pcr.Is404) { response.StatusCode = 404; - response.TrySkipIisCustomErrors = Current.Configs.WebRouting().TrySkipIisCustomErrors; + response.TrySkipIisCustomErrors = /*Current.Configs.WebRouting().TrySkipIisCustomErrors; TODO */ false; if (response.TrySkipIisCustomErrors == false) logger.Warn("Status code is 404 yet TrySkipIisCustomErrors is false - IIS will take over."); diff --git a/src/Umbraco.Web/UmbracoWebService.cs b/src/Umbraco.Web/UmbracoWebService.cs index 916ab5ad8e..b8d69f5b62 100644 --- a/src/Umbraco.Web/UmbracoWebService.cs +++ b/src/Umbraco.Web/UmbracoWebService.cs @@ -6,6 +6,7 @@ using System.Web.Services; using Umbraco.Core; using Umbraco.Core.Cache; using Umbraco.Core.Configuration; +using Umbraco.Core.Configuration.Legacy; using Umbraco.Core.Logging; using Umbraco.Core.Persistence; using Umbraco.Core.Services; @@ -31,7 +32,7 @@ namespace Umbraco.Web } protected UmbracoWebService() - : this(Current.ProfilingLogger, Current.UmbracoContextAccessor, Current.Services, Current.Configs.Global()) + : this(Current.ProfilingLogger, Current.UmbracoContextAccessor, Current.Services, new GlobalSettings()) { } diff --git a/src/Umbraco.Web/WebApi/Filters/CheckIfUserTicketDataIsStaleAttribute.cs b/src/Umbraco.Web/WebApi/Filters/CheckIfUserTicketDataIsStaleAttribute.cs deleted file mode 100644 index ee057408e9..0000000000 --- a/src/Umbraco.Web/WebApi/Filters/CheckIfUserTicketDataIsStaleAttribute.cs +++ /dev/null @@ -1,128 +0,0 @@ -using System; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using System.Web.Http.Controllers; -using System.Web.Http.Filters; -using Umbraco.Core; -using Umbraco.Core.BackOffice; -using Umbraco.Core.Mapping; -using Umbraco.Core.Models; -using Umbraco.Core.Models.Membership; -using Umbraco.Infrastructure.Configuration; -using Umbraco.Web.Composing; -using Umbraco.Web.Security; - -namespace Umbraco.Web.WebApi.Filters -{ - /// - /// This filter will check if the current Principal/Identity assigned to the request has stale data in it compared - /// to what is persisted for the current user and will update the current auth ticket with the correct data if required and output - /// a custom response header for the UI to be notified of it. - /// - /// - /// This could/should be created as a filter on the BackOfficeCookieAuthenticationProvider just like the SecurityStampValidator does - /// - public sealed class CheckIfUserTicketDataIsStaleAttribute : ActionFilterAttribute - { - // this is an attribute - no choice - private UmbracoMapper Mapper => Current.Mapper; - - public override async Task OnActionExecutingAsync(HttpActionContext actionContext, CancellationToken cancellationToken) - { - await CheckStaleData(actionContext); - } - - public override async Task OnActionExecutedAsync(HttpActionExecutedContext actionExecutedContext, CancellationToken cancellationToken) - { - await CheckStaleData(actionExecutedContext.ActionContext); - - //we need new tokens and append the custom header if changes have been made - if (actionExecutedContext.ActionContext.Request.Properties.ContainsKey(typeof(CheckIfUserTicketDataIsStaleAttribute).Name)) - { - var tokenFilter = new SetAngularAntiForgeryTokensAttribute(); - tokenFilter.OnActionExecuted(actionExecutedContext); - - //add the header - AppendUserModifiedHeaderAttribute.AppendHeader(actionExecutedContext); - } - } - - private async Task CheckStaleData(HttpActionContext actionContext) - { - if (actionContext == null - || actionContext.Request == null - || actionContext.RequestContext == null - || actionContext.RequestContext.Principal == null - || actionContext.RequestContext.Principal.Identity == null) - { - return; - } - - //don't execute if it's already been done - if (actionContext.Request.Properties.ContainsKey(typeof(CheckIfUserTicketDataIsStaleAttribute).Name)) - return; - - var identity = actionContext.RequestContext.Principal.Identity as UmbracoBackOfficeIdentity; - if (identity == null) return; - - var userId = identity.Id.TryConvertTo(); - if (userId == false) return; - - var user = Current.Services.UserService.GetUserById(userId.Result); - if (user == null) return; - - //a list of checks to execute, if any of them pass then we resync - var checks = new Func[] - { - () => user.Username != identity.Username, - () => - { - var culture = user.GetUserCulture(Current.Services.TextService, ConfigModelConversionsFromLegacy.ConvertGlobalSettings(Current.Configs.Global())); - return culture != null && culture.ToString() != identity.Culture; - }, - () => user.AllowedSections.UnsortedSequenceEqual(identity.AllowedApplications) == false, - () => user.Groups.Select(x => x.Alias).UnsortedSequenceEqual(identity.Roles) == false, - () => - { - var startContentIds = user.CalculateContentStartNodeIds(Current.Services.EntityService); - return startContentIds.UnsortedSequenceEqual(identity.StartContentNodes) == false; - }, - () => - { - var startMediaIds = user.CalculateMediaStartNodeIds(Current.Services.EntityService); - return startMediaIds.UnsortedSequenceEqual(identity.StartMediaNodes) == false; - } - }; - - if (checks.Any(check => check())) - { - await ReSync(user, actionContext); - } - } - - /// - /// This will update the current request IPrincipal to be correct and re-create the auth ticket - /// - /// - /// - /// - private async Task ReSync(IUser user, HttpActionContext actionContext) - { - var owinCtx = actionContext.Request.TryGetOwinContext(); - if (owinCtx) - { - var signInManager = owinCtx.Result.GetBackOfficeSignInManager(); - - var backOfficeIdentityUser = Mapper.Map(user); - await signInManager.SignInAsync(backOfficeIdentityUser, isPersistent: true, rememberBrowser: false); - - //ensure the remainder of the request has the correct principal set - actionContext.Request.SetPrincipalForRequest(owinCtx.Result.Request.User); - - //flag that we've made changes - actionContext.Request.Properties[typeof(CheckIfUserTicketDataIsStaleAttribute).Name] = true; - } - } - } -} diff --git a/src/Umbraco.Web/WebApi/Filters/SetAngularAntiForgeryTokensAttribute.cs b/src/Umbraco.Web/WebApi/Filters/SetAngularAntiForgeryTokensAttribute.cs deleted file mode 100644 index dadf2367b6..0000000000 --- a/src/Umbraco.Web/WebApi/Filters/SetAngularAntiForgeryTokensAttribute.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System.Linq; -using System.Net; -using System.Net.Http; -using System.Net.Http.Headers; -using System.Web.Http.Filters; -using Umbraco.Core; -using Umbraco.Web.Composing; - -namespace Umbraco.Web.WebApi.Filters -{ - /// - /// A filter to set the csrf cookie token based on angular conventions - /// - public sealed class SetAngularAntiForgeryTokensAttribute : ActionFilterAttribute - { - public override void OnActionExecuted(HttpActionExecutedContext context) - { - if (context.Response == null) return; - - //DO not set the token cookies if the request has failed!! - if (context.Response.StatusCode != HttpStatusCode.OK) return; - - //don't need to set the cookie if they already exist and they are valid - if (context.Request.Headers.GetCookies(Constants.Web.AngularCookieName).Any() - && context.Request.Headers.GetCookies(Constants.Web.CsrfValidationCookieName).Any()) - { - //if they are not valid for some strange reason - we need to continue setting valid ones - string failedReason; - if (AngularAntiForgeryHelper.ValidateHeaders(context.Request.Headers, out failedReason)) - { - return; - } - } - - string cookieToken, headerToken; - AngularAntiForgeryHelper.GetTokens(out cookieToken, out headerToken); - - //We need to set 2 cookies: one is the cookie value that angular will use to set a header value on each request, - // the 2nd is the validation value generated by the anti-forgery helper that we use to validate the header token against. - - var angularCookie = new CookieHeaderValue(Constants.Web.AngularCookieName, headerToken) - { - Path = "/", - //must be js readable - HttpOnly = false, - Secure = Current.Configs.Global().UseHttps - }; - - var validationCookie = new CookieHeaderValue(Constants.Web.CsrfValidationCookieName, cookieToken) - { - Path = "/", - HttpOnly = true, - Secure = Current.Configs.Global().UseHttps - }; - - context.Response.Headers.AddCookies(new[] { angularCookie, validationCookie }); - } - } -} diff --git a/src/Umbraco.Web/WebApi/UmbracoAuthorizedApiController.cs b/src/Umbraco.Web/WebApi/UmbracoAuthorizedApiController.cs index 48b3de44fd..015cb3c6bc 100644 --- a/src/Umbraco.Web/WebApi/UmbracoAuthorizedApiController.cs +++ b/src/Umbraco.Web/WebApi/UmbracoAuthorizedApiController.cs @@ -24,7 +24,7 @@ namespace Umbraco.Web.WebApi [UmbracoAuthorize] [DisableBrowserCache] // [UmbracoWebApiRequireHttps] - [CheckIfUserTicketDataIsStale] + // [CheckIfUserTicketDataIsStale] [UnhandedExceptionLoggerConfiguration] [EnableDetailedErrors] public abstract class UmbracoAuthorizedApiController : UmbracoApiController