v9: Remove install endpoint as valid endpoint (#11710)

* Remove installer endpoint from valid candidates

* Removed unrelevant change
This commit is contained in:
Nikolaj Geisle
2021-12-02 10:01:23 +01:00
committed by Mole
parent 249d87297d
commit 6c5851f556
3 changed files with 23 additions and 3 deletions

View File

@@ -13,6 +13,7 @@ using Umbraco.Cms.Core.Security;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.WebAssets;
using Umbraco.Cms.Infrastructure.Install;
using Umbraco.Cms.Web.Common.Attributes;
using Umbraco.Cms.Web.Common.Filters;
using Umbraco.Extensions;
@@ -101,6 +102,7 @@ namespace Umbraco.Cms.Web.BackOffice.Install
/// </summary>
/// <returns></returns>
[HttpGet]
[IgnoreFromNotFoundSelectorPolicy]
public ActionResult Redirect()
{
var uri = HttpContext.Request.GetEncodedUrl();

View File

@@ -0,0 +1,13 @@
using System;
namespace Umbraco.Cms.Web.Common.Attributes
{
/// <summary>
/// When applied to an api controller it will be routed to the /Umbraco/BackOffice prefix route so we can determine if it
/// is a back office route or not.
/// </summary>
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public sealed class IgnoreFromNotFoundSelectorPolicyAttribute : Attribute
{
}
}

View File

@@ -8,6 +8,7 @@ using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.AspNetCore.Routing;
using Microsoft.AspNetCore.Routing.Matching;
using Umbraco.Cms.Core.Routing;
using Umbraco.Cms.Web.Common.Attributes;
using Umbraco.Cms.Web.Common.Controllers;
using Umbraco.Cms.Web.Common.Routing;
@@ -80,11 +81,15 @@ namespace Umbraco.Cms.Web.Website.Routing
{
for (int i = 0; i < candidates.Count; i++)
{
if (candidates.IsValidCandidate(i))
// We have to check if candidates needs to be ignored here
// So we dont return false when all endpoints are invalid
if (candidates.IsValidCandidate(i) &&
candidates[i].Endpoint.Metadata.GetMetadata<IgnoreFromNotFoundSelectorPolicyAttribute>() is null)
{
return false;
}
}
return true;
}
}