Avoid usage of IOHelper in GlobalSettings

This commit is contained in:
Bjarke Berg
2020-03-13 10:00:03 +01:00
parent 6fafe0408d
commit ea15fdb14e
31 changed files with 99 additions and 82 deletions

View File

@@ -235,7 +235,7 @@ namespace Umbraco.Web.Security
var cookieAuthOptions = app.CreateUmbracoCookieAuthOptions(
umbracoContextAccessor, globalSettings, runtimeState, securitySettings,
//This defines the explicit path read cookies from for this middleware
ioHelper, requestCache, new[] {$"{globalSettings.Path}/backoffice/UmbracoApi/Authentication/GetRemainingTimeoutSeconds"});
ioHelper, requestCache, new[] {$"{ioHelper.BackOfficePath}/backoffice/UmbracoApi/Authentication/GetRemainingTimeoutSeconds"});
cookieAuthOptions.Provider = cookieOptions.Provider;
//This is a custom middleware, we need to return the user's remaining logged in seconds
@@ -243,7 +243,8 @@ namespace Umbraco.Web.Security
cookieAuthOptions,
Current.Configs.Global(),
Current.Configs.Security(),
app.CreateLogger<GetUserSecondsMiddleWare>());
app.CreateLogger<GetUserSecondsMiddleWare>(),
Current.IOHelper);
//This is required so that we can read the auth ticket format outside of this pipeline
app.CreatePerOwinContext<UmbracoAuthTicketDataProtector>(

View File

@@ -41,7 +41,7 @@ namespace Umbraco.Web.Security
_ioHelper = ioHelper;
_requestCache = requestCache;
_explicitPaths = explicitPaths?.ToArray();
_getRemainingSecondsPath = $"{globalSettings.Path}/backoffice/UmbracoApi/Authentication/GetRemainingTimeoutSeconds";
_getRemainingSecondsPath = $"{ioHelper.BackOfficePath}/backoffice/UmbracoApi/Authentication/GetRemainingTimeoutSeconds";
}
/// <summary>

View File

@@ -8,6 +8,7 @@ using Microsoft.Owin.Logging;
using Umbraco.Core;
using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.IO;
using Umbraco.Core.Security;
namespace Umbraco.Web.Security
@@ -26,19 +27,22 @@ namespace Umbraco.Web.Security
private readonly IGlobalSettings _globalSettings;
private readonly ISecuritySettings _security;
private readonly ILogger _logger;
private readonly IIOHelper _ioHelper;
public GetUserSecondsMiddleWare(
OwinMiddleware next,
UmbracoBackOfficeCookieAuthOptions authOptions,
IGlobalSettings globalSettings,
ISecuritySettings security,
ILogger logger)
ILogger logger,
IIOHelper ioHelper)
: base(next)
{
_authOptions = authOptions ?? throw new ArgumentNullException(nameof(authOptions));
_globalSettings = globalSettings;
_security = security;
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
_ioHelper = ioHelper;
}
public override async Task Invoke(IOwinContext context)
@@ -48,7 +52,7 @@ namespace Umbraco.Web.Security
if (request.Uri.Scheme.InvariantStartsWith("http")
&& request.Uri.AbsolutePath.InvariantEquals(
$"{_globalSettings.Path}/backoffice/UmbracoApi/Authentication/GetRemainingTimeoutSeconds"))
$"{_ioHelper.BackOfficePath}/backoffice/UmbracoApi/Authentication/GetRemainingTimeoutSeconds"))
{
var cookie = _authOptions.CookieManager.GetRequestCookie(context, _security.AuthCookieName);
if (cookie.IsNullOrWhiteSpace() == false)