NetCore: Abstract ConfigurationManager references

This commit is contained in:
cyberdot
2020-03-03 11:18:54 +00:00
parent dc36fa1290
commit 01362d0dd0
69 changed files with 374 additions and 121 deletions
@@ -0,0 +1,7 @@
namespace Umbraco.Abstractions
{
public interface IActiveDirectorySettings
{
string ActiveDirectoryDomain { get; }
}
}
@@ -0,0 +1,7 @@
namespace Umbraco.Abstractions
{
public interface IExceptionFilterSettings
{
bool Disabled { get; }
}
}
@@ -0,0 +1,7 @@
namespace Umbraco.Abstractions
{
public interface IIndexCreatorSettings
{
string LuceneDirectoryFactory { get; }
}
}
@@ -1,4 +1,4 @@
namespace Umbraco.ModelsBuilder.Embedded.Configuration
namespace Umbraco.Abstractions
{
public interface IModelsBuilderConfig
{
@@ -0,0 +1,7 @@
namespace Umbraco.Abstractions
{
public interface INuCacheSettings
{
string BTreeBlockSize { get; }
}
}
@@ -0,0 +1,8 @@
namespace Umbraco.Abstractions
{
public interface IRuntimeSettings
{
int? MaxQueryStringLength { get; }
int? MaxRequestLength { get; }
}
}
@@ -0,0 +1,7 @@
namespace Umbraco.Abstractions
{
public interface ITypeFinderSettings
{
string AssembliesAcceptingLoadExceptions { get; }
}
}
@@ -1,4 +1,4 @@
namespace Umbraco.ModelsBuilder.Embedded.Configuration
namespace Umbraco.Abstractions
{
/// <summary>
/// Defines the models generation modes.
@@ -0,0 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
</Project>
@@ -0,0 +1,15 @@
using System.Configuration;
using Umbraco.Abstractions;
namespace Umbraco.Configuration
{
public class ActiveDirectory : IActiveDirectorySettings
{
public ActiveDirectory()
{
ActiveDirectoryDomain = ConfigurationManager.AppSettings["ActiveDirectoryDomain"];
}
public string ActiveDirectoryDomain { get; }
}
}
@@ -0,0 +1,18 @@
using System.Configuration;
using Umbraco.Abstractions;
namespace Umbraco.Configuration
{
public class ExceptionFilterSettings : IExceptionFilterSettings
{
public ExceptionFilterSettings()
{
if (bool.TryParse(ConfigurationManager.AppSettings["Umbraco.Web.DisableModelBindingExceptionFilter"],
out var disabled))
{
Disabled = disabled;
}
}
public bool Disabled { get; }
}
}
@@ -382,6 +382,10 @@ namespace Umbraco.Core.Configuration
private string _databaseFactoryServerVersion;
public string DatabaseFactoryServerVersion => GetterWithDefaultValue(Constants.AppSettings.Debug.DatabaseFactoryServerVersion, string.Empty, ref _databaseFactoryServerVersion);
private string _mainDomLock;
public string MainDomLock => GetterWithDefaultValue(Constants.AppSettings.MainDomLock, string.Empty, ref _mainDomLock);
private T GetterWithDefaultValue<T>(string appSettingKey, T defaultValue, ref T backingField)
{
if (backingField != null) return backingField;
@@ -0,0 +1,15 @@
using System.Configuration;
using Umbraco.Abstractions;
namespace Umbraco.Configuration
{
public class IndexCreatorSettings : IIndexCreatorSettings
{
public IndexCreatorSettings()
{
LuceneDirectoryFactory = ConfigurationManager.AppSettings["Umbraco.Examine.LuceneDirectoryFactory"];
}
public string LuceneDirectoryFactory { get; }
}
}
@@ -2,11 +2,11 @@
using System.Configuration;
using System.IO;
using System.Threading;
using System.Web.Configuration;
using Umbraco.Abstractions;
using Umbraco.Core;
using Umbraco.Core.IO;
namespace Umbraco.ModelsBuilder.Embedded.Configuration
namespace Umbraco.Configuration
{
/// <summary>
/// Represents the models builder configuration.
@@ -174,8 +174,13 @@ namespace Umbraco.ModelsBuilder.Embedded.Configuration
{
get
{
var section = (CompilationSection)ConfigurationManager.GetSection("system.web/compilation");
return section != null && section.Debug;
if (ConfigurationManager.GetSection("system.web/compilation") is ConfigurationSection section &&
bool.TryParse(section.ElementInformation.Properties["debug"].Value.ToString(), out var isDebug))
{
return isDebug;
}
return false;
}
}
@@ -1,4 +1,6 @@
namespace Umbraco.ModelsBuilder.Embedded.Configuration
using Umbraco.Abstractions;
namespace Umbraco.Configuration
{
/// <summary>
/// Provides extensions for the <see cref="ModelsMode"/> enumeration.
@@ -0,0 +1,14 @@
using System.Configuration;
using Umbraco.Abstractions;
namespace Umbraco.Configuration
{
public class NuCacheSettings : INuCacheSettings
{
public NuCacheSettings()
{
BTreeBlockSize = ConfigurationManager.AppSettings["Umbraco.Web.PublishedCache.NuCache.BTree.BlockSize"];
}
public string BTreeBlockSize { get; }
}
}
@@ -0,0 +1,29 @@
using System.Configuration;
using Umbraco.Abstractions;
namespace Umbraco.Configuration
{
public class RuntimeSettings : IRuntimeSettings
{
public RuntimeSettings()
{
if (ConfigurationManager.GetSection("system.web/httpRuntime") is ConfigurationSection section)
{
var maxRequestLengthProperty = section.ElementInformation.Properties["maxRequestLength"];
if (maxRequestLengthProperty != null && maxRequestLengthProperty.Value is int requestLength)
{
MaxRequestLength = requestLength;
}
var maxQueryStringProperty = section.ElementInformation.Properties["maxQueryStringLength"];
if (maxQueryStringProperty != null && maxQueryStringProperty.Value is int maxQueryStringLength)
{
MaxQueryStringLength = maxQueryStringLength;
}
}
}
public int? MaxQueryStringLength { get; }
public int? MaxRequestLength { get; }
}
}
@@ -0,0 +1,17 @@
using System.Configuration;
using Umbraco.Abstractions;
using Umbraco.Core;
namespace Umbraco.Configuration
{
public class TypeFinderSettings : ITypeFinderSettings
{
public TypeFinderSettings()
{
AssembliesAcceptingLoadExceptions = ConfigurationManager.AppSettings[
Constants.AppSettings.AssembliesAcceptingLoadExceptions];
}
public string AssembliesAcceptingLoadExceptions { get; }
}
}
@@ -26,6 +26,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Umbraco.Abstractions\Umbraco.Abstractions.csproj" />
<ProjectReference Include="..\Umbraco.Core\Umbraco.Core.csproj" />
</ItemGroup>
@@ -95,5 +95,6 @@
bool DisableElectionForSingleServer { get; }
string RegisterType { get; }
string DatabaseFactoryServerVersion { get; }
string MainDomLock { get; }
}
}
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.Generic;
namespace Umbraco.Core.Configuration.UmbracoSettings
{
@@ -1,10 +1,10 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using Examine;
using Examine.LuceneEngine.Directories;
using Lucene.Net.Store;
using Umbraco.Abstractions;
using Umbraco.Core;
using Umbraco.Core.Composing;
using Umbraco.Core.IO;
@@ -19,11 +19,13 @@ namespace Umbraco.Examine
{
private readonly ITypeFinder _typeFinder;
private readonly IIOHelper _ioHelper;
private readonly IIndexCreatorSettings _settings;
protected LuceneIndexCreator(ITypeFinder typeFinder, IIOHelper ioHelper)
protected LuceneIndexCreator(ITypeFinder typeFinder, IIOHelper ioHelper, IIndexCreatorSettings settings)
{
_typeFinder = typeFinder;
_ioHelper = ioHelper;
_settings = settings;
}
public abstract IEnumerable<IIndex> Create();
@@ -43,7 +45,8 @@ namespace Umbraco.Examine
System.IO.Directory.CreateDirectory(dirInfo.FullName);
//check if there's a configured directory factory, if so create it and use that to create the lucene dir
var configuredDirectoryFactory = ConfigurationManager.AppSettings["Umbraco.Examine.LuceneDirectoryFactory"];
var configuredDirectoryFactory = _settings.LuceneDirectoryFactory;
if (!configuredDirectoryFactory.IsNullOrWhiteSpace())
{
//this should be a fully qualified type
@@ -26,6 +26,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Umbraco.Abstractions\Umbraco.Abstractions.csproj" />
<ProjectReference Include="..\Umbraco.Core\Umbraco.Core.csproj" />
<ProjectReference Include="..\Umbraco.Infrastructure\Umbraco.Infrastructure.csproj" />
</ItemGroup>
@@ -4,6 +4,7 @@ using Umbraco.Core.Services;
using Lucene.Net.Analysis.Standard;
using Examine.LuceneEngine;
using Examine;
using Umbraco.Abstractions;
using Umbraco.Core;
using Umbraco.Core.Composing;
using Umbraco.Core.IO;
@@ -25,7 +26,8 @@ namespace Umbraco.Examine
IMemberService memberService,
IUmbracoIndexConfig umbracoIndexConfig,
IIOHelper ioHelper,
IRuntimeState runtimeState) : base(typeFinder, ioHelper)
IRuntimeState runtimeState,
IIndexCreatorSettings settings) : base(typeFinder, ioHelper, settings)
{
ProfilingLogger = profilingLogger ?? throw new System.ArgumentNullException(nameof(profilingLogger));
LanguageService = languageService ?? throw new System.ArgumentNullException(nameof(languageService));
@@ -1,4 +1,6 @@
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Abstractions;
using Umbraco.Configuration;
using Umbraco.Core.Configuration.UmbracoSettings;
namespace Umbraco.Core.Composing.CompositionExtensions
{
@@ -16,6 +18,14 @@ namespace Umbraco.Core.Composing.CompositionExtensions
composition.RegisterUnique(factory => factory.GetInstance<IUmbracoSettingsSection>().RequestHandler);
composition.RegisterUnique(factory => factory.GetInstance<IUmbracoSettingsSection>().Security);
composition.RegisterUnique<IIndexCreatorSettings, IndexCreatorSettings>();
composition.RegisterUnique<INuCacheSettings, NuCacheSettings>();
composition.RegisterUnique<ITypeFinderSettings, TypeFinderSettings>();
composition.RegisterUnique<IRuntimeSettings, RuntimeSettings>();
composition.RegisterUnique<IActiveDirectorySettings, IActiveDirectorySettings>();
composition.RegisterUnique<IExceptionFilterSettings, ExceptionFilterSettings>();
composition.RegisterUnique<IModelsBuilderConfig, ModelsBuilderConfig>();
return composition;
}
}
@@ -62,6 +62,8 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Umbraco.Abstractions\Umbraco.Abstractions.csproj" />
<ProjectReference Include="..\Umbraco.Configuration\Umbraco.Configuration.csproj" />
<ProjectReference Include="..\Umbraco.Core\Umbraco.Core.csproj" />
</ItemGroup>
@@ -1,4 +1,4 @@
using Umbraco.ModelsBuilder.Embedded.Configuration;
using Umbraco.Abstractions;
using Umbraco.Web.Models.ContentEditing;
namespace Umbraco.ModelsBuilder.Embedded.BackOffice
@@ -1,9 +1,9 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using Umbraco.Abstractions;
using Umbraco.Core;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.ModelsBuilder.Embedded.Configuration;
using Umbraco.Web.Editors;
using Umbraco.Web.Models.ContentEditing;
@@ -1,5 +1,6 @@
using System.Text;
using Umbraco.ModelsBuilder.Embedded.Configuration;
using Umbraco.Abstractions;
using Umbraco.Configuration;
namespace Umbraco.ModelsBuilder.Embedded.BackOffice
{
@@ -1,4 +1,4 @@
using Umbraco.ModelsBuilder.Embedded.Configuration;
using Umbraco.Abstractions;
using Umbraco.Web.Models.ContentEditing;
namespace Umbraco.ModelsBuilder.Embedded.BackOffice
@@ -1,4 +1,4 @@
using Umbraco.ModelsBuilder.Embedded.Configuration;
using Umbraco.Abstractions;
using Umbraco.Web.Models.ContentEditing;
namespace Umbraco.ModelsBuilder.Embedded.BackOffice
@@ -3,9 +3,10 @@ using System.Net;
using System.Net.Http;
using System.Runtime.Serialization;
using System.Web.Hosting;
using Umbraco.Abstractions;
using Umbraco.Configuration;
using Umbraco.Core.Exceptions;
using Umbraco.ModelsBuilder.Embedded.Building;
using Umbraco.ModelsBuilder.Embedded.Configuration;
using Umbraco.Web.Editors;
using Umbraco.Web.WebApi.Filters;
@@ -1,7 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Umbraco.ModelsBuilder.Embedded.Configuration;
using Umbraco.Abstractions;
using Umbraco.Configuration;
namespace Umbraco.ModelsBuilder.Embedded.Building
{
@@ -1,6 +1,6 @@
using System.IO;
using System.Text;
using Umbraco.ModelsBuilder.Embedded.Configuration;
using Umbraco.Abstractions;
namespace Umbraco.ModelsBuilder.Embedded.Building
{
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using Umbraco.ModelsBuilder.Embedded.Configuration;
using Umbraco.Abstractions;
namespace Umbraco.ModelsBuilder.Embedded.Building
{
@@ -4,13 +4,14 @@ using System.Reflection;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using Umbraco.Abstractions;
using Umbraco.Configuration;
using Umbraco.Core.Composing;
using Umbraco.Core.IO;
using Umbraco.Core.Services;
using Umbraco.Core.Services.Implement;
using Umbraco.Core.Strings;
using Umbraco.ModelsBuilder.Embedded.BackOffice;
using Umbraco.ModelsBuilder.Embedded.Configuration;
using Umbraco.Web;
using Umbraco.Web.JavaScript;
using Umbraco.Web.Mvc;
@@ -1,12 +1,12 @@
using System.Linq;
using System.Reflection;
using Umbraco.Abstractions;
using Umbraco.Configuration;
using Umbraco.Core;
using Umbraco.Core.Logging;
using Umbraco.Core.Composing;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.ModelsBuilder.Embedded.Building;
using Umbraco.ModelsBuilder.Embedded.Configuration;
using Umbraco.Web;
namespace Umbraco.ModelsBuilder.Embedded.Compose
{
@@ -1,5 +1,5 @@
using Umbraco.Core.Configuration;
using Umbraco.ModelsBuilder.Embedded.Configuration;
using Umbraco.Abstractions;
using Umbraco.Core.Configuration;
namespace Umbraco.ModelsBuilder.Embedded
{
@@ -1,10 +1,10 @@
using System;
using System.Threading;
using System.Web.Hosting;
using Umbraco.Abstractions;
using Umbraco.Configuration;
using Umbraco.Core.Hosting;
using Umbraco.Core.Logging;
using Umbraco.ModelsBuilder.Embedded.Building;
using Umbraco.ModelsBuilder.Embedded.Configuration;
using Umbraco.Web.Cache;
namespace Umbraco.ModelsBuilder.Embedded
@@ -1,7 +1,7 @@
using System;
using System.IO;
using System.Text;
using Umbraco.ModelsBuilder.Embedded.Configuration;
using Umbraco.Abstractions;
namespace Umbraco.ModelsBuilder.Embedded
{
@@ -1,5 +1,5 @@
using System.IO;
using Umbraco.ModelsBuilder.Embedded.Configuration;
using Umbraco.Abstractions;
using Umbraco.Web.Cache;
namespace Umbraco.ModelsBuilder.Embedded
@@ -11,12 +11,12 @@ using System.Threading;
using System.Web;
using System.Web.Compilation;
using System.Web.WebPages.Razor;
using Umbraco.Abstractions;
using Umbraco.Core;
using Umbraco.Core.Hosting;
using Umbraco.Core.Logging;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.ModelsBuilder.Embedded.Building;
using Umbraco.ModelsBuilder.Embedded.Configuration;
using File = System.IO.File;
namespace Umbraco.ModelsBuilder.Embedded
@@ -59,10 +59,6 @@
<Compile Include="Building\TypeModel.cs" />
<Compile Include="Compose\DisabledModelsBuilderComponent.cs" />
<Compile Include="ConfigsExtensions.cs" />
<Compile Include="Configuration\IModelsBuilderConfig.cs" />
<Compile Include="Configuration\ModelsBuilderConfig.cs" />
<Compile Include="Configuration\ModelsMode.cs" />
<Compile Include="Configuration\ModelsModeExtensions.cs" />
<Compile Include="BackOffice\DashboardReport.cs" />
<Compile Include="ImplementPropertyTypeAttribute.cs" />
<Compile Include="ModelsBuilderAssemblyAttribute.cs" />
@@ -101,6 +97,14 @@
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Umbraco.Abstractions\Umbraco.Abstractions.csproj">
<Project>{D369E986-00D5-4F49-9B2D-E7A8F0C9EEDD}</Project>
<Name>Umbraco.Abstractions</Name>
</ProjectReference>
<ProjectReference Include="..\Umbraco.Configuration\Umbraco.Configuration.csproj">
<Project>{FBE7C065-DAC0-4025-A78B-63B24D3AB00B}</Project>
<Name>Umbraco.Configuration</Name>
</ProjectReference>
<ProjectReference Include="..\Umbraco.Core\Umbraco.Core.csproj">
<Project>{29aa69d9-b597-4395-8d42-43b1263c240a}</Project>
<Name>Umbraco.Core</Name>
@@ -123,6 +127,8 @@
<Version>5.2.7</Version>
</PackageReference>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Folder Include="Configuration\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
@@ -1,12 +1,13 @@
using System.Configuration;
using CSharpTest.Net.Collections;
using CSharpTest.Net.Serialization;
using Umbraco.Abstractions;
namespace Umbraco.Web.PublishedCache.NuCache.DataSource
{
internal class BTree
{
public static BPlusTree<int, ContentNodeKit> GetTree(string filepath, bool exists)
public static BPlusTree<int, ContentNodeKit> GetTree(string filepath, bool exists, INuCacheSettings settings)
{
var keySerializer = new PrimitiveSerializer();
var valueSerializer = new ContentNodeKitSerializer();
@@ -19,7 +20,7 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource
CachePolicy = CachePolicy.None,
// default is 4096, min 2^9 = 512, max 2^16 = 64K
FileBlockSize = GetBlockSize(),
FileBlockSize = GetBlockSize(settings),
// other options?
};
@@ -32,11 +33,11 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource
return tree;
}
private static int GetBlockSize()
private static int GetBlockSize(INuCacheSettings settings)
{
var blockSize = 4096;
var appSetting = ConfigurationManager.AppSettings["Umbraco.Web.PublishedCache.NuCache.BTree.BlockSize"];
var appSetting = settings.BTreeBlockSize;
if (appSetting == null)
return blockSize;
@@ -6,6 +6,7 @@ using System.Linq;
using System.Threading;
using CSharpTest.Net.Collections;
using Newtonsoft.Json;
using Umbraco.Abstractions;
using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Composing;
@@ -53,6 +54,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
private readonly IHostingEnvironment _hostingEnvironment;
private readonly IShortStringHelper _shortStringHelper;
private readonly IIOHelper _ioHelper;
private readonly INuCacheSettings _config;
// volatile because we read it with no lock
private volatile bool _isReady;
@@ -90,7 +92,8 @@ namespace Umbraco.Web.PublishedCache.NuCache
ITypeFinder typeFinder,
IHostingEnvironment hostingEnvironment,
IShortStringHelper shortStringHelper,
IIOHelper ioHelper)
IIOHelper ioHelper,
INuCacheSettings config)
: base(publishedSnapshotAccessor, variationContextAccessor)
{
//if (Interlocked.Increment(ref _singletonCheck) > 1)
@@ -111,6 +114,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
_hostingEnvironment = hostingEnvironment;
_shortStringHelper = shortStringHelper;
_ioHelper = ioHelper;
_config = config;
// we need an Xml serializer here so that the member cache can support XPath,
// for members this is done by navigating the serialized-to-xml member
@@ -197,8 +201,8 @@ namespace Umbraco.Web.PublishedCache.NuCache
_localMediaDbExists = File.Exists(localMediaDbPath);
// if both local databases exist then GetTree will open them, else new databases will be created
_localContentDb = BTree.GetTree(localContentDbPath, _localContentDbExists);
_localMediaDb = BTree.GetTree(localMediaDbPath, _localMediaDbExists);
_localContentDb = BTree.GetTree(localContentDbPath, _localContentDbExists, _config);
_localMediaDb = BTree.GetTree(localMediaDbPath, _localMediaDbExists, _config);
_logger.Info<PublishedSnapshotService>("Registered with MainDom, localContentDbExists? {LocalContentDbExists}, localMediaDbExists? {LocalMediaDbExists}", _localContentDbExists, _localMediaDbExists);
}
@@ -12,6 +12,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Umbraco.Abstractions\Umbraco.Abstractions.csproj" />
<ProjectReference Include="..\Umbraco.Core\Umbraco.Core.csproj" />
<ProjectReference Include="..\Umbraco.Infrastructure\Umbraco.Infrastructure.csproj" />
</ItemGroup>
@@ -4,10 +4,10 @@ using System.Linq;
using System.Text;
using Moq;
using NUnit.Framework;
using Umbraco.Abstractions;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.ModelsBuilder.Embedded;
using Umbraco.ModelsBuilder.Embedded.Building;
using Umbraco.ModelsBuilder.Embedded.Configuration;
namespace Umbraco.Tests.ModelsBuilder
{
@@ -1,6 +1,6 @@
using System.Configuration;
using NUnit.Framework;
using Umbraco.ModelsBuilder.Embedded.Configuration;
using Umbraco.Configuration;
using Umbraco.Tests.TestHelpers;
namespace Umbraco.Tests.ModelsBuilder
@@ -4,6 +4,7 @@ using System.Data;
using System.Linq;
using Moq;
using NUnit.Framework;
using Umbraco.Abstractions;
using Umbraco.Core;
using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
@@ -144,6 +145,7 @@ namespace Umbraco.Tests.PublishedContent
_source = new TestDataSource(kits);
var typeFinder = new TypeFinder(Mock.Of<ILogger>());
var settings = Mock.Of<INuCacheSettings>();
// at last, create the complete NuCache snapshot service!
@@ -169,7 +171,8 @@ namespace Umbraco.Tests.PublishedContent
typeFinder,
hostingEnvironment,
new MockShortStringHelper(),
TestHelper.IOHelper);
TestHelper.IOHelper,
settings);
// invariant is the current default
_variationAccesor.VariationContext = new VariationContext();
@@ -4,6 +4,7 @@ using System.Data;
using System.Linq;
using Moq;
using NUnit.Framework;
using Umbraco.Abstractions;
using Umbraco.Core;
using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
@@ -185,6 +186,7 @@ namespace Umbraco.Tests.PublishedContent
_variationAccesor = new TestVariationContextAccessor();
var typeFinder = new TypeFinder(Mock.Of<ILogger>());
var settings = Mock.Of<INuCacheSettings>();
// at last, create the complete NuCache snapshot service!
var options = new PublishedSnapshotServiceOptions { IgnoreLocalDb = true };
@@ -209,7 +211,8 @@ namespace Umbraco.Tests.PublishedContent
typeFinder,
TestHelper.GetHostingEnvironment(),
new MockShortStringHelper(),
TestHelper.IOHelper);
TestHelper.IOHelper,
settings);
// invariant is the current default
_variationAccesor.VariationContext = new VariationContext();
@@ -2,10 +2,8 @@
using System.Linq;
using System.Web.Mvc;
using System.Web.Routing;
using System.Web.Security;
using Moq;
using NUnit.Framework;
using NUnit.Framework.Internal;
using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Logging;
@@ -17,22 +15,17 @@ using Umbraco.Web.Models;
using Umbraco.Web.Mvc;
using Umbraco.Web.WebApi;
using Umbraco.Core.Strings;
using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.Dictionary;
using Umbraco.Core.Hosting;
using Umbraco.Core.IO;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.Persistence;
using Umbraco.Core.Services;
using Umbraco.Tests.PublishedContent;
using Umbraco.Tests.Testing;
using Umbraco.Tests.Testing.Objects.Accessors;
using Umbraco.Web.PublishedCache;
using Umbraco.Web.Runtime;
using Umbraco.Web.Security;
using Current = Umbraco.Web.Composing.Current;
using Umbraco.Web.Security.Providers;
using ILogger = Umbraco.Core.Logging.ILogger;
namespace Umbraco.Tests.Routing
@@ -141,7 +134,7 @@ namespace Umbraco.Tests.Routing
var url = "~/dummy-page";
var template = CreateTemplate(templateName);
var route = RouteTable.Routes["Umbraco_default"];
var routeData = new RouteData() {Route = route};
var routeData = new RouteData() { Route = route };
var umbracoContext = GetUmbracoContext("~/dummy-page", template.Id, routeData, true);
var httpContext = GetHttpContextFactory(url, routeData).HttpContext;
var httpContextAccessor = TestHelper.GetHttpContextAccessor(httpContext);
@@ -156,12 +149,12 @@ namespace Umbraco.Tests.Routing
var handler = new RenderRouteHandler(umbracoContext, new TestControllerFactory(umbracoContextAccessor, Mock.Of<ILogger>(), context =>
{
return new CustomDocumentController(Factory.GetInstance<IGlobalSettings>(),
umbracoContextAccessor,
Factory.GetInstance<ServiceContext>(),
Factory.GetInstance<AppCaches>(),
Factory.GetInstance<IProfilingLogger>(),
new UmbracoHelper(Mock.Of<IPublishedContent>(), Mock.Of<ITagQuery>(), Mock.Of<ICultureDictionaryFactory>(), Mock.Of<IUmbracoComponentRenderer>(), Mock.Of<IPublishedContentQuery>()));
return new CustomDocumentController(Factory.GetInstance<IGlobalSettings>(),
umbracoContextAccessor,
Factory.GetInstance<ServiceContext>(),
Factory.GetInstance<AppCaches>(),
Factory.GetInstance<IProfilingLogger>(),
new UmbracoHelper(Mock.Of<IPublishedContent>(), Mock.Of<ITagQuery>(), Mock.Of<ICultureDictionaryFactory>(), Mock.Of<IUmbracoComponentRenderer>(), Mock.Of<IPublishedContentQuery>()));
}), ShortStringHelper);
handler.GetHandlerForRoute(httpContext.Request.RequestContext, frequest);
@@ -4,6 +4,7 @@ using System.Linq;
using System.Web.Routing;
using Moq;
using NUnit.Framework;
using Umbraco.Abstractions;
using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Composing;
@@ -86,6 +87,7 @@ namespace Umbraco.Tests.Scoping
var hostingEnvironment = TestHelper.GetHostingEnvironment();
var typeFinder = new TypeFinder(Mock.Of<ILogger>());
var settings = Mock.Of<INuCacheSettings>();
return new PublishedSnapshotService(
options,
@@ -107,7 +109,8 @@ namespace Umbraco.Tests.Scoping
typeFinder,
hostingEnvironment,
new MockShortStringHelper(),
IOHelper);
IOHelper,
settings);
}
protected IUmbracoContext GetUmbracoContextNu(string url, int templateId = 1234, RouteData routeData = null, bool setSingleton = false, IUmbracoSettingsSection umbracoSettings = null, IEnumerable<IUrlProvider> urlProviders = null)
@@ -4,6 +4,7 @@ using System.Linq;
using System.Threading;
using Moq;
using NUnit.Framework;
using Umbraco.Abstractions;
using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Composing;
@@ -59,6 +60,7 @@ namespace Umbraco.Tests.Services
var hostingEnvironment = Mock.Of<IHostingEnvironment>();
var typeFinder = new TypeFinder(Mock.Of<ILogger>());
var settings = Mock.Of<INuCacheSettings>();
return new PublishedSnapshotService(
options,
@@ -80,7 +82,8 @@ namespace Umbraco.Tests.Services
typeFinder,
hostingEnvironment,
new MockShortStringHelper(),
IOHelper);
IOHelper,
settings);
}
public class LocalServerMessenger : ServerMessengerBase
+4
View File
@@ -558,6 +558,10 @@
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Umbraco.Abstractions\Umbraco.Abstractions.csproj">
<Project>{D369E986-00D5-4F49-9B2D-E7A8F0C9EEDD}</Project>
<Name>Umbraco.Abstractions</Name>
</ProjectReference>
<ProjectReference Include="..\Umbraco.Configuration\Umbraco.Configuration.csproj">
<Project>{fbe7c065-dac0-4025-a78b-63b24d3ab00b}</Project>
<Name>Umbraco.Configuration</Name>
@@ -110,7 +110,7 @@
on-login="hideLoginScreen()">
</umb-login>
@Html.BareMinimumServerVariablesScript(Url, Url.Action("ExternalLogin", "BackOffice", new { area = ViewData.GetUmbracoPath() }), Model.Features, Model.GlobalSettings, Model.UmbracoVersion, Model.UmbracoSettingsSection, Model.IOHelper, Model.TreeCollection, Model.HttpContextAccessor, Model.HostingEnvironment)
@Html.BareMinimumServerVariablesScript(Url, Url.Action("ExternalLogin", "BackOffice", new { area = ViewData.GetUmbracoPath() }), Model.Features, Model.GlobalSettings, Model.UmbracoVersion, Model.UmbracoSettingsSection, Model.IOHelper, Model.TreeCollection, Model.HttpContextAccessor, Model.HostingEnvironment, Model.RuntimeSettings)
<script>
@@ -1,14 +1,11 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Security;
using System.Text;
using System.Threading.Tasks;
using System.Web.Compilation;
using Umbraco.Core;
using Umbraco.Abstractions;
using Umbraco.Core.Composing;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.Hosting;
@@ -26,7 +23,11 @@ namespace Umbraco.Web.Composing
internal class BuildManagerTypeFinder : TypeFinder, ITypeFinder
{
public BuildManagerTypeFinder(IIOHelper ioHelper, IHostingEnvironment hostingEnvironment, ILogger logger, ITypeFinderConfig typeFinderConfig = null) : base(logger, typeFinderConfig)
public BuildManagerTypeFinder(
IIOHelper ioHelper,
IHostingEnvironment hostingEnvironment,
ILogger logger,
ITypeFinderConfig typeFinderConfig = null) : base(logger, typeFinderConfig)
{
if (ioHelper == null) throw new ArgumentNullException(nameof(ioHelper));
if (hostingEnvironment == null) throw new ArgumentNullException(nameof(hostingEnvironment));
@@ -91,7 +92,14 @@ namespace Umbraco.Web.Composing
/// </summary>
internal class TypeFinderConfig : ITypeFinderConfig
{
private readonly ITypeFinderSettings _settings;
private IEnumerable<string> _assembliesAcceptingLoadExceptions;
public TypeFinderConfig(ITypeFinderSettings settings)
{
_settings = settings;
}
public IEnumerable<string> AssembliesAcceptingLoadExceptions
{
get
@@ -99,7 +107,7 @@ namespace Umbraco.Web.Composing
if (_assembliesAcceptingLoadExceptions != null)
return _assembliesAcceptingLoadExceptions;
var s = ConfigurationManager.AppSettings[Constants.AppSettings.AssembliesAcceptingLoadExceptions];
var s = _settings.AssembliesAcceptingLoadExceptions;
return _assembliesAcceptingLoadExceptions = string.IsNullOrWhiteSpace(s)
? Array.Empty<string>()
: s.Split(',').Select(x => x.Trim()).ToArray();
@@ -11,6 +11,7 @@ using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.Owin;
using Microsoft.Owin.Security;
using Newtonsoft.Json;
using Umbraco.Abstractions;
using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Configuration;
@@ -53,6 +54,7 @@ namespace Umbraco.Web.Editors
private readonly TreeCollection _treeCollection;
private readonly IHostingEnvironment _hostingEnvironment;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly IRuntimeSettings _runtimeSettings;
public BackOfficeController(
IManifestParser manifestParser,
@@ -70,7 +72,8 @@ namespace Umbraco.Web.Editors
IIOHelper ioHelper,
TreeCollection treeCollection,
IHostingEnvironment hostingEnvironment,
IHttpContextAccessor httpContextAccessor)
IHttpContextAccessor httpContextAccessor,
IRuntimeSettings settings)
: base(globalSettings, umbracoContextAccessor, services, appCaches, profilingLogger, umbracoHelper)
{
_manifestParser = manifestParser;
@@ -83,6 +86,7 @@ namespace Umbraco.Web.Editors
_treeCollection = treeCollection ?? throw new ArgumentNullException(nameof(treeCollection));
_hostingEnvironment = hostingEnvironment;
_httpContextAccessor = httpContextAccessor;
_runtimeSettings = settings;
}
protected BackOfficeSignInManager SignInManager => _signInManager ?? (_signInManager = OwinContext.GetBackOfficeSignInManager());
@@ -98,8 +102,8 @@ namespace Umbraco.Web.Editors
public async Task<ActionResult> Default()
{
return await RenderDefaultOrProcessExternalLoginAsync(
() => View(GlobalSettings.Path.EnsureEndsWith('/') + "Views/Default.cshtml", new BackOfficeModel(_features, GlobalSettings, _umbracoVersion, _umbracoSettingsSection,_ioHelper, _treeCollection, _httpContextAccessor, _hostingEnvironment)),
() => View(GlobalSettings.Path.EnsureEndsWith('/') + "Views/Default.cshtml", new BackOfficeModel(_features, GlobalSettings, _umbracoVersion, _umbracoSettingsSection, _ioHelper, _treeCollection, _httpContextAccessor, _hostingEnvironment)));
() => View(GlobalSettings.Path.EnsureEndsWith('/') + "Views/Default.cshtml", new BackOfficeModel(_features, GlobalSettings, _umbracoVersion, _umbracoSettingsSection,_ioHelper, _treeCollection, _httpContextAccessor, _hostingEnvironment, _runtimeSettings)),
() => View(GlobalSettings.Path.EnsureEndsWith('/') + "Views/Default.cshtml", new BackOfficeModel(_features, GlobalSettings, _umbracoVersion, _umbracoSettingsSection, _ioHelper, _treeCollection, _httpContextAccessor, _hostingEnvironment, _runtimeSettings)));
}
[HttpGet]
@@ -182,7 +186,7 @@ namespace Umbraco.Web.Editors
{
return await RenderDefaultOrProcessExternalLoginAsync(
//The default view to render when there is no external login info or errors
() => View(GlobalSettings.Path.EnsureEndsWith('/') + "Views/AuthorizeUpgrade.cshtml", new BackOfficeModel(_features, GlobalSettings, _umbracoVersion, _umbracoSettingsSection, _ioHelper, _treeCollection, _httpContextAccessor, _hostingEnvironment)),
() => View(GlobalSettings.Path.EnsureEndsWith('/') + "Views/AuthorizeUpgrade.cshtml", new BackOfficeModel(_features, GlobalSettings, _umbracoVersion, _umbracoSettingsSection, _ioHelper, _treeCollection, _httpContextAccessor, _hostingEnvironment, _runtimeSettings)),
//The ActionResult to perform if external login is successful
() => Redirect("/"));
}
@@ -289,7 +293,7 @@ namespace Umbraco.Web.Editors
[MinifyJavaScriptResult(Order = 1)]
public JavaScriptResult ServerVariables()
{
var serverVars = new BackOfficeServerVariables(Url, _runtimeState, _features, GlobalSettings, _umbracoVersion, _umbracoSettingsSection, _ioHelper, _treeCollection, _httpContextAccessor, _hostingEnvironment);
var serverVars = new BackOfficeServerVariables(Url, _runtimeState, _features, GlobalSettings, _umbracoVersion, _umbracoSettingsSection, _ioHelper, _treeCollection, _httpContextAccessor, _hostingEnvironment, _runtimeSettings);
//cache the result if debugging is disabled
var result = _hostingEnvironment.IsDebugMode
+5 -2
View File
@@ -1,4 +1,5 @@
using Umbraco.Core.Configuration;
using Umbraco.Abstractions;
using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.Hosting;
using Umbraco.Core.IO;
@@ -10,7 +11,7 @@ namespace Umbraco.Web.Editors
public class BackOfficeModel
{
public BackOfficeModel(UmbracoFeatures features, IGlobalSettings globalSettings, IUmbracoVersion umbracoVersion, IUmbracoSettingsSection umbracoSettingsSection, IIOHelper ioHelper, TreeCollection treeCollection, IHttpContextAccessor httpContextAccessor, IHostingEnvironment hostingEnvironment)
public BackOfficeModel(UmbracoFeatures features, IGlobalSettings globalSettings, IUmbracoVersion umbracoVersion, IUmbracoSettingsSection umbracoSettingsSection, IIOHelper ioHelper, TreeCollection treeCollection, IHttpContextAccessor httpContextAccessor, IHostingEnvironment hostingEnvironment, IRuntimeSettings runtimeSettings)
{
Features = features;
GlobalSettings = globalSettings;
@@ -20,6 +21,7 @@ namespace Umbraco.Web.Editors
TreeCollection = treeCollection;
HttpContextAccessor = httpContextAccessor;
HostingEnvironment = hostingEnvironment;
RuntimeSettings = runtimeSettings;
}
public UmbracoFeatures Features { get; }
@@ -30,5 +32,6 @@ namespace Umbraco.Web.Editors
public TreeCollection TreeCollection { get; }
public IHttpContextAccessor HttpContextAccessor { get; }
public IHostingEnvironment HostingEnvironment { get; }
public IRuntimeSettings RuntimeSettings { get; set; }
}
}
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using Umbraco.Abstractions;
using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.Hosting;
@@ -14,8 +15,8 @@ namespace Umbraco.Web.Editors
private readonly UmbracoFeatures _features;
public IEnumerable<ILanguage> Languages { get; }
public BackOfficePreviewModel(UmbracoFeatures features, IGlobalSettings globalSettings, IUmbracoVersion umbracoVersion, IEnumerable<ILanguage> languages, IUmbracoSettingsSection umbracoSettingsSection, IIOHelper ioHelper, TreeCollection treeCollection, IHttpContextAccessor httpContextAccessor, IHostingEnvironment hostingEnvironment)
: base(features, globalSettings, umbracoVersion, umbracoSettingsSection, ioHelper, treeCollection, httpContextAccessor, hostingEnvironment)
public BackOfficePreviewModel(UmbracoFeatures features, IGlobalSettings globalSettings, IUmbracoVersion umbracoVersion, IEnumerable<ILanguage> languages, IUmbracoSettingsSection umbracoSettingsSection, IIOHelper ioHelper, TreeCollection treeCollection, IHttpContextAccessor httpContextAccessor, IHostingEnvironment hostingEnvironment, IRuntimeSettings runtimeSettings)
: base(features, globalSettings, umbracoVersion, umbracoSettingsSection, ioHelper, treeCollection, httpContextAccessor, hostingEnvironment, runtimeSettings)
{
_features = features;
Languages = languages;
@@ -1,15 +1,13 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Runtime.Serialization;
using System.Web;
using System.Web.Configuration;
using System.Web.Mvc;
using ClientDependency.Core.Config;
using Microsoft.Owin;
using Microsoft.Owin.Security;
using Umbraco.Abstractions;
using Umbraco.Core;
using Umbraco.Core.Configuration;
using Umbraco.Web.Features;
@@ -41,8 +39,20 @@ namespace Umbraco.Web.Editors
private readonly TreeCollection _treeCollection;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly IHostingEnvironment _hostingEnvironment;
private readonly IRuntimeSettings _settings;
internal BackOfficeServerVariables(UrlHelper urlHelper, IRuntimeState runtimeState, UmbracoFeatures features, IGlobalSettings globalSettings, IUmbracoVersion umbracoVersion, IUmbracoSettingsSection umbracoSettingsSection, IIOHelper ioHelper, TreeCollection treeCollection, IHttpContextAccessor httpContextAccessor, IHostingEnvironment hostingEnvironment)
internal BackOfficeServerVariables(
UrlHelper urlHelper,
IRuntimeState runtimeState,
UmbracoFeatures features,
IGlobalSettings globalSettings,
IUmbracoVersion umbracoVersion,
IUmbracoSettingsSection umbracoSettingsSection,
IIOHelper ioHelper,
TreeCollection treeCollection,
IHttpContextAccessor httpContextAccessor,
IHostingEnvironment hostingEnvironment,
IRuntimeSettings settings)
{
_urlHelper = urlHelper;
_runtimeState = runtimeState;
@@ -54,6 +64,7 @@ namespace Umbraco.Web.Editors
_treeCollection = treeCollection ?? throw new ArgumentNullException(nameof(treeCollection));
_httpContextAccessor = httpContextAccessor;
_hostingEnvironment = hostingEnvironment;
_settings = settings;
}
/// <summary>
@@ -473,11 +484,9 @@ namespace Umbraco.Web.Editors
return app;
}
private static string GetMaxRequestLength()
private string GetMaxRequestLength()
{
return ConfigurationManager.GetSection("system.web/httpRuntime") is HttpRuntimeSection section
? section.MaxRequestLength.ToString()
: string.Empty;
return _settings.MaxRequestLength.HasValue ? _settings.MaxRequestLength.Value.ToString() : string.Empty;
}
}
}
+6 -2
View File
@@ -3,6 +3,7 @@ using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.UI;
using Umbraco.Abstractions;
using Umbraco.Core;
using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.UmbracoSettings;
@@ -36,6 +37,7 @@ namespace Umbraco.Web.Editors
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly IHostingEnvironment _hostingEnvironment;
private readonly ICookieManager _cookieManager;
private IRuntimeSettings _runtimeSettings;
public PreviewController(
UmbracoFeatures features,
@@ -49,7 +51,8 @@ namespace Umbraco.Web.Editors
TreeCollection treeCollection,
IHttpContextAccessor httpContextAccessor,
IHostingEnvironment hostingEnvironment,
ICookieManager cookieManager)
ICookieManager cookieManager,
IRuntimeSettings settings)
{
_features = features;
_globalSettings = globalSettings;
@@ -63,6 +66,7 @@ namespace Umbraco.Web.Editors
_httpContextAccessor = httpContextAccessor;
_hostingEnvironment = hostingEnvironment;
_cookieManager = cookieManager;
_runtimeSettings = settings;
}
[UmbracoAuthorize(redirectToUmbracoLogin: true)]
@@ -71,7 +75,7 @@ namespace Umbraco.Web.Editors
{
var availableLanguages = _localizationService.GetAllLanguages();
var model = new BackOfficePreviewModel(_features, _globalSettings, _umbracoVersion, availableLanguages, _umbracoSettingsSection, _ioHelper, _treeCollection, _httpContextAccessor, _hostingEnvironment);
var model = new BackOfficePreviewModel(_features, _globalSettings, _umbracoVersion, availableLanguages, _umbracoSettingsSection, _ioHelper, _treeCollection, _httpContextAccessor, _hostingEnvironment, _runtimeSettings);
if (model.PreviewExtendedHeaderView.IsNullOrWhiteSpace() == false)
{
@@ -5,6 +5,7 @@ using System.Web;
using System.Web.Mvc;
using Microsoft.Owin.Security;
using Newtonsoft.Json;
using Umbraco.Abstractions;
using Umbraco.Core.Hosting;
using Umbraco.Core.IO;
using Umbraco.Web.Composing;
@@ -40,9 +41,9 @@ namespace Umbraco.Web
/// These are the bare minimal server variables that are required for the application to start without being authenticated,
/// we will load the rest of the server vars after the user is authenticated.
/// </remarks>
public static IHtmlString BareMinimumServerVariablesScript(this HtmlHelper html, UrlHelper uri, string externalLoginsUrl, UmbracoFeatures features, IGlobalSettings globalSettings, IUmbracoVersion umbracoVersion, IUmbracoSettingsSection umbracoSettingsSection, IIOHelper ioHelper, TreeCollection treeCollection, IHttpContextAccessor httpContextAccessor, IHostingEnvironment hostingEnvironment)
public static IHtmlString BareMinimumServerVariablesScript(this HtmlHelper html, UrlHelper uri, string externalLoginsUrl, UmbracoFeatures features, IGlobalSettings globalSettings, IUmbracoVersion umbracoVersion, IUmbracoSettingsSection umbracoSettingsSection, IIOHelper ioHelper, TreeCollection treeCollection, IHttpContextAccessor httpContextAccessor, IHostingEnvironment hostingEnvironment, IRuntimeSettings settings)
{
var serverVars = new BackOfficeServerVariables(uri, Current.RuntimeState, features, globalSettings, umbracoVersion, umbracoSettingsSection, ioHelper, treeCollection, httpContextAccessor, hostingEnvironment);
var serverVars = new BackOfficeServerVariables(uri, Current.RuntimeState, features, globalSettings, umbracoVersion, umbracoSettingsSection, ioHelper, treeCollection, httpContextAccessor, hostingEnvironment, settings);
var minVars = serverVars.BareMinimumServerVariables();
var str = @"<script type=""text/javascript"">
@@ -3,6 +3,7 @@ using System.Configuration;
using System.Net;
using System.Text.RegularExpressions;
using System.Web.Mvc;
using Umbraco.Abstractions;
using Umbraco.Core;
using Umbraco.Web.Composing;
@@ -21,8 +22,10 @@ namespace Umbraco.Web.Mvc
public void OnException(ExceptionContext filterContext)
{
var settings = Current.Factory.GetInstance<IExceptionFilterSettings>();
var disabled = settings?.Disabled ?? false;
if (Current.PublishedModelFactory.IsLiveFactory()
&& ConfigurationManager.AppSettings["Umbraco.Web.DisableModelBindingExceptionFilter"] != "true"
&& !disabled
&& !filterContext.ExceptionHandled
&& ((filterContext.Exception is ModelBindingException || filterContext.Exception is InvalidCastException)
&& IsMessageAboutTheSameModelType(filterContext.Exception.Message)))
@@ -1,23 +1,21 @@
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Web.Configuration;
using System.Web.Http;
using System.Web.Http.Dispatcher;
using System.Web.Mvc;
using System.Web.Routing;
using ClientDependency.Core.CompositeFiles.Providers;
using ClientDependency.Core.Config;
using Umbraco.Abstractions;
using Umbraco.Core;
using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.Hosting;
using Umbraco.Core.Strings;
using Umbraco.Core.IO;
using Umbraco.Core.Strings;
using Umbraco.Web.Install;
using Umbraco.Web.JavaScript;
using Umbraco.Web.Mvc;
@@ -37,6 +35,7 @@ namespace Umbraco.Web.Runtime
private readonly IHostingEnvironment _hostingEnvironment;
private readonly IIOHelper _ioHelper;
private readonly IShortStringHelper _shortStringHelper;
private readonly IRuntimeSettings _settings;
public WebInitialComponent(
IUmbracoContextAccessor umbracoContextAccessor,
@@ -46,7 +45,8 @@ namespace Umbraco.Web.Runtime
IGlobalSettings globalSettings,
IHostingEnvironment hostingEnvironment,
IIOHelper ioHelper,
IShortStringHelper shortStringHelper)
IShortStringHelper shortStringHelper,
IRuntimeSettings settings)
{
_umbracoContextAccessor = umbracoContextAccessor;
_surfaceControllerTypes = surfaceControllerTypes;
@@ -56,6 +56,7 @@ namespace Umbraco.Web.Runtime
_hostingEnvironment = hostingEnvironment;
_ioHelper = ioHelper;
_shortStringHelper = shortStringHelper;
_settings = settings;
}
public void Initialize()
@@ -146,10 +147,10 @@ namespace Umbraco.Web.Runtime
= Path.Combine(cachePath, "ClientDependency");
}
if (ConfigurationManager.GetSection("system.web/httpRuntime") is HttpRuntimeSection section)
if (_settings.MaxQueryStringLength.HasValue || _settings.MaxRequestLength.HasValue)
{
//set the max url length for CDF to be the smallest of the max query length, max request length
ClientDependency.Core.CompositeFiles.CompositeDependencyHandler.MaxHandlerUrlLength = Math.Min(section.MaxQueryStringLength, section.MaxRequestLength);
ClientDependency.Core.CompositeFiles.CompositeDependencyHandler.MaxHandlerUrlLength = Math.Min(_settings.MaxQueryStringLength.GetValueOrDefault(), _settings.MaxRequestLength.GetValueOrDefault());
}
//Register a custom renderer - used to process property editor dependencies
+4 -3
View File
@@ -1,5 +1,6 @@
using System;
using System.Web;
using System.Web;
using Umbraco.Abstractions;
using Umbraco.Configuration;
using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Composing;
@@ -97,7 +98,7 @@ namespace Umbraco.Web.Runtime
#region Getters
protected override ITypeFinder GetTypeFinder() => _typeFinder ?? (_typeFinder = new BuildManagerTypeFinder(IOHelper, HostingEnvironment, Logger, new BuildManagerTypeFinder.TypeFinderConfig()));
protected override ITypeFinder GetTypeFinder() => _typeFinder ?? (_typeFinder = new BuildManagerTypeFinder(IOHelper, HostingEnvironment, Logger, new BuildManagerTypeFinder.TypeFinderConfig(new TypeFinderSettings())));
protected override AppCaches GetAppCaches() => new AppCaches(
// we need to have the dep clone runtime cache provider to ensure
@@ -1,8 +1,7 @@
using System;
using System.Configuration;
using System.DirectoryServices.AccountManagement;
using System.Threading.Tasks;
using Umbraco.Core.Models.Identity;
using Umbraco.Abstractions;
using Umbraco.Web.Models.Identity;
namespace Umbraco.Web.Security
@@ -10,15 +9,15 @@ namespace Umbraco.Web.Security
// TODO: This relies on an assembly that is not .NET Standard (at least not at the time of implementation) :(
public class ActiveDirectoryBackOfficeUserPasswordChecker : IBackOfficeUserPasswordChecker
{
public virtual string ActiveDirectoryDomain
private readonly IActiveDirectorySettings _settings;
public ActiveDirectoryBackOfficeUserPasswordChecker(IActiveDirectorySettings settings)
{
get
{
// TODO: Verify this AppSetting key is used in .NET Framework & canot be changed to Umbraco.Core. prefix
return ConfigurationManager.AppSettings["ActiveDirectoryDomain"];
}
_settings = settings;
}
public virtual string ActiveDirectoryDomain => _settings.ActiveDirectoryDomain;
public Task<BackOfficeUserPasswordCheckerResult> CheckPasswordAsync(BackOfficeIdentityUser user, string password)
{
bool isValid;
+4
View File
@@ -106,6 +106,10 @@
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Umbraco.Abstractions\Umbraco.Abstractions.csproj">
<Project>{D369E986-00D5-4F49-9B2D-E7A8F0C9EEDD}</Project>
<Name>Umbraco.Abstractions</Name>
</ProjectReference>
<ProjectReference Include="..\Umbraco.Configuration\Umbraco.Configuration.csproj">
<Project>{fbe7c065-dac0-4025-a78b-63b24d3ab00b}</Project>
<Name>Umbraco.Configuration</Name>
+3 -6
View File
@@ -1,14 +1,12 @@
using System.Configuration;
using System.Threading;
using System.Threading;
using System.Web;
using Umbraco.Abstractions;
using Umbraco.Core;
using Umbraco.Core.Logging.Serilog;
using Umbraco.Core.Runtime;
using Umbraco.Core.Configuration;
using Umbraco.Core.Hosting;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.Persistence;
using Umbraco.Web.Runtime;
namespace Umbraco.Web
@@ -26,8 +24,7 @@ namespace Umbraco.Web
var dbProviderFactoryCreator = new UmbracoDbProviderFactoryCreator(connectionStringConfig?.ProviderName);
// Determine if we should use the sql main dom or the default
var appSettingMainDomLock = ConfigurationManager.AppSettings[Constants.AppSettings.MainDomLock];
var appSettingMainDomLock = configs.Global().MainDomLock;
var mainDomLock = appSettingMainDomLock == "SqlMainDomLock"
? (IMainDomLock)new SqlMainDomLock(logger, configs, dbProviderFactoryCreator)
: new MainDomSemaphoreLock(logger, hostingEnvironment);
+9 -3
View File
@@ -111,11 +111,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Umbraco.Persistance.SqlCe",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.TestData", "Umbraco.TestData\Umbraco.TestData.csproj", "{FB5676ED-7A69-492C-B802-E7B24144C0FC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.PublishedCache.NuCache", "Umbraco.PublishedCache.NuCache\Umbraco.PublishedCache.NuCache.csproj", "{F6DE8DA0-07CC-4EF2-8A59-2BC81DBB3830}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Umbraco.PublishedCache.NuCache", "Umbraco.PublishedCache.NuCache\Umbraco.PublishedCache.NuCache.csproj", "{F6DE8DA0-07CC-4EF2-8A59-2BC81DBB3830}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.Examine.Lucene", "Umbraco.Examine.Lucene\Umbraco.Examine.Lucene.csproj", "{0FAD7D2A-D7DD-45B1-91FD-488BB6CDACEA}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Umbraco.Examine.Lucene", "Umbraco.Examine.Lucene\Umbraco.Examine.Lucene.csproj", "{0FAD7D2A-D7DD-45B1-91FD-488BB6CDACEA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.Web.BackOffice", "Umbraco.Web.BackOffice\Umbraco.Web.BackOffice.csproj", "{9B95EEF7-63FE-4432-8C63-166BE9C1A929}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Umbraco.Web.BackOffice", "Umbraco.Web.BackOffice\Umbraco.Web.BackOffice.csproj", "{9B95EEF7-63FE-4432-8C63-166BE9C1A929}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.Abstractions", "Umbraco.Abstractions\Umbraco.Abstractions.csproj", "{D369E986-00D5-4F49-9B2D-E7A8F0C9EEDD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -177,6 +179,10 @@ Global
{9B95EEF7-63FE-4432-8C63-166BE9C1A929}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9B95EEF7-63FE-4432-8C63-166BE9C1A929}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9B95EEF7-63FE-4432-8C63-166BE9C1A929}.Release|Any CPU.Build.0 = Release|Any CPU
{D369E986-00D5-4F49-9B2D-E7A8F0C9EEDD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D369E986-00D5-4F49-9B2D-E7A8F0C9EEDD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D369E986-00D5-4F49-9B2D-E7A8F0C9EEDD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D369E986-00D5-4F49-9B2D-E7A8F0C9EEDD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE