Added POC of basic auth middleware

This commit is contained in:
Bjarke Berg
2021-08-05 21:42:36 +02:00
parent 61b343da8b
commit 4f2cb09939
13 changed files with 199 additions and 16 deletions

View File

@@ -1,5 +1,7 @@
using System;
using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
@@ -7,6 +9,22 @@ namespace Umbraco.Extensions
{
public static class HttpContextExtensions
{
/// <summary>
/// Runs the authentication process
/// </summary>
public static async Task<AuthenticateResult> AuthenticateBackOfficeAsync(this HttpContext httpContext)
{
if (httpContext == null)
{
return AuthenticateResult.NoResult();
}
var result = await httpContext.AuthenticateAsync(Cms.Core.Constants.Security.BackOfficeAuthenticationType);
return result;
}
/// <summary>
/// Get the value in the request form or query string for the key
/// </summary>