Avoid usage of IOHelper in GlobalSettings
This commit is contained in:
@@ -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>(
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user