Netcore: Introduce BackofficeSecurityAccessor (#8871)
* Introduced IWebSecurityAccessor Signed-off-by: Bjarke Berg <mail@bergmania.dk> * Fixed tests Signed-off-by: Bjarke Berg <mail@bergmania.dk> * Renamed WebSecurity to BackofficeSecurity and all related names * Fixes typos Co-authored-by: Elitsa Marinovska <elm@umbraco.dk>
This commit is contained in:
@@ -13,14 +13,15 @@ using Umbraco.Web.Security;
|
||||
|
||||
namespace Umbraco.Web.Common.Security
|
||||
{
|
||||
public class WebSecurity : IWebSecurity
|
||||
|
||||
public class BackofficeSecurity : IBackofficeSecurity
|
||||
{
|
||||
private readonly IUserService _userService;
|
||||
private readonly GlobalSettings _globalSettings;
|
||||
private readonly IHostingEnvironment _hostingEnvironment;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
public WebSecurity(
|
||||
public BackofficeSecurity(
|
||||
IUserService userService,
|
||||
IOptions<GlobalSettings> globalSettings,
|
||||
IHostingEnvironment hostingEnvironment,
|
||||
43
src/Umbraco.Web.Common/Security/BackofficeSecurityFactory.cs
Normal file
43
src/Umbraco.Web.Common/Security/BackofficeSecurityFactory.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Configuration.Models;
|
||||
using Umbraco.Core.Hosting;
|
||||
using Umbraco.Core.Security;
|
||||
using Umbraco.Core.Services;
|
||||
|
||||
namespace Umbraco.Web.Common.Security
|
||||
{
|
||||
public class BackofficeSecurityFactory: IBackofficeSecurityFactory
|
||||
{
|
||||
private readonly IBackofficeSecurityAccessor _backofficeSecurityAccessor;
|
||||
private readonly IUserService _userService;
|
||||
private readonly IOptions<GlobalSettings> _globalSettings;
|
||||
private readonly IHostingEnvironment _hostingEnvironment;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
public BackofficeSecurityFactory(
|
||||
IBackofficeSecurityAccessor backofficeSecurityAccessor,
|
||||
IUserService userService,
|
||||
IOptions<GlobalSettings> globalSettings,
|
||||
IHostingEnvironment hostingEnvironment,
|
||||
IHttpContextAccessor httpContextAccessor)
|
||||
{
|
||||
_backofficeSecurityAccessor = backofficeSecurityAccessor;
|
||||
_userService = userService;
|
||||
_globalSettings = globalSettings;
|
||||
_hostingEnvironment = hostingEnvironment;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
}
|
||||
|
||||
public void EnsureBackofficeSecurity()
|
||||
{
|
||||
if (_backofficeSecurityAccessor.BackofficeSecurity is null)
|
||||
{
|
||||
_backofficeSecurityAccessor.BackofficeSecurity = new BackofficeSecurity(_userService, _globalSettings, _hostingEnvironment, _httpContextAccessor);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user