diff --git a/src/Umbraco.Web.Common/Profiler/ConfigureMiniProfilerOptions.cs b/src/Umbraco.Web.Common/Profiler/ConfigureMiniProfilerOptions.cs index 4239ba1737..e005183d2b 100644 --- a/src/Umbraco.Web.Common/Profiler/ConfigureMiniProfilerOptions.cs +++ b/src/Umbraco.Web.Common/Profiler/ConfigureMiniProfilerOptions.cs @@ -1,5 +1,8 @@ +using System.Security.Claims; +using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Options; +using OpenIddict.Abstractions; using StackExchange.Profiling; using Umbraco.Cms.Core.Configuration.Models; using Umbraco.Cms.Core.Hosting; @@ -35,9 +38,17 @@ internal sealed class ConfigureMiniProfilerOptions : IConfigureOptions true;// FIXME when we can get current backoffice user, _backOfficeSecurityAccessor.BackOfficeSecurity?.CurrentUser is not null; + private async Task IsBackofficeUserAuthorized(HttpRequest request) + { + AuthenticateResult authenticateResult = await request.HttpContext.AuthenticateBackOfficeAsync(); + ClaimsIdentity? identity = authenticateResult.Principal?.GetUmbracoIdentity(); + + return identity?.GetClaims(Core.Constants.Security.AllowedApplicationsClaimType) + .InvariantContains(Core.Constants.Applications.Settings) ?? false; + + } } diff --git a/src/Umbraco.Web.Common/Repositories/WebProfilerRepository.cs b/src/Umbraco.Web.Common/Repositories/WebProfilerRepository.cs index 52eaaf04ca..44dc862e96 100644 --- a/src/Umbraco.Web.Common/Repositories/WebProfilerRepository.cs +++ b/src/Umbraco.Web.Common/Repositories/WebProfilerRepository.cs @@ -21,7 +21,7 @@ internal class WebProfilerRepository : IWebProfilerRepository { if (status) { - _httpContextAccessor.GetRequiredHttpContext().Response.Cookies.Append(CookieName, string.Empty, new CookieOptions { Expires = DateTime.Now.AddYears(1) }); + _httpContextAccessor.GetRequiredHttpContext().Response.Cookies.Append(CookieName, "1", new CookieOptions { Expires = DateTime.Now.AddYears(1) }); } else {