diff --git a/src/Umbraco.Web.BackOffice/Extensions/UmbracoBuilderExtensions.cs b/src/Umbraco.Web.BackOffice/Extensions/UmbracoBuilderExtensions.cs index 79c7a9d29a..336855dd1b 100644 --- a/src/Umbraco.Web.BackOffice/Extensions/UmbracoBuilderExtensions.cs +++ b/src/Umbraco.Web.BackOffice/Extensions/UmbracoBuilderExtensions.cs @@ -30,7 +30,6 @@ namespace Umbraco.Extensions public static IUmbracoBuilder AddBackOffice(this IUmbracoBuilder builder) { builder.Services.AddAntiforgery(); - builder.Services.AddSingleton(); builder.Services .AddAuthentication() // This just creates a builder, nothing more diff --git a/src/Umbraco.Web.BackOffice/Filters/OverrideAuthorizationAttribute.cs b/src/Umbraco.Web.BackOffice/Filters/OverrideAuthorizationAttribute.cs deleted file mode 100644 index 3d7b68cc80..0000000000 --- a/src/Umbraco.Web.BackOffice/Filters/OverrideAuthorizationAttribute.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using Microsoft.AspNetCore.Mvc.Filters; - -namespace Umbraco.Web.BackOffice.Filters -{ - // TODO: This should probably be deleted, anything requiring this should move to a different controller - public class OverrideAuthorizationAttribute : ActionFilterAttribute - { - /// - /// Ensures a special type of authorization filter is ignored. Defaults to . - /// - /// The type of authorization filter to override. if null then is used. - /// - /// https://stackoverflow.com/questions/33558095/overrideauthorizationattribute-in-asp-net-5 - /// - public OverrideAuthorizationAttribute(Type filtersToOverride = null) - { - FiltersToOverride = filtersToOverride ?? typeof(IAuthorizationFilter); - } - - public Type FiltersToOverride { get;} - - - } -} diff --git a/src/Umbraco.Web.BackOffice/Filters/OverrideAuthorizationFilterProvider.cs b/src/Umbraco.Web.BackOffice/Filters/OverrideAuthorizationFilterProvider.cs deleted file mode 100644 index 39f691e190..0000000000 --- a/src/Umbraco.Web.BackOffice/Filters/OverrideAuthorizationFilterProvider.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Linq; -using Microsoft.AspNetCore.Mvc.Filters; -using Umbraco.Core; - -namespace Umbraco.Web.BackOffice.Filters -{ - // TODO: This should be deleted, anything requiring this should move to a different controller - public class OverrideAuthorizationFilterProvider : IFilterProvider, IFilterMetadata - { - public void OnProvidersExecuted(FilterProviderContext context) - { - - } - - public void OnProvidersExecuting(FilterProviderContext context) - { - if (context.ActionContext.ActionDescriptor.FilterDescriptors != null) - { - //Does the action have any UmbracoAuthorizeFilter? - var overrideFilters = context.Results.Where(filterItem => filterItem.Filter is OverrideAuthorizationAttribute).ToArray(); - foreach (var overrideFilter in overrideFilters) - { - context.Results.RemoveAll(filterItem => - //Remove any filter for the type indicated in the UmbracoAuthorizeFilter attribute - filterItem.Descriptor.Filter.GetType() == ((OverrideAuthorizationAttribute)overrideFilter.Filter).FiltersToOverride && - //Remove filters with lower scope (ie controller) than the override filter (ie action method) - filterItem.Descriptor.Scope < overrideFilter.Descriptor.Scope); - } - } - } - - //all framework providers have negative orders, so ours will come later - public int Order => 1; - } -} diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index e59eed272c..c2b8d8c38e 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -141,7 +141,6 @@ - diff --git a/src/Umbraco.Web/WebApi/Filters/EnableOverrideAuthorizationAttribute.cs b/src/Umbraco.Web/WebApi/Filters/EnableOverrideAuthorizationAttribute.cs deleted file mode 100644 index 358c9cc3b3..0000000000 --- a/src/Umbraco.Web/WebApi/Filters/EnableOverrideAuthorizationAttribute.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; - -namespace Umbraco.Web.WebApi.Filters -{ - /// - /// This allows for Action based auth attributes to override Class based auth attributes if they are specified - /// - /// - /// This attribute can be applied at the class level and will indicate to any class level auth attribute that inherits from OverridableAuthorizationAttribute - /// - [AttributeUsage(AttributeTargets.Class, Inherited = true, AllowMultiple = true)] - public sealed class EnableOverrideAuthorizationAttribute : Attribute - { - // TODO: we should remove this and use the System.Web.Http.OverrideAuthorizationAttribute which uses IOverrideFilter instead - } -} diff --git a/src/Umbraco.Web/WebApi/Filters/OverridableAuthorizationAttribute.cs b/src/Umbraco.Web/WebApi/Filters/OverridableAuthorizationAttribute.cs index 070bb53fb3..243611cca0 100644 --- a/src/Umbraco.Web/WebApi/Filters/OverridableAuthorizationAttribute.cs +++ b/src/Umbraco.Web/WebApi/Filters/OverridableAuthorizationAttribute.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Linq; using System.Web.Http; using System.Web.Http.Controllers; @@ -40,7 +40,7 @@ namespace Umbraco.Web.WebApi.Filters //if the controller is allowing authorization to be overridden at the action level and there are action level authorization attributes // then exit and let the action level auth attribute(s) execute. - if (actionContext.ActionDescriptor.ControllerDescriptor.GetCustomAttributes().Any() + if (actionContext.ActionDescriptor.ControllerDescriptor.GetCustomAttributes().Any() && actionAttributes.Any()) { return;