diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj
index 8c56a05169..616bfa96b6 100644
--- a/src/Umbraco.Tests/Umbraco.Tests.csproj
+++ b/src/Umbraco.Tests/Umbraco.Tests.csproj
@@ -458,9 +458,6 @@
-
-
-
$(NuGetPackageFolders.Split(';')[0])
diff --git a/src/Umbraco.Web/Composing/LightInject/LightInjectContainer.cs b/src/Umbraco.Web/Composing/LightInject/LightInjectContainer.cs
deleted file mode 100644
index 863e406067..0000000000
--- a/src/Umbraco.Web/Composing/LightInject/LightInjectContainer.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-using System;
-using System.Web.Http;
-using LightInject;
-using LightInject.Web;
-using Umbraco.Core.Composing.LightInject;
-
-namespace Umbraco.Web.Composing.LightInject
-{
- ///
- /// Implements DI with LightInject.
- ///
- public class LightInjectContainer : Core.Composing.LightInject.LightInjectContainer
- {
- ///
- /// Initializes a new instance of the with a LightInject container.
- ///
- protected LightInjectContainer(ServiceContainer container)
- : base(container)
- { }
-
- ///
- /// Creates a new instance of the class.
- ///
- public new static LightInjectContainer Create()
- => new LightInjectContainer(CreateServiceContainer());
-
- ///
- /// Overridden to supply the .Net Framework based PerWebRequestScopeManagerProvider
- ///
- public override void EnablePerWebRequestScope()
- {
- if (!(Container.ScopeManagerProvider is MixedLightInjectScopeManagerProvider smp))
- throw new Exception("Container.ScopeManagerProvider is not MixedLightInjectScopeManagerProvider.");
- smp.EnablePerWebRequestScope(new PerWebRequestScopeManagerProvider());
- }
-
- ///
- public override void ConfigureForWeb()
- {
- // IoC setup for LightInject for MVC/WebApi
- // see comments on MixedLightInjectScopeManagerProvider for explanations of what we are doing here
- if (!(Container.ScopeManagerProvider is MixedLightInjectScopeManagerProvider smp))
- throw new Exception("Container.ScopeManagerProvider is not MixedLightInjectScopeManagerProvider.");
- Container.EnableMvc(); // does container.EnablePerWebRequestScope()
- Container.ScopeManagerProvider = smp; // reverts - we will do it last (in WebRuntime)
- Container.EnableWebApi(GlobalConfiguration.Configuration);
- }
- }
-}
diff --git a/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs b/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs
deleted file mode 100644
index bfb2448926..0000000000
--- a/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs
+++ /dev/null
@@ -1,297 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Linq;
-using System.Runtime.Serialization;
-using System.Web;
-using System.Web.Mvc;
-using Microsoft.Extensions.Options;
-using Umbraco.Core;
-using Umbraco.Core.Configuration;
-using Umbraco.Core.Configuration.Models;
-using Umbraco.Core.Hosting;
-using Umbraco.Core.Media;
-using Umbraco.Core.WebAssets;
-using Umbraco.Web.Features;
-using Umbraco.Web.Mvc;
-using Umbraco.Web.Security;
-using Umbraco.Web.Trees;
-using Constants = Umbraco.Core.Constants;
-
-namespace Umbraco.Web.Editors
-{
- ///
- /// Used to collect the server variables for use in the back office angular app
- ///
- internal class BackOfficeServerVariables
- {
- private readonly UrlHelper _urlHelper;
- private readonly IRuntimeState _runtimeState;
- private readonly UmbracoFeatures _features;
- private readonly GlobalSettings _globalSettings;
- private readonly IUmbracoVersion _umbracoVersion;
- private readonly ContentSettings _contentSettings;
- private readonly TreeCollection _treeCollection;
- private readonly IHttpContextAccessor _httpContextAccessor;
- private readonly IHostingEnvironment _hostingEnvironment;
- private readonly RuntimeSettings _settings;
- private readonly SecuritySettings _securitySettings;
- private readonly IRuntimeMinifier _runtimeMinifier;
- private readonly IImageUrlGenerator _imageUrlGenerator;
-
- internal BackOfficeServerVariables(
- UrlHelper urlHelper,
- IRuntimeState runtimeState,
- UmbracoFeatures features,
- GlobalSettings globalSettings,
- IUmbracoVersion umbracoVersion,
- IOptions contentSettings,
- TreeCollection treeCollection,
- IHostingEnvironment hostingEnvironment,
- IOptions settings,
- IOptions securitySettings,
- IRuntimeMinifier runtimeMinifier,
- IImageUrlGenerator imageUrlGenerator)
- {
- _urlHelper = urlHelper;
- _runtimeState = runtimeState;
- _features = features;
- _globalSettings = globalSettings;
- _umbracoVersion = umbracoVersion;
- _contentSettings = contentSettings.Value ?? throw new ArgumentNullException(nameof(contentSettings));
- _treeCollection = treeCollection ?? throw new ArgumentNullException(nameof(treeCollection));
- _hostingEnvironment = hostingEnvironment;
- _settings = settings.Value;
- _securitySettings = securitySettings.Value;
- _runtimeMinifier = runtimeMinifier;
- _imageUrlGenerator = imageUrlGenerator;
- }
-
- ///
- /// Returns the server variables for non-authenticated users
- ///
- ///
- internal Dictionary BareMinimumServerVariables()
- {
- //this is the filter for the keys that we'll keep based on the full version of the server vars
- var keepOnlyKeys = new Dictionary
- {
- {"umbracoUrls", new[] {"authenticationApiBaseUrl", "serverVarsJs", "externalLoginsUrl", "currentUserApiBaseUrl", "iconApiBaseUrl"}},
- {"umbracoSettings", new[] {"allowPasswordReset", "imageFileTypes", "maxFileSize", "loginBackgroundImage", "canSendRequiredEmail", "usernameIsEmail"}},
- {"application", new[] {"applicationPath", "cacheBuster"}},
- {"isDebuggingEnabled", new string[] { }},
- {"features", new [] {"disabledFeatures"}}
- };
- //now do the filtering...
- var defaults = GetServerVariables();
- foreach (var key in defaults.Keys.ToArray())
- {
- if (keepOnlyKeys.ContainsKey(key) == false)
- {
- defaults.Remove(key);
- }
- else
- {
- var asDictionary = defaults[key] as IDictionary;
- if (asDictionary != null)
- {
- var toKeep = keepOnlyKeys[key];
- foreach (var k in asDictionary.Keys.Cast().ToArray())
- {
- if (toKeep.Contains(k) == false)
- {
- asDictionary.Remove(k);
- }
- }
- }
- }
- }
-
- // TODO: This is ultra confusing! this same key is used for different things, when returning the full app when authenticated it is this URL but when not auth'd it's actually the ServerVariables address
- // so based on compat and how things are currently working we need to replace the serverVarsJs one
- ((Dictionary)defaults["umbracoUrls"])["serverVarsJs"] = _urlHelper.Action("ServerVariables", "BackOffice");
-
- return defaults;
- }
-
- ///
- /// Returns the server variables for authenticated users
- ///
- ///
- internal Dictionary GetServerVariables()
- {
- var globalSettings = _globalSettings;
- var defaultVals = new Dictionary
- {
- {
- "umbracoUrls", new Dictionary
- {
- // TODO: Add 'umbracoApiControllerBaseUrl' which people can use in JS
- // to prepend their URL. We could then also use this in our own resources instead of
- // having each url defined here explicitly - we can do that in v8! for now
- // for umbraco services we'll stick to explicitly defining the endpoints.
-
- {"externalLoginsUrl", _urlHelper.Action("ExternalLogin", "BackOffice")},
- {"externalLinkLoginsUrl", _urlHelper.Action("LinkLogin", "BackOffice")},
- {"gridConfig", _urlHelper.Action("GetGridConfig", "BackOffice")},
- // TODO: This is ultra confusing! this same key is used for different things, when returning the full app when authenticated it is this URL but when not auth'd it's actually the ServerVariables address
- {"serverVarsJs", _urlHelper.Action("Application", "BackOffice")},
- //API URLs
- {
- "packagesRestApiBaseUrl", Constants.PackageRepository.RestApiBaseUrl
- },
-
- }
- },
- {
- "umbracoSettings", new Dictionary
- {
- {"umbracoPath", _globalSettings.GetBackOfficePath(_hostingEnvironment)},
- {"mediaPath", _hostingEnvironment.ToAbsolute(globalSettings.UmbracoMediaPath).TrimEnd('/')},
- {"appPluginsPath", _hostingEnvironment.ToAbsolute(Constants.SystemDirectories.AppPlugins).TrimEnd('/')},
- {
- "imageFileTypes",
- string.Join(",", _imageUrlGenerator.SupportedImageFileTypes)
- },
- {
- "disallowedUploadFiles",
- string.Join(",", _contentSettings.DisallowedUploadFiles)
- },
- {
- "allowedUploadFiles",
- string.Join(",", _contentSettings.AllowedUploadFiles)
- },
- {
- "maxFileSize",
- GetMaxRequestLength()
- },
- {"keepUserLoggedIn", _securitySettings.KeepUserLoggedIn},
- {"usernameIsEmail", _securitySettings.UsernameIsEmail},
- {"cssPath", _hostingEnvironment.ToAbsolute(globalSettings.UmbracoCssPath).TrimEnd('/')},
- {"allowPasswordReset", _securitySettings.AllowPasswordReset},
- {"loginBackgroundImage", _contentSettings.LoginBackgroundImage},
- {"showUserInvite", EmailSender.CanSendRequiredEmail(globalSettings)},
- {"canSendRequiredEmail", EmailSender.CanSendRequiredEmail(globalSettings)},
- {"showAllowSegmentationForDocumentTypes", false},
- }
- },
- {
- "umbracoPlugins", new Dictionary
- {
- // for each tree that is [PluginController], get
- // alias -> areaName
- // so that routing (route.js) can look for views
- { "trees", GetPluginTrees().ToArray() }
- }
- },
- {
- "isDebuggingEnabled", _hostingEnvironment.IsDebugMode
- },
- {
- "application", GetApplicationState()
- },
- {
- "externalLogins", new Dictionary
- {
- {
- "providers", _httpContextAccessor.GetRequiredHttpContext().GetOwinContext().Authentication.GetExternalAuthenticationTypes()
- .Where(p => p.Properties.ContainsKey("UmbracoBackOffice"))
- .Select(p => new
- {
- authType = p.AuthenticationType, caption = p.Caption,
- // TODO: Need to see if this exposes any sensitive data!
- properties = p.Properties
- })
- .ToArray()
- }
- }
- },
- {
- "features", new Dictionary
- {
- {
- "disabledFeatures", new Dictionary
- {
- { "disableTemplates", _features.Disabled.DisableTemplates}
- }
- }
-
- }
- }
- };
- return defaultVals;
- }
-
- [DataContract]
- private class PluginTree
- {
- [DataMember(Name = "alias")]
- public string Alias { get; set; }
-
- [DataMember(Name = "packageFolder")]
- public string PackageFolder { get; set; }
- }
-
- private IEnumerable GetPluginTrees()
- {
- // used to be (cached)
- //var treeTypes = Current.TypeLoader.GetAttributedTreeControllers();
- //
- // ie inheriting from TreeController and marked with TreeAttribute
- //
- // do this instead
- // inheriting from TreeControllerBase and marked with TreeAttribute
-
- foreach (var tree in _treeCollection)
- {
- var treeType = tree.TreeControllerType;
-
- // exclude anything marked with CoreTreeAttribute
- var coreTree = treeType.GetCustomAttribute(false);
- if (coreTree != null) continue;
-
- // exclude anything not marked with PluginControllerAttribute
- var pluginController = treeType.GetCustomAttribute(false);
- if (pluginController == null) continue;
-
- yield return new PluginTree { Alias = tree.TreeAlias, PackageFolder = pluginController.AreaName };
- }
- }
-
- ///
- /// Returns the server variables regarding the application state
- ///
- ///
- private Dictionary GetApplicationState()
- {
- var app = new Dictionary
- {
- // add versions - see UmbracoVersion for details & differences
-
- // the complete application version (eg "8.1.2-alpha.25")
- { "version", _umbracoVersion.SemanticVersion.ToSemanticString() },
-
- // the assembly version (eg "8.0.0")
- { "assemblyVersion", _umbracoVersion.AssemblyVersion.ToString() }
- };
-
- var version = _runtimeState.SemanticVersion.ToSemanticString();
-
- //the value is the hash of the version, cdf version and the configured state
- app.Add("cacheBuster", $"{version}.{_runtimeState.Level}.{_runtimeMinifier.CacheBuster}".GenerateHash());
-
- //useful for dealing with virtual paths on the client side when hosted in virtual directories especially
- app.Add("applicationPath", _httpContextAccessor.GetRequiredHttpContext().Request.ApplicationPath.EnsureEndsWith('/'));
-
- //add the server's GMT time offset in minutes
- app.Add("serverTimeOffset", Convert.ToInt32(DateTimeOffset.Now.Offset.TotalMinutes));
-
- return app;
- }
-
- private string GetMaxRequestLength()
- {
- return _settings.MaxRequestLength.HasValue ? _settings.MaxRequestLength.Value.ToString() : string.Empty;
- }
- }
-}
diff --git a/src/Umbraco.Web/Editors/UmbracoAuthorizedJsonController.cs b/src/Umbraco.Web/Editors/UmbracoAuthorizedJsonController.cs
deleted file mode 100644
index 4cd5a76fa4..0000000000
--- a/src/Umbraco.Web/Editors/UmbracoAuthorizedJsonController.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-using System;
-using Microsoft.Extensions.Options;
-using Umbraco.Core;
-using Umbraco.Core.Cache;
-using Umbraco.Core.Configuration;
-using Umbraco.Core.Configuration.Models;
-using Umbraco.Core.Logging;
-using Umbraco.Core.Mapping;
-using Umbraco.Core.Persistence;
-using Umbraco.Core.Services;
-using Umbraco.Core.Strings;
-using Umbraco.Web.Composing;
-using Umbraco.Web.Routing;
-using Umbraco.Web.WebApi;
-using Umbraco.Web.WebApi.Filters;
-
-namespace Umbraco.Web.Editors
-{
- ///
- /// An abstract API controller that only supports JSON and all requests must contain the correct csrf header
- ///
- ///
- /// Inheriting from this controller means that ALL of your methods are JSON methods that are called by Angular,
- /// methods that are not called by Angular or don't contain a valid csrf header will NOT work.
- ///
- [ValidateAngularAntiForgeryToken]
- [AngularJsonOnlyConfiguration]
- public abstract class UmbracoAuthorizedJsonController : UmbracoAuthorizedApiController
- {
- protected UmbracoAuthorizedJsonController()
- {
- ShortStringHelper = Current.ShortStringHelper;
- }
-
- protected UmbracoAuthorizedJsonController(
- GlobalSettings globalSettings,
- IUmbracoContextAccessor umbracoContextAccessor,
- ISqlContext sqlContext,
- ServiceContext services,
- AppCaches appCaches,
- IProfilingLogger logger,
- IRuntimeState runtimeState,
- IShortStringHelper shortStringHelper,
- UmbracoMapper umbracoMapper,
- IPublishedUrlProvider publishedUrlProvider)
- : base(globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoMapper, publishedUrlProvider)
- {
- ShortStringHelper = shortStringHelper ?? throw new ArgumentNullException(nameof(shortStringHelper));
- }
-
- protected IShortStringHelper ShortStringHelper { get; }
- }
-}
diff --git a/src/Umbraco.Web/FormDataCollectionExtensions.cs b/src/Umbraco.Web/FormDataCollectionExtensions.cs
deleted file mode 100644
index 3f2840c8ca..0000000000
--- a/src/Umbraco.Web/FormDataCollectionExtensions.cs
+++ /dev/null
@@ -1,104 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Net.Http.Formatting;
-using System.Text;
-using Umbraco.Core;
-
-namespace Umbraco.Web
-{
- // Migrated to .NET Core (as FormCollectionExtensions)
- public static class FormDataCollectionExtensions
- {
- ///
- /// Converts a dictionary object to a query string representation such as:
- /// firstname=shannon&lastname=deminick
- ///
- ///
- /// Any keys found in this collection will be removed from the output
- ///
- public static string ToQueryString(this FormDataCollection items, params string[] keysToIgnore)
- {
- if (items == null) return "";
- if (items.Any() == false) return "";
-
- var builder = new StringBuilder();
- foreach (var i in items.Where(i => keysToIgnore.InvariantContains(i.Key) == false))
- {
- builder.Append(string.Format("{0}={1}&", i.Key, i.Value));
- }
- return builder.ToString().TrimEnd('&');
- }
-
- ///
- /// Converts the FormCollection to a dictionary
- ///
- ///
- ///
- public static IDictionary ToDictionary(this FormDataCollection items)
- {
- return items.ToDictionary(x => x.Key, x => (object)x.Value);
- }
-
- ///
- /// Returns the value of a mandatory item in the FormCollection
- ///
- ///
- ///
- ///
- public static string GetRequiredString(this FormDataCollection items, string key)
- {
- if (items.HasKey(key) == false)
- throw new ArgumentNullException("The " + key + " query string parameter was not found but is required");
- return items.Single(x => x.Key.InvariantEquals(key)).Value;
- }
-
- ///
- /// Checks if the collection contains the key
- ///
- ///
- ///
- ///
- public static bool HasKey(this FormDataCollection items, string key)
- {
- return items.Any(x => x.Key.InvariantEquals(key));
- }
-
- ///
- /// Returns the object based in the collection based on it's key. This does this with a conversion so if it doesn't convert a null object is returned.
- ///
- ///
- ///
- ///
- ///
- public static T GetValue(this FormDataCollection items, string key)
- {
- var val = items.Get(key);
- if (string.IsNullOrEmpty(val)) return default(T);
-
- var converted = val.TryConvertTo();
- return converted.Success
- ? converted.Result
- : default(T);
- }
-
- ///
- /// Returns the object based in the collection based on it's key. This does this with a conversion so if it doesn't convert or the query string is no there an exception is thrown
- ///
- ///
- ///
- ///
- ///
- public static T GetRequiredValue(this FormDataCollection items, string key)
- {
- var val = items.Get(key);
- if (string.IsNullOrEmpty(val))
- throw new InvalidOperationException($"The required query string parameter {key} is missing");
-
- var converted = val.TryConvertTo();
- return converted.Success
- ? converted.Result
- : throw new InvalidOperationException($"The required query string parameter {key} cannot be converted to type {typeof(T)}");
- }
- }
-}
diff --git a/src/Umbraco.Web/Mvc/JsonNetResult.cs b/src/Umbraco.Web/Mvc/JsonNetResult.cs
deleted file mode 100644
index c086b5f375..0000000000
--- a/src/Umbraco.Web/Mvc/JsonNetResult.cs
+++ /dev/null
@@ -1,57 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Web;
-using System.Web.Mvc;
-using Newtonsoft.Json;
-
-namespace Umbraco.Web.Mvc
-{
-
- ///
- /// Custom json result using newtonsoft json.net
- ///
- /// Migrated already to .Net Core
- public class JsonNetResult : ActionResult
- {
- public Encoding ContentEncoding { get; set; }
- public string ContentType { get; set; }
- public object Data { get; set; }
-
- public JsonSerializerSettings SerializerSettings { get; set; }
- public Formatting Formatting { get; set; }
-
- public JsonNetResult()
- {
- SerializerSettings = new JsonSerializerSettings();
- }
-
- public override void ExecuteResult(ControllerContext context)
- {
- if (context == null)
- throw new ArgumentNullException("context");
-
- HttpResponseBase response = context.HttpContext.Response;
-
- response.ContentType = string.IsNullOrEmpty(ContentType) == false
- ? ContentType
- : "application/json";
-
- if (ContentEncoding != null)
- response.ContentEncoding = ContentEncoding;
-
- if (Data != null)
- {
- var writer = new JsonTextWriter(response.Output) { Formatting = Formatting };
-
- var serializer = JsonSerializer.Create(SerializerSettings);
- serializer.Serialize(writer, Data);
-
- writer.Flush();
- }
- }
- }
-
-}
diff --git a/src/Umbraco.Web/Mvc/MinifyJavaScriptResultAttribute.cs b/src/Umbraco.Web/Mvc/MinifyJavaScriptResultAttribute.cs
deleted file mode 100644
index 635a7314c5..0000000000
--- a/src/Umbraco.Web/Mvc/MinifyJavaScriptResultAttribute.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-using System.Web.Mvc;
-using Umbraco.Web.Composing;
-using Umbraco.Core.Hosting;
-using Umbraco.Core.Runtime;
-using Umbraco.Core.WebAssets;
-
-namespace Umbraco.Web.Mvc
-{
- ///
- /// Minifies the result for the JavaScriptResult
- ///
- ///
- /// Only minifies in release mode
- ///
- /// Migrated already to .Net Core
- public class MinifyJavaScriptResultAttribute : ActionFilterAttribute
- {
- private readonly IHostingEnvironment _hostingEnvironment;
- private readonly IRuntimeMinifier _runtimeMinifier;
-
- public MinifyJavaScriptResultAttribute()
- {
- _hostingEnvironment = Current.HostingEnvironment;
- _runtimeMinifier = Current.RuntimeMinifier;
- }
-
- public MinifyJavaScriptResultAttribute(IHostingEnvironment hostingEnvironment, IRuntimeMinifier runtimeMinifier)
- {
- _hostingEnvironment = hostingEnvironment;
- _runtimeMinifier = runtimeMinifier;
- }
-
- ///
- /// Minify the result if in release mode
- ///
- ///
- public override void OnResultExecuting(ResultExecutingContext filterContext)
- {
- base.OnResultExecuting(filterContext);
-
- if (filterContext.Result == null) return;
- var jsResult = filterContext.Result as JavaScriptResult;
- if (jsResult == null) return;
- if (_hostingEnvironment.IsDebugMode) return;
-
- //minify the result
- var result = jsResult.Script;
- var minified = _runtimeMinifier.MinifyAsync(result, AssetType.Javascript).GetAwaiter().GetResult();
- jsResult.Script = minified;
- }
- }
-}
diff --git a/src/Umbraco.Web/Mvc/UmbracoViewPage.cs b/src/Umbraco.Web/Mvc/UmbracoViewPage.cs
deleted file mode 100644
index a41d692b86..0000000000
--- a/src/Umbraco.Web/Mvc/UmbracoViewPage.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System.Web.WebPages;
-using Umbraco.Core.Models.PublishedContent;
-
-namespace Umbraco.Web.Mvc
-{
- public abstract class UmbracoViewPage : UmbracoViewPage
- {
-
- }
-}
diff --git a/src/Umbraco.Web/Security/ConfiguredPasswordValidator.cs b/src/Umbraco.Web/Security/ConfiguredPasswordValidator.cs
deleted file mode 100644
index bbc9722f69..0000000000
--- a/src/Umbraco.Web/Security/ConfiguredPasswordValidator.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using Microsoft.AspNet.Identity;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using Umbraco.Core.Configuration;
-
-namespace Umbraco.Core.Security
-{
- // NOTE: Migrated to netcore (in a different way)
- public interface IPasswordValidator
- {
- Task>> ValidateAsync(IPasswordConfiguration config, string password);
- }
-
- // NOTE: Migrated to netcore (in a different way)
- public class ConfiguredPasswordValidator : PasswordValidator, IPasswordValidator
- {
- async Task>> IPasswordValidator.ValidateAsync(IPasswordConfiguration passwordConfiguration, string password)
- {
- RequiredLength = passwordConfiguration.RequiredLength;
- RequireNonLetterOrDigit = passwordConfiguration.RequireNonLetterOrDigit;
- RequireDigit = passwordConfiguration.RequireDigit;
- RequireLowercase = passwordConfiguration.RequireLowercase;
- RequireUppercase = passwordConfiguration.RequireUppercase;
-
- var result = await ValidateAsync(password);
- if (result.Succeeded)
- return Attempt>.Succeed();
- return Attempt>.Fail(result.Errors);
- }
- }
-}
diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj
index 2395fa254c..d7bd025e2a 100644
--- a/src/Umbraco.Web/Umbraco.Web.csproj
+++ b/src/Umbraco.Web/Umbraco.Web.csproj
@@ -148,7 +148,6 @@
-
@@ -163,7 +162,6 @@
-
@@ -191,7 +189,6 @@
-
@@ -211,14 +208,12 @@
-
-
@@ -236,7 +231,6 @@
-
@@ -270,10 +264,7 @@
-
-
-
@@ -283,8 +274,6 @@
-
-
@@ -294,9 +283,7 @@
-
-
@@ -314,14 +301,9 @@
-
-
-
-
-
diff --git a/src/Umbraco.Web/WebApi/Filters/AppendUserModifiedHeaderAttribute.cs b/src/Umbraco.Web/WebApi/Filters/AppendUserModifiedHeaderAttribute.cs
deleted file mode 100644
index 95e1a94787..0000000000
--- a/src/Umbraco.Web/WebApi/Filters/AppendUserModifiedHeaderAttribute.cs
+++ /dev/null
@@ -1,78 +0,0 @@
-using System;
-using System.Web.Http.Filters;
-using Umbraco.Core;
-using Umbraco.Core.Models;
-using Umbraco.Web.Composing;
-
-namespace Umbraco.Web.WebApi.Filters
-{
- ///
- /// Appends a custom response header to notify the UI that the current user data has been modified
- ///
- /// Migrated to NET core
- public sealed class AppendUserModifiedHeaderAttribute : ActionFilterAttribute
- {
- private readonly string _userIdParameter;
-
- ///
- /// An empty constructor which will always set the header
- ///
- public AppendUserModifiedHeaderAttribute()
- {
- }
-
- ///
- /// A constructor specifying the action parameter name containing the user id to match against the current user and if they match the header will be appended
- ///
- ///
- public AppendUserModifiedHeaderAttribute(string userIdParameter)
- {
- if (userIdParameter == null) throw new ArgumentNullException("userIdParameter");
- _userIdParameter = userIdParameter;
- }
-
- public static void AppendHeader(HttpActionExecutedContext actionExecutedContext)
- {
- if (actionExecutedContext.Response.Headers.Contains("X-Umb-User-Modified") == false)
- {
- actionExecutedContext.Response.Headers.Add("X-Umb-User-Modified", "1");
- }
- }
-
- public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
- {
- base.OnActionExecuted(actionExecutedContext);
-
- if (_userIdParameter.IsNullOrWhiteSpace())
- {
- AppendHeader(actionExecutedContext);
- }
- else
- {
- var actionContext = actionExecutedContext.ActionContext;
- if (actionContext.ActionArguments[_userIdParameter] == null)
- {
- throw new InvalidOperationException("No argument found for the current action with the name: " + _userIdParameter);
- }
-
- var user = Current.UmbracoContext.Security.CurrentUser;
- if (user == null) return;
-
- var userId = GetUserIdFromParameter(actionContext.ActionArguments[_userIdParameter]);
-
- if (userId == user.Id)
- AppendHeader(actionExecutedContext);
- }
-
- }
-
- private int GetUserIdFromParameter(object parameterValue)
- {
- if (parameterValue is int)
- {
- return (int)parameterValue;
- }
- throw new InvalidOperationException("The id type: " + parameterValue.GetType() + " is not a supported id");
- }
- }
-}
diff --git a/src/Umbraco.Web/WebApi/Filters/DisableBrowserCacheAttribute.cs b/src/Umbraco.Web/WebApi/Filters/DisableBrowserCacheAttribute.cs
deleted file mode 100644
index cfb7ddb6bc..0000000000
--- a/src/Umbraco.Web/WebApi/Filters/DisableBrowserCacheAttribute.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-using System;
-using System.Net.Http.Headers;
-using System.Web.Http.Filters;
-
-namespace Umbraco.Web.WebApi.Filters
-{
- ///
- /// Ensures that the request is not cached by the browser
- ///
- public class DisableBrowserCacheAttribute : ActionFilterAttribute
- {
- public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
- {
- //See: http://stackoverflow.com/questions/17755239/how-to-stop-chrome-from-caching-rest-response-from-webapi
-
- base.OnActionExecuted(actionExecutedContext);
- if (actionExecutedContext == null || actionExecutedContext.Response == null ||
- actionExecutedContext.Response.Headers == null)
- {
- return;
- }
- //NOTE: Until we upgraded to WebApi 2, this didn't work correctly and we had to revert to using
- // HttpContext.Current responses. I've changed this back to what it should be now since it works
- // and now with WebApi2, the HttpContext.Current responses don't! Anyways, all good now.
- actionExecutedContext.Response.Headers.CacheControl = new CacheControlHeaderValue()
- {
- NoCache = true,
- NoStore = true,
- MaxAge = new TimeSpan(0),
- MustRevalidate = true
- };
-
- actionExecutedContext.Response.Headers.Pragma.Add(new NameValueHeaderValue("no-cache"));
- if (actionExecutedContext.Response.Content != null)
- {
- actionExecutedContext.Response.Content.Headers.Expires =
- //Mon, 01 Jan 1990 00:00:00 GMT
- new DateTimeOffset(1990, 1, 1, 0, 0, 0, TimeSpan.Zero);
- }
- }
- }
-}
diff --git a/src/Umbraco.Web/WebApi/Filters/FileUploadCleanupFilterAttribute.cs b/src/Umbraco.Web/WebApi/Filters/FileUploadCleanupFilterAttribute.cs
deleted file mode 100644
index b12fc51ca6..0000000000
--- a/src/Umbraco.Web/WebApi/Filters/FileUploadCleanupFilterAttribute.cs
+++ /dev/null
@@ -1,151 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Net.Http;
-using System.Web.Http.Filters;
-using Microsoft.Extensions.Logging;
-using Umbraco.Core;
-using Umbraco.Core.Models;
-using Umbraco.Web.Composing;
-using Umbraco.Web.Models.ContentEditing;
-using File = System.IO.File;
-
-namespace Umbraco.Web.WebApi.Filters
-{
- ///
- /// Checks if the parameter is IHaveUploadedFiles and then deletes any temporary saved files from file uploads associated with the request
- ///
- internal sealed class FileUploadCleanupFilterAttribute : ActionFilterAttribute
- {
- private readonly bool _incomingModel;
-
- ///
- /// Constructor specifies if the filter should analyze the incoming or outgoing model
- ///
- ///
- public FileUploadCleanupFilterAttribute(bool incomingModel = true)
- {
- _incomingModel = incomingModel;
- }
-
- public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
- {
- base.OnActionExecuted(actionExecutedContext);
-
- var tempFolders = new List();
-
- if (_incomingModel)
- {
- if (actionExecutedContext.ActionContext.ActionArguments.Any())
- {
- if (actionExecutedContext.ActionContext.ActionArguments.First().Value is IHaveUploadedFiles contentItem)
- {
- //cleanup any files associated
- foreach (var f in contentItem.UploadedFiles)
- {
- //track all temp folders so we can remove old files afterwards
- var dir = Path.GetDirectoryName(f.TempFilePath);
- if (tempFolders.Contains(dir) == false)
- {
- tempFolders.Add(dir);
- }
-
- try
- {
- File.Delete(f.TempFilePath);
- }
- catch (System.Exception ex)
- {
- Current.Logger.LogError(ex, "Could not delete temp file {FileName}", f.TempFilePath);
- }
- }
- }
- }
- }
- else
- {
- if (actionExecutedContext == null)
- {
- Current.Logger.LogWarning("The actionExecutedContext is null!!??");
- return;
- }
- if (actionExecutedContext.Request == null)
- {
- Current.Logger.LogWarning("The actionExecutedContext.Request is null!!??");
- return;
- }
- if (actionExecutedContext.Request.Content == null)
- {
- Current.Logger.LogWarning("The actionExecutedContext.Request.Content is null!!??");
- return;
- }
-
- ObjectContent objectContent;
-
- try
- {
- objectContent = actionExecutedContext.Response.Content as ObjectContent;
- }
- catch (System.Exception ex)
- {
- Current.Logger.LogError(ex, "Could not acquire actionExecutedContext.Response.Content");
- return;
- }
-
- if (objectContent != null)
- {
- if (objectContent.Value is IHaveUploadedFiles uploadedFiles)
- {
- if (uploadedFiles.UploadedFiles != null)
- {
- //cleanup any files associated
- foreach (var f in uploadedFiles.UploadedFiles)
- {
- if (f.TempFilePath.IsNullOrWhiteSpace() == false)
- {
- //track all temp folders so we can remove old files afterwards
- var dir = Path.GetDirectoryName(f.TempFilePath);
- if (tempFolders.Contains(dir) == false)
- {
- tempFolders.Add(dir);
- }
-
- Current.Logger.LogDebug("Removing temp file {FileName}", f.TempFilePath);
-
- try
- {
- File.Delete(f.TempFilePath);
- }
- catch (System.Exception ex)
- {
- Current.Logger.LogError(ex, "Could not delete temp file {FileName}", f.TempFilePath);
- }
-
- //clear out the temp path so it's not returned in the response
- f.TempFilePath = "";
- }
- else
- {
- Current.Logger.LogWarning("The f.TempFilePath is null or whitespace!!??");
- }
- }
- }
- else
- {
- Current.Logger.LogWarning("The uploadedFiles.UploadedFiles is null!!??");
- }
- }
- else
- {
- Current.Logger.LogWarning("The actionExecutedContext.Request.Content.Value is not IHaveUploadedFiles, it is {ObjectType}", objectContent.Value.GetType());
- }
- }
- else
- {
- Current.Logger.LogWarning("The actionExecutedContext.Request.Content is not ObjectContent, it is {RequestObjectType}", actionExecutedContext.Request.Content.GetType());
- }
- }
- }
- }
-}
diff --git a/src/Umbraco.Web/WebApi/Filters/FilterGrouping.cs b/src/Umbraco.Web/WebApi/Filters/FilterGrouping.cs
deleted file mode 100644
index fc3dc65675..0000000000
--- a/src/Umbraco.Web/WebApi/Filters/FilterGrouping.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Web.Http.Filters;
-
-namespace Umbraco.Web.WebApi.Filters
-{
- ///
- /// Quickly split filters into different types
- ///
- internal class FilterGrouping
- {
- private readonly List _actionFilters = new List();
- private readonly List _authorizationFilters = new List();
- private readonly List _exceptionFilters = new List();
-
- public FilterGrouping(IEnumerable filters)
- {
- if (filters == null) throw new ArgumentNullException("filters");
-
- foreach (FilterInfo f in filters)
- {
- var filter = f.Instance;
- Categorize(filter, _actionFilters);
- Categorize(filter, _authorizationFilters);
- Categorize(filter, _exceptionFilters);
- }
- }
-
- public IEnumerable ActionFilters
- {
- get { return _actionFilters; }
- }
-
- public IEnumerable AuthorizationFilters
- {
- get { return _authorizationFilters; }
- }
-
- public IEnumerable ExceptionFilters
- {
- get { return _exceptionFilters; }
- }
-
- private static void Categorize(IFilter filter, List list) where T : class
- {
- T match = filter as T;
- if (match != null)
- {
- list.Add(match);
- }
- }
- }
-}
diff --git a/src/Umbraco.Web/WebApi/Filters/HttpQueryStringModelBinder.cs b/src/Umbraco.Web/WebApi/Filters/HttpQueryStringModelBinder.cs
deleted file mode 100644
index 3b8e4bea3f..0000000000
--- a/src/Umbraco.Web/WebApi/Filters/HttpQueryStringModelBinder.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-using System.Net.Http.Formatting;
-using System.Web.Http.Controllers;
-using System.Web.Http.ModelBinding;
-using Umbraco.Core;
-
-namespace Umbraco.Web.WebApi.Filters
-{
- ///
- /// Allows an Action to execute with an arbitrary number of QueryStrings
- ///
- ///
- /// Just like you can POST an arbitrary number of parameters to an Action, you can't GET an arbitrary number
- /// but this will allow you to do it
- ///
- /// Migrated to .NET core
- public sealed class HttpQueryStringModelBinder : IModelBinder
- {
- public bool BindModel(HttpActionContext actionContext, ModelBindingContext bindingContext)
- {
- //get the query strings from the request properties
- if (actionContext.Request.Properties.ContainsKey("MS_QueryNameValuePairs"))
- {
- if (actionContext.Request.Properties["MS_QueryNameValuePairs"] is IEnumerable> queryStrings)
- {
- var queryStringKeys = queryStrings.Select(kvp => kvp.Key).ToArray();
- var additionalParameters = new Dictionary();
- if(queryStringKeys.InvariantContains("culture") == false) {
- additionalParameters["culture"] = actionContext.Request.ClientCulture();
- }
-
- var formData = new FormDataCollection(queryStrings.Union(additionalParameters));
- bindingContext.Model = formData;
- return true;
- }
- }
- return false;
- }
- }
-}
diff --git a/src/Umbraco.Web/WebApi/Filters/UmbracoApplicationAuthorizeAttribute.cs b/src/Umbraco.Web/WebApi/Filters/UmbracoApplicationAuthorizeAttribute.cs
deleted file mode 100644
index 37a8f8a4b4..0000000000
--- a/src/Umbraco.Web/WebApi/Filters/UmbracoApplicationAuthorizeAttribute.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-using System.Linq;
-using System.Web.Http;
-using System.Web.Http.Controllers;
-using Umbraco.Web.Composing;
-
-namespace Umbraco.Web.WebApi.Filters
-{
- ///
- /// Ensures that the current user has access to the specified application
- ///
- public sealed class UmbracoApplicationAuthorizeAttribute : OverridableAuthorizationAttribute
- {
- ///
- /// Can be used by unit tests to enable/disable this filter
- ///
- internal static bool Enable = true;
-
- private readonly string[] _appNames;
-
- ///
- /// Constructor to set any number of applications that the user needs access to be authorized
- ///
- ///
- /// If the user has access to any of the specified apps, they will be authorized.
- ///
- public UmbracoApplicationAuthorizeAttribute(params string[] appName)
- {
- _appNames = appName;
- }
-
- protected override bool IsAuthorized(HttpActionContext actionContext)
- {
- if (Enable == false)
- {
- return true;
- }
-
- var authorized = Current.UmbracoContext.Security.CurrentUser != null
- && _appNames.Any(app => Current.UmbracoContext.Security.UserHasSectionAccess(
- app, Current.UmbracoContext.Security.CurrentUser));
-
- return authorized;
- }
- }
-}
diff --git a/src/Umbraco.Web/WebApi/Filters/UmbracoTreeAuthorizeAttribute.cs b/src/Umbraco.Web/WebApi/Filters/UmbracoTreeAuthorizeAttribute.cs
deleted file mode 100644
index 07829648c3..0000000000
--- a/src/Umbraco.Web/WebApi/Filters/UmbracoTreeAuthorizeAttribute.cs
+++ /dev/null
@@ -1,57 +0,0 @@
-using System;
-using System.Linq;
-using System.Web.Http.Controllers;
-using System.Web.Http.Filters;
-using Umbraco.Core;
-using Umbraco.Web.Composing;
-
-//MOVED to netcore
-namespace Umbraco.Web.WebApi.Filters
-{
- ///
- /// Ensures that the current user has access to the application for which the specified tree(s) belongs
- ///
- ///
- /// This would allow a tree to be moved between sections
- ///
- public sealed class UmbracoTreeAuthorizeAttribute : OverridableAuthorizationAttribute
- {
- ///
- /// Can be used by unit tests to enable/disable this filter
- ///
- internal static bool Enable = true;
-
- private readonly string[] _treeAliases;
-
- ///
- /// Constructor to set authorization to be based on a tree alias for which application security will be applied
- ///
- ///
- /// If the user has access to the application that the treeAlias is specified in, they will be authorized.
- /// Multiple trees may be specified.
- ///
- public UmbracoTreeAuthorizeAttribute(params string[] treeAliases)
- {
- _treeAliases = treeAliases;
- }
-
- protected override bool IsAuthorized(HttpActionContext actionContext)
- {
- if (Enable == false)
- {
- return true;
- }
-
- var apps = _treeAliases.Select(x => Current.TreeService
- .GetByAlias(x))
- .WhereNotNull()
- .Select(x => x.SectionAlias)
- .Distinct()
- .ToArray();
-
- return Current.UmbracoContext.Security.CurrentUser != null
- && apps.Any(app => Current.UmbracoContext.Security.UserHasSectionAccess(
- app, Current.UmbracoContext.Security.CurrentUser));
- }
- }
-}
diff --git a/src/Umbraco.Web/WebApi/JsonCamelCaseFormatter.cs b/src/Umbraco.Web/WebApi/JsonCamelCaseFormatter.cs
deleted file mode 100644
index 62cde68cd4..0000000000
--- a/src/Umbraco.Web/WebApi/JsonCamelCaseFormatter.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using System;
-using System.Linq;
-using System.Net.Http.Formatting;
-using System.Web.Http.Controllers;
-using Newtonsoft.Json.Serialization;
-
-namespace Umbraco.Web.WebApi
-{
- ///
- /// Applying this attribute to any webapi controller will ensure that it only contains one json formatter with a camelCase formatter
- ///
- public class JsonCamelCaseFormatter : Attribute, IControllerConfiguration
- {
- public void Initialize(HttpControllerSettings controllerSettings, HttpControllerDescriptor controllerDescriptor)
- {
- //remove all json formatters then add our custom one
- var toRemove = controllerSettings.Formatters.Where(t => (t is JsonMediaTypeFormatter)).ToList();
- foreach (var r in toRemove)
- {
- controllerSettings.Formatters.Remove(r);
- }
-
- var jsonFormatter = new JsonMediaTypeFormatter
- {
- SerializerSettings =
- {
- ContractResolver = new CamelCasePropertyNamesContractResolver()
- }
- };
- controllerSettings.Formatters.Add(jsonFormatter);
- }
-
- }
-}
diff --git a/src/Umbraco.Web/WebApi/PrefixlessBodyModelValidator.cs b/src/Umbraco.Web/WebApi/PrefixlessBodyModelValidator.cs
deleted file mode 100644
index a9838f3413..0000000000
--- a/src/Umbraco.Web/WebApi/PrefixlessBodyModelValidator.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-using System;
-using System.Web.Http.Controllers;
-using System.Web.Http.Metadata;
-using System.Web.Http.Validation;
-
-namespace Umbraco.Web.WebApi
-{
- ///
- /// By default WebApi always appends a prefix to any ModelState error but we don't want this,
- /// so this is a custom validator that ensures there is no prefix set.
- ///
- ///
- /// We were already doing this with the content/media/members validation since we had to manually validate because we
- /// were posting multi-part values. We were always passing in an empty prefix so it worked. However for other editors we
- /// are validating with normal data annotations (for the most part) and we don't want the prefix there either.
- ///
- internal class PrefixlessBodyModelValidator : IBodyModelValidator
- {
- private readonly IBodyModelValidator _innerValidator;
-
- public PrefixlessBodyModelValidator(IBodyModelValidator innerValidator)
- {
- if (innerValidator == null)
- {
- throw new ArgumentNullException("innerValidator");
- }
-
- _innerValidator = innerValidator;
- }
-
- public bool Validate(object model, Type type, ModelMetadataProvider metadataProvider, HttpActionContext actionContext, string keyPrefix)
- {
- // Remove the keyPrefix but otherwise let innerValidator do what it normally does.
- return _innerValidator.Validate(model, type, metadataProvider, actionContext, string.Empty);
- }
- }
-}
diff --git a/src/Umbraco.Web/WebApi/PrefixlessBodyModelValidatorAttribute.cs b/src/Umbraco.Web/WebApi/PrefixlessBodyModelValidatorAttribute.cs
deleted file mode 100644
index b13cf983a5..0000000000
--- a/src/Umbraco.Web/WebApi/PrefixlessBodyModelValidatorAttribute.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System;
-using System.Web.Http;
-using System.Web.Http.Controllers;
-using System.Web.Http.Validation;
-
-namespace Umbraco.Web.WebApi
-{
- ///
- /// Applying this attribute to any webapi controller will ensure that the is of type
- ///
- internal class PrefixlessBodyModelValidatorAttribute : Attribute, IControllerConfiguration
- {
- public virtual void Initialize(HttpControllerSettings controllerSettings, HttpControllerDescriptor controllerDescriptor)
- {
- //replace the normal validator with our custom one for this controller
- controllerSettings.Services.Replace(typeof(IBodyModelValidator),
- new PrefixlessBodyModelValidator(controllerSettings.Services.GetBodyModelValidator()));
- }
- }
-}
diff --git a/src/Umbraco.Web/WebApi/UmbracoAuthorizedApiController.cs b/src/Umbraco.Web/WebApi/UmbracoAuthorizedApiController.cs
index 993fd36bc2..87627501bd 100644
--- a/src/Umbraco.Web/WebApi/UmbracoAuthorizedApiController.cs
+++ b/src/Umbraco.Web/WebApi/UmbracoAuthorizedApiController.cs
@@ -23,9 +23,9 @@ namespace Umbraco.Web.WebApi
[IsBackOffice]
// [UmbracoUserTimeoutFilter] has been migrated to netcore
[UmbracoAuthorize]
- [DisableBrowserCache]
- // [UmbracoWebApiRequireHttps]
- // [CheckIfUserTicketDataIsStale]
+ // [DisableBrowserCache] has been migrated to netcore
+ // [UmbracoWebApiRequireHttps]
+ // [CheckIfUserTicketDataIsStale]
// [UnhandedExceptionLoggerConfiguration]
[EnableDetailedErrors]
public abstract class UmbracoAuthorizedApiController : UmbracoApiController