Implements Public Access in netcore (#10137)

* Getting new netcore PublicAccessChecker in place

* Adds full test coverage for PublicAccessChecker

* remove PublicAccessComposer

* adjust namespaces, ensure RoleManager works, separate public access controller, reduce content controller

* Implements the required methods on IMemberManager, removes old migrated code

* Updates routing to be able to re-route, Fixes middleware ordering ensuring endpoints are last, refactors pipeline options, adds public access middleware, ensures public access follows all hops

* adds note

* adds note

* Cleans up ext methods, ensures that members identity is added on both front-end and back ends. updates how UmbracoApplicationBuilder works in that it explicitly starts endpoints at the time of calling.

* Changes name to IUmbracoEndpointBuilder

* adds note

* Fixing tests, fixing error describers so there's 2x one for back office, one for members, fixes TryConvertTo, fixes login redirect

* fixing build

* Fixes keepalive, fixes PublicAccessMiddleware to not throw, updates startup code to be more clear and removes magic that registers middleware.

* adds note

* removes unused filter, fixes build

* fixes WebPath and tests

* Looks up entities in one query

* remove usings

* Fix test, remove stylesheet

* Set status code before we write to response to avoid error

* Ensures that users and members are validated when logging in. Shares more code between users and members.

* Fixes RepositoryCacheKeys to ensure the keys are normalized

* oops didn't mean to commit this

* Fix casing issues with caching, stop boxing value types for all cache operations, stop re-creating string keys in DefaultRepositoryCachePolicy

* bah, far out this keeps getting recommitted. sorry

Co-authored-by: Bjarke Berg <mail@bergmania.dk>
This commit is contained in:
Shannon Deminick
2021-04-20 15:11:45 +10:00
committed by GitHub
parent 385cc62523
commit a1624d26a3
150 changed files with 2715 additions and 2173 deletions

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
@@ -9,6 +9,7 @@ using HttpRequestExtensions = Umbraco.Extensions.HttpRequestExtensions;
namespace Umbraco.Cms.Web.BackOffice.Middleware
{
/// <summary>
/// Used to handle errors registered by external login providers
/// </summary>

View File

@@ -0,0 +1,22 @@
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core.Configuration.Models;
namespace Umbraco.Cms.Web.BackOffice.Middleware
{
/// <summary>
/// Ensures the Keep Alive middleware is part of
/// </summary>
public sealed class ConfigureGlobalOptionsForKeepAliveMiddlware : IPostConfigureOptions<GlobalSettings>
{
private readonly IOptions<KeepAliveSettings> _keepAliveSettings;
public ConfigureGlobalOptionsForKeepAliveMiddlware(IOptions<KeepAliveSettings> keepAliveSettings) => _keepAliveSettings = keepAliveSettings;
/// <summary>
/// Append the keep alive ping url to the reserved URLs
/// </summary>
/// <param name="name"></param>
/// <param name="options"></param>
public void PostConfigure(string name, GlobalSettings options) => options.ReservedUrls += _keepAliveSettings.Value.KeepAlivePingUrl;
}
}

View File

@@ -0,0 +1,26 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
namespace Umbraco.Cms.Web.BackOffice.Middleware
{
/// <summary>
/// Used for the Umbraco keep alive service. This is terminating middleware.
/// </summary>
public class KeepAliveMiddleware : IMiddleware
{
public async Task InvokeAsync(HttpContext context, RequestDelegate next)
{
if (HttpMethods.IsGet(context.Request.Method) || HttpMethods.IsHead(context.Request.Method))
{
context.Response.StatusCode = StatusCodes.Status200OK;
await context.Response.WriteAsync("I'm alive");
}
else
{
context.Response.StatusCode = StatusCodes.Status404NotFound;
}
}
}
}