Merge pull request #4212 from umbraco/temp8-fixme-only-allow-local-keep-alive-pings

Fixme - Only allow local KeepAlive Pings requests
This commit is contained in:
Warren Buckley
2019-01-24 11:49:05 +00:00
committed by GitHub
3 changed files with 23 additions and 5 deletions

View File

@@ -1,16 +1,13 @@
using System.Runtime.Serialization;
using System.Web.Http;
using Umbraco.Web.Mvc;
using Umbraco.Web.WebApi;
namespace Umbraco.Web.Editors
{
// fixme/task - deal with this
// this is not authenticated, and therefore public, and therefore reveals we
// are running Umbraco - but, all requests should come from localhost really,
// so there should be a way to 404 when the request comes from the outside.
public class KeepAliveController : UmbracoApiController
{
[OnlyLocalRequests]
[HttpGet]
public KeepAlivePingResult Ping()
{

View File

@@ -0,0 +1,20 @@
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Web.Http.Controllers;
using System.Web.Http.Filters;
namespace Umbraco.Web.Mvc
{
public class OnlyLocalRequestsAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(HttpActionContext actionContext)
{
if (!actionContext.Request.IsLocal())
{
throw new HttpResponseException(HttpStatusCode.NotFound);
}
}
}
}

View File

@@ -172,6 +172,7 @@
<Compile Include="Models\ContentEditing\MacroParameterDisplay.cs" />
<Compile Include="Models\Link.cs" />
<Compile Include="Models\LinkType.cs" />
<Compile Include="Mvc\OnlyLocalRequestsAttribute.cs" />
<Compile Include="PropertyEditors\MultiUrlPickerConfiguration.cs" />
<Compile Include="PropertyEditors\MultiUrlPickerConfigurationEditor.cs" />
<Compile Include="PropertyEditors\MultiUrlPickerPropertyEditor.cs" />