diff --git a/src/Umbraco.Core/ContentApps/ContentAppFactoryCollection.cs b/src/Umbraco.Core/ContentApps/ContentAppFactoryCollection.cs index 7884126dc8..738da5ef60 100644 --- a/src/Umbraco.Core/ContentApps/ContentAppFactoryCollection.cs +++ b/src/Umbraco.Core/ContentApps/ContentAppFactoryCollection.cs @@ -5,24 +5,25 @@ using Umbraco.Core; using Umbraco.Core.Composing; using Umbraco.Core.Models.ContentEditing; using Umbraco.Core.Models.Membership; +using Umbraco.Core.Security; namespace Umbraco.Web.ContentApps { public class ContentAppFactoryCollection : BuilderCollectionBase { private readonly ILogger _logger; - private readonly IUmbracoContextAccessor _umbracoContextAccessor; + private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor; - public ContentAppFactoryCollection(IEnumerable items, ILogger logger, IUmbracoContextAccessor umbracoContextAccessor) + public ContentAppFactoryCollection(IEnumerable items, ILogger logger, IBackOfficeSecurityAccessor backOfficeSecurityAccessor) : base(items) { _logger = logger; - _umbracoContextAccessor = umbracoContextAccessor; + _backOfficeSecurityAccessor = backOfficeSecurityAccessor; } private IEnumerable GetCurrentUserGroups() { - var currentUser = _umbracoContextAccessor.UmbracoContext?.Security?.CurrentUser; + var currentUser = _backOfficeSecurityAccessor?.BackOfficeSecurity?.CurrentUser; return currentUser == null ? Enumerable.Empty() : currentUser.Groups; diff --git a/src/Umbraco.Core/ContentApps/ContentAppFactoryCollectionBuilder.cs b/src/Umbraco.Core/ContentApps/ContentAppFactoryCollectionBuilder.cs index 0f0e09042b..138c426043 100644 --- a/src/Umbraco.Core/ContentApps/ContentAppFactoryCollectionBuilder.cs +++ b/src/Umbraco.Core/ContentApps/ContentAppFactoryCollectionBuilder.cs @@ -9,6 +9,7 @@ using Umbraco.Core.IO; using Umbraco.Core.Manifest; using Umbraco.Core.Models.ContentEditing; using Umbraco.Core.Models.Identity; +using Umbraco.Core.Security; namespace Umbraco.Web.ContentApps { @@ -21,8 +22,8 @@ namespace Umbraco.Web.ContentApps { // get the logger factory just-in-time - see note below for manifest parser var loggerFactory = factory.GetRequiredService(); - var umbracoContextAccessor = factory.GetRequiredService(); - return new ContentAppFactoryCollection(CreateItems(factory), loggerFactory.CreateLogger(), umbracoContextAccessor); + var backOfficeSecurityAccessor = factory.GetRequiredService(); + return new ContentAppFactoryCollection(CreateItems(factory), loggerFactory.CreateLogger(), backOfficeSecurityAccessor); } protected override IEnumerable CreateItems(IServiceProvider factory) diff --git a/src/Umbraco.Core/IUmbracoContext.cs b/src/Umbraco.Core/IUmbracoContext.cs index 312135169a..681dedbfd2 100644 --- a/src/Umbraco.Core/IUmbracoContext.cs +++ b/src/Umbraco.Core/IUmbracoContext.cs @@ -15,11 +15,6 @@ namespace Umbraco.Web /// DateTime ObjectCreated { get; } - /// - /// Gets the BackofficeSecurity class - /// - IBackOfficeSecurity Security { get; } - /// /// Gets the uri that is handled by ASP.NET after server-side rewriting took place. /// diff --git a/src/Umbraco.Examine.Lucene/BackOfficeExamineSearcher.cs b/src/Umbraco.Examine.Lucene/BackOfficeExamineSearcher.cs index 24800fa98a..9551dc8b90 100644 --- a/src/Umbraco.Examine.Lucene/BackOfficeExamineSearcher.cs +++ b/src/Umbraco.Examine.Lucene/BackOfficeExamineSearcher.cs @@ -6,6 +6,7 @@ using System.Text.RegularExpressions; using Examine; using Umbraco.Core; using Umbraco.Core.Models; +using Umbraco.Core.Security; using Umbraco.Core.Services; using Umbraco.Web; using Umbraco.Web.Models.ContentEditing; @@ -16,19 +17,19 @@ namespace Umbraco.Examine { private readonly IExamineManager _examineManager; private readonly ILocalizationService _languageService; - private readonly IUmbracoContextAccessor _umbracoContextAccessor; + private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor; private readonly IEntityService _entityService; private readonly IUmbracoTreeSearcherFields _treeSearcherFields; public BackOfficeExamineSearcher(IExamineManager examineManager, ILocalizationService languageService, - IUmbracoContextAccessor umbracoContextAccessor, + IBackOfficeSecurityAccessor backOfficeSecurityAccessor, IEntityService entityService, IUmbracoTreeSearcherFields treeSearcherFields) { _examineManager = examineManager; _languageService = languageService; - _umbracoContextAccessor = umbracoContextAccessor; + _backOfficeSecurityAccessor = backOfficeSecurityAccessor; _entityService = entityService; _treeSearcherFields = treeSearcherFields; } @@ -47,7 +48,7 @@ namespace Umbraco.Examine query = "\"" + g.ToString() + "\""; } - var currentUser = _umbracoContextAccessor.UmbracoContext?.Security?.CurrentUser; + var currentUser = _backOfficeSecurityAccessor?.BackOfficeSecurity?.CurrentUser; switch (entityType) { diff --git a/src/Umbraco.Infrastructure/Compose/NotificationsComponent.cs b/src/Umbraco.Infrastructure/Compose/NotificationsComponent.cs index 81a41cf575..8c26e0e688 100644 --- a/src/Umbraco.Infrastructure/Compose/NotificationsComponent.cs +++ b/src/Umbraco.Infrastructure/Compose/NotificationsComponent.cs @@ -10,6 +10,7 @@ using Umbraco.Core.Configuration.Models; using Umbraco.Core.Models; using Umbraco.Core.Models.Entities; using Umbraco.Core.Models.Membership; +using Umbraco.Core.Security; using Umbraco.Core.Services; using Umbraco.Core.Services.Implement; using Umbraco.Web.Actions; @@ -183,7 +184,7 @@ namespace Umbraco.Web.Compose /// public sealed class Notifier { - private readonly IUmbracoContextAccessor _umbracoContextAccessor; + private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor; private readonly IRequestAccessor _requestAccessor; private readonly INotificationService _notificationService; private readonly IUserService _userService; @@ -194,15 +195,15 @@ namespace Umbraco.Web.Compose /// /// Constructor /// - /// + /// + /// /// /// /// /// - /// /// public Notifier( - IUmbracoContextAccessor umbracoContextAccessor, + IBackOfficeSecurityAccessor backOfficeSecurityAccessor, IRequestAccessor requestAccessor, INotificationService notificationService, IUserService userService, @@ -210,7 +211,7 @@ namespace Umbraco.Web.Compose IOptions globalSettings, ILogger logger) { - _umbracoContextAccessor = umbracoContextAccessor; + _backOfficeSecurityAccessor = backOfficeSecurityAccessor; _requestAccessor = requestAccessor; _notificationService = notificationService; _userService = userService; @@ -221,7 +222,7 @@ namespace Umbraco.Web.Compose public void Notify(IAction action, params IContent[] entities) { - var user = _umbracoContextAccessor.UmbracoContext?.Security?.CurrentUser; + var user = _backOfficeSecurityAccessor?.BackOfficeSecurity?.CurrentUser; //if there is no current user, then use the admin if (user == null) diff --git a/src/Umbraco.Infrastructure/PropertyEditors/GridPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/GridPropertyEditor.cs index c34ce59fe6..e6db6a4328 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/GridPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/GridPropertyEditor.cs @@ -9,6 +9,7 @@ using Umbraco.Core.Media; using Umbraco.Core.Models; using Umbraco.Core.Models.Editors; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Security; using Umbraco.Core.Services; using Umbraco.Core.Strings; using Umbraco.Web.Templates; @@ -28,7 +29,7 @@ namespace Umbraco.Web.PropertyEditors Group = Constants.PropertyEditors.Groups.RichContent)] public class GridPropertyEditor : DataEditor { - private readonly IUmbracoContextAccessor _umbracoContextAccessor; + private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor; private readonly IIOHelper _ioHelper; private readonly HtmlImageSourceParser _imageSourceParser; private readonly RichTextEditorPastedImages _pastedImages; @@ -37,7 +38,7 @@ namespace Umbraco.Web.PropertyEditors public GridPropertyEditor( ILoggerFactory loggerFactory, - IUmbracoContextAccessor umbracoContextAccessor, + IBackOfficeSecurityAccessor backOfficeSecurityAccessor, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, @@ -49,7 +50,7 @@ namespace Umbraco.Web.PropertyEditors IImageUrlGenerator imageUrlGenerator) : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) { - _umbracoContextAccessor = umbracoContextAccessor; + _backOfficeSecurityAccessor = backOfficeSecurityAccessor; _ioHelper = ioHelper; _imageSourceParser = imageSourceParser; _pastedImages = pastedImages; @@ -63,13 +64,13 @@ namespace Umbraco.Web.PropertyEditors /// Overridden to ensure that the value is validated /// /// - protected override IDataValueEditor CreateValueEditor() => new GridPropertyValueEditor(Attribute, _umbracoContextAccessor, DataTypeService, LocalizationService, LocalizedTextService, _imageSourceParser, _pastedImages, _localLinkParser, ShortStringHelper, _imageUrlGenerator); + protected override IDataValueEditor CreateValueEditor() => new GridPropertyValueEditor(Attribute, _backOfficeSecurityAccessor, DataTypeService, LocalizationService, LocalizedTextService, _imageSourceParser, _pastedImages, _localLinkParser, ShortStringHelper, _imageUrlGenerator); protected override IConfigurationEditor CreateConfigurationEditor() => new GridConfigurationEditor(_ioHelper); internal class GridPropertyValueEditor : DataValueEditor, IDataValueReference { - private readonly IUmbracoContextAccessor _umbracoContextAccessor; + private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor; private readonly HtmlImageSourceParser _imageSourceParser; private readonly RichTextEditorPastedImages _pastedImages; private readonly RichTextPropertyEditor.RichTextPropertyValueEditor _richTextPropertyValueEditor; @@ -78,7 +79,7 @@ namespace Umbraco.Web.PropertyEditors public GridPropertyValueEditor( DataEditorAttribute attribute, - IUmbracoContextAccessor umbracoContextAccessor, + IBackOfficeSecurityAccessor backOfficeSecurityAccessor, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, @@ -89,10 +90,10 @@ namespace Umbraco.Web.PropertyEditors IImageUrlGenerator imageUrlGenerator) : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute) { - _umbracoContextAccessor = umbracoContextAccessor; + _backOfficeSecurityAccessor = backOfficeSecurityAccessor; _imageSourceParser = imageSourceParser; _pastedImages = pastedImages; - _richTextPropertyValueEditor = new RichTextPropertyEditor.RichTextPropertyValueEditor(attribute, umbracoContextAccessor, dataTypeService, localizationService, localizedTextService, shortStringHelper, imageSourceParser, localLinkParser, pastedImages, imageUrlGenerator); + _richTextPropertyValueEditor = new RichTextPropertyEditor.RichTextPropertyValueEditor(attribute, backOfficeSecurityAccessor, dataTypeService, localizationService, localizedTextService, shortStringHelper, imageSourceParser, localLinkParser, pastedImages, imageUrlGenerator); _mediaPickerPropertyValueEditor = new MediaPickerPropertyEditor.MediaPickerPropertyValueEditor(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute); _imageUrlGenerator = imageUrlGenerator; } @@ -121,7 +122,7 @@ namespace Umbraco.Web.PropertyEditors var grid = DeserializeGridValue(rawJson, out var rtes, out _); - var userId = _umbracoContextAccessor.UmbracoContext?.Security?.CurrentUser?.Id ?? Constants.Security.SuperUserId; + var userId = _backOfficeSecurityAccessor?.BackOfficeSecurity?.CurrentUser?.Id ?? Constants.Security.SuperUserId; // Process the rte values foreach (var rte in rtes) diff --git a/src/Umbraco.Infrastructure/PropertyEditors/RichTextPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/RichTextPropertyEditor.cs index bf867ce648..049f020db4 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/RichTextPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/RichTextPropertyEditor.cs @@ -7,6 +7,7 @@ using Umbraco.Core.Media; using Umbraco.Core.Models; using Umbraco.Core.Models.Editors; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Security; using Umbraco.Core.Services; using Umbraco.Core.Strings; using Umbraco.Examine; @@ -28,7 +29,7 @@ namespace Umbraco.Web.PropertyEditors Icon = "icon-browser-window")] public class RichTextPropertyEditor : DataEditor { - private readonly IUmbracoContextAccessor _umbracoContextAccessor; + private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor; private readonly HtmlImageSourceParser _imageSourceParser; private readonly HtmlLocalLinkParser _localLinkParser; private readonly RichTextEditorPastedImages _pastedImages; @@ -40,7 +41,7 @@ namespace Umbraco.Web.PropertyEditors /// public RichTextPropertyEditor( ILoggerFactory loggerFactory, - IUmbracoContextAccessor umbracoContextAccessor, + IBackOfficeSecurityAccessor backOfficeSecurityAccessor, IDataTypeService dataTypeService, ILocalizationService localizationService, HtmlImageSourceParser imageSourceParser, @@ -52,7 +53,7 @@ namespace Umbraco.Web.PropertyEditors IImageUrlGenerator imageUrlGenerator) : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) { - _umbracoContextAccessor = umbracoContextAccessor; + _backOfficeSecurityAccessor = backOfficeSecurityAccessor; _imageSourceParser = imageSourceParser; _localLinkParser = localLinkParser; _pastedImages = pastedImages; @@ -64,7 +65,7 @@ namespace Umbraco.Web.PropertyEditors /// Create a custom value editor /// /// - protected override IDataValueEditor CreateValueEditor() => new RichTextPropertyValueEditor(Attribute, _umbracoContextAccessor, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, _imageSourceParser, _localLinkParser, _pastedImages, _imageUrlGenerator); + protected override IDataValueEditor CreateValueEditor() => new RichTextPropertyValueEditor(Attribute, _backOfficeSecurityAccessor, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, _imageSourceParser, _localLinkParser, _pastedImages, _imageUrlGenerator); protected override IConfigurationEditor CreateConfigurationEditor() => new RichTextConfigurationEditor(_ioHelper); @@ -75,7 +76,7 @@ namespace Umbraco.Web.PropertyEditors /// internal class RichTextPropertyValueEditor : DataValueEditor, IDataValueReference { - private IUmbracoContextAccessor _umbracoContextAccessor; + private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor; private readonly HtmlImageSourceParser _imageSourceParser; private readonly HtmlLocalLinkParser _localLinkParser; private readonly RichTextEditorPastedImages _pastedImages; @@ -83,7 +84,7 @@ namespace Umbraco.Web.PropertyEditors public RichTextPropertyValueEditor( DataEditorAttribute attribute, - IUmbracoContextAccessor umbracoContextAccessor, + IBackOfficeSecurityAccessor backOfficeSecurityAccessor, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, @@ -94,7 +95,7 @@ namespace Umbraco.Web.PropertyEditors IImageUrlGenerator imageUrlGenerator) : base(dataTypeService, localizationService,localizedTextService, shortStringHelper, attribute) { - _umbracoContextAccessor = umbracoContextAccessor; + _backOfficeSecurityAccessor = backOfficeSecurityAccessor; _imageSourceParser = imageSourceParser; _localLinkParser = localLinkParser; _pastedImages = pastedImages; @@ -146,7 +147,7 @@ namespace Umbraco.Web.PropertyEditors if (editorValue.Value == null) return null; - var userId = _umbracoContextAccessor.UmbracoContext?.Security?.CurrentUser?.Id ?? Constants.Security.SuperUserId; + var userId = _backOfficeSecurityAccessor?.BackOfficeSecurity?.CurrentUser?.Id ?? Constants.Security.SuperUserId; var config = editorValue.DataTypeConfiguration as RichTextConfiguration; var mediaParent = config?.MediaParentId; diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/HostedServices/TempFileCleanupTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/HostedServices/TempFileCleanupTests.cs index 7feda1e9da..2fcc618397 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/HostedServices/TempFileCleanupTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/HostedServices/TempFileCleanupTests.cs @@ -15,7 +15,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Infrastructure.HostedServices public class TempFileCleanupTests { private Mock _mockIOHelper; - private string _testPath = @"c:\test\temp\path"; + private string _testPath = Path.GetTempPath(); [Test] public async Task Does_Not_Execute_When_Not_Main_Dom() diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Logging/LogviewerTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Logging/LogviewerTests.cs index 2b78714997..6a0fde5116 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Logging/LogviewerTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Logging/LogviewerTests.cs @@ -42,12 +42,12 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Infrastructure.Logging var loggingConfiguration = TestHelper.GetLoggingConfiguration(hostingEnv); - var exampleLogfilePath = Path.Combine(testRoot, @"TestHelpers\Assets\", _logfileName); + var exampleLogfilePath = Path.Combine(testRoot, "TestHelpers","Assets", _logfileName); _newLogfileDirPath = loggingConfiguration.LogDirectory; _newLogfilePath = Path.Combine(_newLogfileDirPath, _logfileName); - var exampleSearchfilePath = Path.Combine(testRoot, @"TestHelpers\Assets\", _searchfileName); - _newSearchfileDirPath = Path.Combine(hostingEnv.ApplicationPhysicalPath, @"Config\"); + var exampleSearchfilePath = Path.Combine(testRoot, "TestHelpers","Assets", _searchfileName); + _newSearchfileDirPath = Path.Combine(hostingEnv.ApplicationPhysicalPath, @"Config"); _newSearchfilePath = Path.Combine(_newSearchfileDirPath, _searchfileName); //Create/ensure Directory exists diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentTestBase.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentTestBase.cs index 0e7bdbc068..f2306aeb72 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentTestBase.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentTestBase.cs @@ -18,6 +18,7 @@ using Umbraco.Web.Routing; using Umbraco.Core.Media; using System; using Microsoft.Extensions.DependencyInjection; +using Umbraco.Core.Security; using Umbraco.Core.Serialization; namespace Umbraco.Tests.PublishedContent @@ -57,7 +58,7 @@ namespace Umbraco.Tests.PublishedContent var dataTypeService = new TestObjects.TestDataTypeService( new DataType(new RichTextPropertyEditor( loggerFactory, - Mock.Of(), + Mock.Of(), Mock.Of(), Mock.Of(), imageSourceParser, diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs index e75abf500d..c0b2de44e8 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs @@ -28,6 +28,7 @@ using Umbraco.Web.Templates; using Umbraco.Web.Routing; using Current = Umbraco.Web.Composing.Current; using Umbraco.Core.Media; +using Umbraco.Core.Security; using Umbraco.Core.Serialization; namespace Umbraco.Tests.PublishedContent @@ -54,6 +55,7 @@ namespace Umbraco.Tests.PublishedContent var mediaFileService = Mock.Of(); var contentTypeBaseServiceProvider = Mock.Of(); var umbracoContextAccessor = Mock.Of(); + var backOfficeSecurityAccessor = Mock.Of(); var publishedUrlProvider = Mock.Of(); var imageSourceParser = new HtmlImageSourceParser(publishedUrlProvider); var serializer = new ConfigurationEditorJsonSerializer(); @@ -64,7 +66,7 @@ namespace Umbraco.Tests.PublishedContent var dataTypeService = new TestObjects.TestDataTypeService( new DataType(new VoidEditor(loggerFactory, Mock.Of(), localizationService, LocalizedTextService, ShortStringHelper), serializer) { Id = 1 }, new DataType(new TrueFalsePropertyEditor(loggerFactory, Mock.Of(), localizationService, IOHelper, ShortStringHelper, LocalizedTextService), serializer) { Id = 1001 }, - new DataType(new RichTextPropertyEditor(loggerFactory,umbracoContextAccessor, Mock.Of(), localizationService, imageSourceParser, linkParser, pastedImages, ShortStringHelper, IOHelper, LocalizedTextService, Mock.Of()), serializer) { Id = 1002 }, + new DataType(new RichTextPropertyEditor(loggerFactory,backOfficeSecurityAccessor, Mock.Of(), localizationService, imageSourceParser, linkParser, pastedImages, ShortStringHelper, IOHelper, LocalizedTextService, Mock.Of()), serializer) { Id = 1002 }, new DataType(new IntegerPropertyEditor(loggerFactory, Mock.Of(), localizationService, ShortStringHelper, LocalizedTextService), serializer) { Id = 1003 }, new DataType(new TextboxPropertyEditor(loggerFactory, Mock.Of(), localizationService, IOHelper, ShortStringHelper, LocalizedTextService), serializer) { Id = 1004 }, new DataType(new MediaPickerPropertyEditor(loggerFactory, Mock.Of(), localizationService, IOHelper, ShortStringHelper, LocalizedTextService), serializer) { Id = 1005 }); diff --git a/src/Umbraco.Tests/Testing/TestingTests/MockTests.cs b/src/Umbraco.Tests/Testing/TestingTests/MockTests.cs index 9c259d7d16..0865cf0d98 100644 --- a/src/Umbraco.Tests/Testing/TestingTests/MockTests.cs +++ b/src/Umbraco.Tests/Testing/TestingTests/MockTests.cs @@ -19,6 +19,7 @@ using Umbraco.Core.Models; using Umbraco.Core.Models.PublishedContent; using Umbraco.Core.Templates; using Umbraco.Core.Persistence; +using Umbraco.Core.Security; using Umbraco.Core.Services; using Umbraco.Tests.Common; using Umbraco.Tests.TestHelpers; @@ -113,7 +114,7 @@ namespace Umbraco.Tests.Testing.TestingTests var membershipHelper = new MembershipHelper(Mock.Of(), Mock.Of(), membershipProvider, Mock.Of(), memberService, memberTypeService, Mock.Of(), AppCaches.Disabled, NullLoggerFactory.Instance, ShortStringHelper, Mock.Of()); var umbracoMapper = new UmbracoMapper(new MapDefinitionCollection(new[] { Mock.Of() })); - var umbracoApiController = new FakeUmbracoApiController(new GlobalSettings(), Mock.Of(), Mock.Of(), ServiceContext.CreatePartial(), AppCaches.NoCache, profilingLogger , Mock.Of(), umbracoMapper, Mock.Of()); + var umbracoApiController = new FakeUmbracoApiController(new GlobalSettings(), Mock.Of(), Mock.Of(), Mock.Of(), ServiceContext.CreatePartial(), AppCaches.NoCache, profilingLogger , Mock.Of(), umbracoMapper, Mock.Of()); Assert.Pass(); } @@ -121,7 +122,7 @@ namespace Umbraco.Tests.Testing.TestingTests internal class FakeUmbracoApiController : UmbracoApiController { - public FakeUmbracoApiController(GlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ISqlContext sqlContext, ServiceContext services, AppCaches appCaches, IProfilingLogger logger, IRuntimeState runtimeState, UmbracoMapper umbracoMapper, IPublishedUrlProvider publishedUrlProvider) - : base(globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoMapper, publishedUrlProvider) { } + public FakeUmbracoApiController(GlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, IBackOfficeSecurityAccessor backOfficeSecurityAccessor, ISqlContext sqlContext, ServiceContext services, AppCaches appCaches, IProfilingLogger logger, IRuntimeState runtimeState, UmbracoMapper umbracoMapper, IPublishedUrlProvider publishedUrlProvider) + : base(globalSettings, umbracoContextAccessor, backOfficeSecurityAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoMapper, publishedUrlProvider) { } } } diff --git a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs index 4466b9424e..7751778069 100644 --- a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs +++ b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs @@ -313,6 +313,7 @@ namespace Umbraco.Tests.Testing // web Composition.Services.AddUnique(_ => Umbraco.Web.Composing.Current.UmbracoContextAccessor); + Composition.Services.AddUnique(_ => new HybridBackofficeSecurityAccessor(AppCaches.NoCache.RequestCache)); Composition.Services.AddUnique(); Composition.WithCollectionBuilder(); diff --git a/src/Umbraco.Web.BackOffice/Controllers/CodeFileController.cs b/src/Umbraco.Web.BackOffice/Controllers/CodeFileController.cs index 4bf76a108a..8eddd0775d 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/CodeFileController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/CodeFileController.cs @@ -10,6 +10,7 @@ using Umbraco.Core.Configuration.Models; using Umbraco.Core.IO; using Umbraco.Core.Mapping; using Umbraco.Core.Models; +using Umbraco.Core.Security; using Umbraco.Core.Services; using Umbraco.Core.Strings; using Umbraco.Core.Strings.Css; @@ -34,7 +35,8 @@ namespace Umbraco.Web.BackOffice.Controllers private readonly IIOHelper _ioHelper; private readonly IFileSystems _fileSystems; private readonly IFileService _fileService; - private readonly IUmbracoContextAccessor _umbracoContextAccessor; + private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor; + private readonly ILocalizedTextService _localizedTextService; private readonly UmbracoMapper _umbracoMapper; private readonly IShortStringHelper _shortStringHelper; @@ -44,7 +46,7 @@ namespace Umbraco.Web.BackOffice.Controllers IIOHelper ioHelper, IFileSystems fileSystems, IFileService fileService, - IUmbracoContextAccessor umbracoContextAccessor, + IBackOfficeSecurityAccessor backOfficeSecurityAccessor, ILocalizedTextService localizedTextService, UmbracoMapper umbracoMapper, IShortStringHelper shortStringHelper, @@ -53,7 +55,7 @@ namespace Umbraco.Web.BackOffice.Controllers _ioHelper = ioHelper; _fileSystems = fileSystems; _fileService = fileService; - _umbracoContextAccessor = umbracoContextAccessor; + _backOfficeSecurityAccessor = backOfficeSecurityAccessor; _localizedTextService = localizedTextService; _umbracoMapper = umbracoMapper; _shortStringHelper = shortStringHelper; @@ -72,7 +74,7 @@ namespace Umbraco.Web.BackOffice.Controllers if (display == null) throw new ArgumentNullException("display"); if (string.IsNullOrWhiteSpace(type)) throw new ArgumentException("Value cannot be null or whitespace.", "type"); - var currentUser = _umbracoContextAccessor.GetRequiredUmbracoContext().Security.CurrentUser; + var currentUser = _backOfficeSecurityAccessor.BackOfficeSecurity.CurrentUser; switch (type) { case Core.Constants.Trees.PartialViews: @@ -322,7 +324,7 @@ namespace Umbraco.Web.BackOffice.Controllers if (string.IsNullOrWhiteSpace(virtualPath)) throw new ArgumentException("Value cannot be null or whitespace.", "virtualPath"); virtualPath = System.Web.HttpUtility.UrlDecode(virtualPath); - var currentUser = _umbracoContextAccessor.GetRequiredUmbracoContext().Security.CurrentUser; + var currentUser = _backOfficeSecurityAccessor.BackOfficeSecurity.CurrentUser; switch (type) { case Constants.Trees.PartialViews: @@ -555,7 +557,7 @@ namespace Umbraco.Web.BackOffice.Controllers ? relPath + display.Name : relPath.EnsureEndsWith('/') + display.Name; } - var currentUser = _umbracoContextAccessor.GetRequiredUmbracoContext().Security.CurrentUser; + var currentUser = _backOfficeSecurityAccessor.BackOfficeSecurity.CurrentUser; var file = getFileByName(relPath); if (file != null) { @@ -608,7 +610,7 @@ namespace Umbraco.Web.BackOffice.Controllers display.Name = EnsureCorrectFileExtension(display.Name, ".cshtml"); Attempt partialViewResult; - var currentUser = _umbracoContextAccessor.GetRequiredUmbracoContext().Security.CurrentUser; + var currentUser = _backOfficeSecurityAccessor.BackOfficeSecurity.CurrentUser; var virtualPath = NormalizeVirtualPath(display.VirtualPath, systemDirectory); var view = getView(virtualPath); diff --git a/src/Umbraco.Web.BackOffice/Controllers/DashboardController.cs b/src/Umbraco.Web.BackOffice/Controllers/DashboardController.cs index 4d12f8db0c..41e5cfb589 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/DashboardController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/DashboardController.cs @@ -15,6 +15,7 @@ using Umbraco.Core.Persistence; using Umbraco.Core.Services; using Umbraco.Core.Strings; using Umbraco.Core.Dashboards; +using Umbraco.Core.Security; using Umbraco.Web.Services; using Umbraco.Web.BackOffice.Filters; using Umbraco.Web.Common.Attributes; @@ -32,7 +33,7 @@ namespace Umbraco.Web.BackOffice.Controllers [UmbracoBackOfficeAuthorize] public class DashboardController : UmbracoApiController { - private readonly IUmbracoContextAccessor _umbracoContextAccessor; + private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor; private readonly AppCaches _appCaches; private readonly ILogger _logger; private readonly IDashboardService _dashboardService; @@ -43,18 +44,15 @@ namespace Umbraco.Web.BackOffice.Controllers /// Initializes a new instance of the with all its dependencies. /// public DashboardController( - IUmbracoContextAccessor umbracoContextAccessor, - ISqlContext sqlContext, - ServiceContext services, + IBackOfficeSecurityAccessor backOfficeSecurityAccessor, AppCaches appCaches, ILogger logger, - IRuntimeState runtimeState, IDashboardService dashboardService, IUmbracoVersion umbracoVersion, IShortStringHelper shortStringHelper) { - _umbracoContextAccessor = umbracoContextAccessor; + _backOfficeSecurityAccessor = backOfficeSecurityAccessor; _appCaches = appCaches; _logger = logger; _dashboardService = dashboardService; @@ -69,7 +67,7 @@ namespace Umbraco.Web.BackOffice.Controllers [ValidateAngularAntiForgeryToken] public async Task GetRemoteDashboardContent(string section, string baseUrl = "https://dashboard.umbraco.org/") { - var user = _umbracoContextAccessor.GetRequiredUmbracoContext().Security.CurrentUser; + var user = _backOfficeSecurityAccessor.BackOfficeSecurity.CurrentUser; var allowedSections = string.Join(",", user.AllowedSections); var language = user.Language; var version = _umbracoVersion.SemanticVersion.ToSemanticString(); @@ -214,7 +212,7 @@ namespace Umbraco.Web.BackOffice.Controllers [TypeFilter(typeof(OutgoingEditorModelEventAttribute))] public IEnumerable> GetDashboard(string section) { - var currentUser = _umbracoContextAccessor.GetRequiredUmbracoContext().Security.CurrentUser; + var currentUser = _backOfficeSecurityAccessor.BackOfficeSecurity.CurrentUser; return _dashboardService.GetDashboards(section, currentUser).Select(x => new Tab { Id = x.Id, diff --git a/src/Umbraco.Web.BackOffice/Controllers/DataTypeController.cs b/src/Umbraco.Web.BackOffice/Controllers/DataTypeController.cs index c88d0d16c9..24c5b1cb24 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/DataTypeController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/DataTypeController.cs @@ -12,6 +12,7 @@ using Umbraco.Core.Configuration.Models; using Umbraco.Core.Mapping; using Umbraco.Core.Models; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Security; using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Web.BackOffice.Filters; @@ -43,7 +44,7 @@ namespace Umbraco.Web.BackOffice.Controllers private readonly IMediaTypeService _mediaTypeService; private readonly IMemberTypeService _memberTypeService; private readonly ILocalizedTextService _localizedTextService; - private readonly IUmbracoContextAccessor _umbracoContextAccessor; + private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor; private readonly IConfigurationEditorJsonSerializer _serializer; public DataTypeController( @@ -56,7 +57,7 @@ namespace Umbraco.Web.BackOffice.Controllers IMediaTypeService mediaTypeService, IMemberTypeService memberTypeService, ILocalizedTextService localizedTextService, - IUmbracoContextAccessor umbracoContextAccessor, + IBackOfficeSecurityAccessor backOfficeSecurityAccessor, IConfigurationEditorJsonSerializer serializer) { _propertyEditors = propertyEditors ?? throw new ArgumentNullException(nameof(propertyEditors)); @@ -68,7 +69,7 @@ namespace Umbraco.Web.BackOffice.Controllers _mediaTypeService = mediaTypeService ?? throw new ArgumentNullException(nameof(mediaTypeService)); _memberTypeService = memberTypeService ?? throw new ArgumentNullException(nameof(memberTypeService)); _localizedTextService = localizedTextService ?? throw new ArgumentNullException(nameof(localizedTextService)); - _umbracoContextAccessor = umbracoContextAccessor ?? throw new ArgumentNullException(nameof(umbracoContextAccessor)); + _backOfficeSecurityAccessor = backOfficeSecurityAccessor ?? throw new ArgumentNullException(nameof(backOfficeSecurityAccessor)); _serializer = serializer ?? throw new ArgumentNullException(nameof(serializer)); } @@ -149,7 +150,7 @@ namespace Umbraco.Web.BackOffice.Controllers { throw new HttpResponseException(HttpStatusCode.NotFound); } - var currentUser = _umbracoContextAccessor.GetRequiredUmbracoContext().Security.CurrentUser; + var currentUser = _backOfficeSecurityAccessor.BackOfficeSecurity.CurrentUser; _dataTypeService.Delete(foundType, currentUser.Id); return Ok(); @@ -249,7 +250,7 @@ namespace Umbraco.Web.BackOffice.Controllers public IActionResult DeleteContainer(int id) { - var currentUser = _umbracoContextAccessor.GetRequiredUmbracoContext().Security.CurrentUser; + var currentUser = _backOfficeSecurityAccessor.BackOfficeSecurity.CurrentUser; _dataTypeService.DeleteContainer(id, currentUser.Id); return Ok(); @@ -257,7 +258,7 @@ namespace Umbraco.Web.BackOffice.Controllers public IActionResult PostCreateContainer(int parentId, string name) { - var currentUser = _umbracoContextAccessor.GetRequiredUmbracoContext().Security.CurrentUser; + var currentUser = _backOfficeSecurityAccessor.BackOfficeSecurity.CurrentUser; var result = _dataTypeService.CreateContainer(parentId, name, currentUser.Id); return result @@ -287,7 +288,7 @@ namespace Umbraco.Web.BackOffice.Controllers dataType.PersistedDataType.Configuration = configuration; - var currentUser = _umbracoContextAccessor.GetRequiredUmbracoContext().Security.CurrentUser; + var currentUser = _backOfficeSecurityAccessor.BackOfficeSecurity.CurrentUser; // save the data type try { @@ -344,7 +345,7 @@ namespace Umbraco.Web.BackOffice.Controllers public IActionResult PostRenameContainer(int id, string name) { - var currentUser = _umbracoContextAccessor.GetRequiredUmbracoContext().Security.CurrentUser; + var currentUser = _backOfficeSecurityAccessor.BackOfficeSecurity.CurrentUser; var result = _dataTypeService.RenameContainer(id, name, currentUser.Id); return result diff --git a/src/Umbraco.Web.BackOffice/Mapping/ContentMapDefinition.cs b/src/Umbraco.Web.BackOffice/Mapping/ContentMapDefinition.cs index 54e7006bec..a2ad2cd834 100644 --- a/src/Umbraco.Web.BackOffice/Mapping/ContentMapDefinition.cs +++ b/src/Umbraco.Web.BackOffice/Mapping/ContentMapDefinition.cs @@ -8,6 +8,7 @@ using Umbraco.Core.Mapping; using Umbraco.Core.Models; using Umbraco.Core.Models.PublishedContent; using Umbraco.Core.Models.Membership; +using Umbraco.Core.Security; using Umbraco.Core.Services; using Umbraco.Web.Models.ContentEditing; using Umbraco.Web.Models.Mapping; @@ -34,6 +35,7 @@ namespace Umbraco.Web.BackOffice.Mapping private readonly ILoggerFactory _loggerFactory; private readonly IUserService _userService; private readonly IEntityService _entityService; + private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor; private readonly IVariationContextAccessor _variationContextAccessor; private readonly IPublishedUrlProvider _publishedUrlProvider; private readonly UriUtility _uriUtility; @@ -43,9 +45,25 @@ namespace Umbraco.Web.BackOffice.Mapping private readonly ContentVariantMapper _contentVariantMapper; - public ContentMapDefinition(CommonMapper commonMapper, CommonTreeNodeMapper commonTreeNodeMapper, ICultureDictionary cultureDictionary, ILocalizedTextService localizedTextService, IContentService contentService, IContentTypeService contentTypeService, - IFileService fileService, IUmbracoContextAccessor umbracoContextAccessor, IPublishedRouter publishedRouter, ILocalizationService localizationService, ILoggerFactory loggerFactory, - IUserService userService, IVariationContextAccessor variationContextAccessor, IContentTypeBaseServiceProvider contentTypeBaseServiceProvider, UriUtility uriUtility, IPublishedUrlProvider publishedUrlProvider, IEntityService entityService) + public ContentMapDefinition( + CommonMapper commonMapper, + CommonTreeNodeMapper commonTreeNodeMapper, + ICultureDictionary cultureDictionary, + ILocalizedTextService localizedTextService, + IContentService contentService, + IContentTypeService contentTypeService, + IFileService fileService, + IUmbracoContextAccessor umbracoContextAccessor, + IPublishedRouter publishedRouter, + ILocalizationService localizationService, + ILoggerFactory loggerFactory, + IUserService userService, + IVariationContextAccessor variationContextAccessor, + IContentTypeBaseServiceProvider contentTypeBaseServiceProvider, + UriUtility uriUtility, + IPublishedUrlProvider publishedUrlProvider, + IEntityService entityService, + IBackOfficeSecurityAccessor backOfficeSecurityAccessor) { _commonMapper = commonMapper; _commonTreeNodeMapper = commonTreeNodeMapper; @@ -60,6 +78,7 @@ namespace Umbraco.Web.BackOffice.Mapping _loggerFactory = loggerFactory; _userService = userService; _entityService = entityService; + _backOfficeSecurityAccessor = backOfficeSecurityAccessor; _variationContextAccessor = variationContextAccessor; _uriUtility = uriUtility; _publishedUrlProvider = publishedUrlProvider; @@ -159,10 +178,10 @@ namespace Umbraco.Web.BackOffice.Mapping private IEnumerable GetActions(IContent source) { - var umbracoContext = _umbracoContextAccessor.UmbracoContext; + var backOfficeSecurity = _backOfficeSecurityAccessor.BackOfficeSecurity; //cannot check permissions without a context - if (umbracoContext == null) + if (backOfficeSecurity is null) return Enumerable.Empty(); string path; @@ -174,10 +193,7 @@ namespace Umbraco.Web.BackOffice.Mapping path = parent == null ? "-1" : parent.Path; } - // TODO: This is certainly not ideal usage here - perhaps the best way to deal with this in the future is - // with the IUmbracoContextAccessor. In the meantime, if used outside of a web app this will throw a null - // reference exception :( - return _userService.GetPermissionsForPath(umbracoContext.Security.CurrentUser, path).GetAllPermissions(); + return _userService.GetPermissionsForPath(backOfficeSecurity.CurrentUser, path).GetAllPermissions(); } private UrlInfo[] GetUrls(IContent source) diff --git a/src/Umbraco.Web.Common/Controllers/IRenderController.cs b/src/Umbraco.Web.Common/Controllers/IRenderController.cs index 3eaf1c35c3..7534abc9b4 100644 --- a/src/Umbraco.Web.Common/Controllers/IRenderController.cs +++ b/src/Umbraco.Web.Common/Controllers/IRenderController.cs @@ -3,7 +3,6 @@ /// /// A marker interface to designate that a controller will be used for Umbraco front-end requests and/or route hijacking /// - /// Migrated already to .Net Core public interface IRenderController { diff --git a/src/Umbraco.Web/GridTemplateExtensions.cs b/src/Umbraco.Web.Common/Extensions/GridTemplateExtensions.cs similarity index 78% rename from src/Umbraco.Web/GridTemplateExtensions.cs rename to src/Umbraco.Web.Common/Extensions/GridTemplateExtensions.cs index 81dc33d2c6..e4a1c0d117 100644 --- a/src/Umbraco.Web/GridTemplateExtensions.cs +++ b/src/Umbraco.Web.Common/Extensions/GridTemplateExtensions.cs @@ -1,27 +1,27 @@ using System; -using System.Web.Mvc; -using System.Web.Mvc.Html; +using Microsoft.AspNetCore.Html; +using Microsoft.AspNetCore.Mvc.Rendering; using Umbraco.Core.Models.PublishedContent; -namespace Umbraco.Web +namespace Umbraco.Extensions { public static class GridTemplateExtensions { - public static MvcHtmlString GetGridHtml(this HtmlHelper html, IPublishedProperty property, string framework = "bootstrap3") + public static IHtmlContent GetGridHtml(this IHtmlHelper html, IPublishedProperty property, string framework = "bootstrap3") { var asString = property.GetValue() as string; - if (asString != null && string.IsNullOrEmpty(asString)) return new MvcHtmlString(string.Empty); + if (asString != null && string.IsNullOrEmpty(asString)) return new HtmlString(string.Empty); var view = "Grid/" + framework; return html.Partial(view, property.GetValue()); } - public static MvcHtmlString GetGridHtml(this HtmlHelper html, IPublishedContent contentItem) + public static IHtmlContent GetGridHtml(this IHtmlHelper html, IPublishedContent contentItem) { return html.GetGridHtml(contentItem, "bodyText", "bootstrap3"); } - public static MvcHtmlString GetGridHtml(this HtmlHelper html, IPublishedContent contentItem, string propertyAlias) + public static IHtmlContent GetGridHtml(this IHtmlHelper html, IPublishedContent contentItem, string propertyAlias) { if (propertyAlias == null) throw new ArgumentNullException(nameof(propertyAlias)); if (string.IsNullOrWhiteSpace(propertyAlias)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(propertyAlias)); @@ -29,7 +29,7 @@ namespace Umbraco.Web return html.GetGridHtml(contentItem, propertyAlias, "bootstrap3"); } - public static MvcHtmlString GetGridHtml(this HtmlHelper html, IPublishedContent contentItem, string propertyAlias, string framework) + public static IHtmlContent GetGridHtml(this IHtmlHelper html, IPublishedContent contentItem, string propertyAlias, string framework) { if (propertyAlias == null) throw new ArgumentNullException(nameof(propertyAlias)); if (string.IsNullOrWhiteSpace(propertyAlias)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(propertyAlias)); @@ -40,17 +40,17 @@ namespace Umbraco.Web var model = prop.GetValue(); var asString = model as string; - if (asString != null && string.IsNullOrEmpty(asString)) return new MvcHtmlString(string.Empty); + if (asString != null && string.IsNullOrEmpty(asString)) return new HtmlString(string.Empty); return html.Partial(view, model); } - public static MvcHtmlString GetGridHtml(this HtmlHelper html, IPublishedElement contentItem) + public static IHtmlContent GetGridHtml(this IHtmlHelper html, IPublishedElement contentItem) { return html.GetGridHtml(contentItem, "bodyText", "bootstrap3"); } - public static MvcHtmlString GetGridHtml(this HtmlHelper html, IPublishedElement contentItem, string propertyAlias) + public static IHtmlContent GetGridHtml(this IHtmlHelper html, IPublishedElement contentItem, string propertyAlias) { if (propertyAlias == null) throw new ArgumentNullException(nameof(propertyAlias)); if (string.IsNullOrWhiteSpace(propertyAlias)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(propertyAlias)); @@ -58,7 +58,7 @@ namespace Umbraco.Web return html.GetGridHtml(contentItem, propertyAlias, "bootstrap3"); } - public static MvcHtmlString GetGridHtml(this HtmlHelper html, IPublishedElement contentItem, string propertyAlias, string framework) + public static IHtmlContent GetGridHtml(this IHtmlHelper html, IPublishedElement contentItem, string propertyAlias, string framework) { if (propertyAlias == null) throw new ArgumentNullException(nameof(propertyAlias)); if (string.IsNullOrWhiteSpace(propertyAlias)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(propertyAlias)); @@ -69,25 +69,25 @@ namespace Umbraco.Web var model = prop.GetValue(); var asString = model as string; - if (asString != null && string.IsNullOrEmpty(asString)) return new MvcHtmlString(string.Empty); + if (asString != null && string.IsNullOrEmpty(asString)) return new HtmlString(string.Empty); return html.Partial(view, model); } - public static MvcHtmlString GetGridHtml(this IPublishedProperty property, HtmlHelper html, string framework = "bootstrap3") + public static IHtmlContent GetGridHtml(this IPublishedProperty property, IHtmlHelper html, string framework = "bootstrap3") { var asString = property.GetValue() as string; - if (asString != null && string.IsNullOrEmpty(asString)) return new MvcHtmlString(string.Empty); + if (asString != null && string.IsNullOrEmpty(asString)) return new HtmlString(string.Empty); var view = "Grid/" + framework; return html.Partial(view, property.GetValue()); } - public static MvcHtmlString GetGridHtml(this IPublishedContent contentItem, HtmlHelper html) + public static IHtmlContent GetGridHtml(this IPublishedContent contentItem, IHtmlHelper html) { return GetGridHtml(contentItem, html, "bodyText", "bootstrap3"); } - public static MvcHtmlString GetGridHtml(this IPublishedContent contentItem, HtmlHelper html, string propertyAlias) + public static IHtmlContent GetGridHtml(this IPublishedContent contentItem, IHtmlHelper html, string propertyAlias) { if (propertyAlias == null) throw new ArgumentNullException(nameof(propertyAlias)); if (string.IsNullOrWhiteSpace(propertyAlias)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(propertyAlias)); @@ -95,7 +95,7 @@ namespace Umbraco.Web return GetGridHtml(contentItem, html, propertyAlias, "bootstrap3"); } - public static MvcHtmlString GetGridHtml(this IPublishedContent contentItem, HtmlHelper html, string propertyAlias, string framework) + public static IHtmlContent GetGridHtml(this IPublishedContent contentItem, IHtmlHelper html, string propertyAlias, string framework) { if (propertyAlias == null) throw new ArgumentNullException(nameof(propertyAlias)); if (string.IsNullOrWhiteSpace(propertyAlias)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(propertyAlias)); @@ -106,7 +106,7 @@ namespace Umbraco.Web var model = prop.GetValue(); var asString = model as string; - if (asString != null && string.IsNullOrEmpty(asString)) return new MvcHtmlString(string.Empty); + if (asString != null && string.IsNullOrEmpty(asString)) return new HtmlString(string.Empty); return html.Partial(view, model); } diff --git a/src/Umbraco.Web.Common/Filters/UmbracoBackOfficeAuthorizeFilter.cs b/src/Umbraco.Web.Common/Filters/UmbracoBackOfficeAuthorizeFilter.cs index 05d46b431a..0c30b25ced 100644 --- a/src/Umbraco.Web.Common/Filters/UmbracoBackOfficeAuthorizeFilter.cs +++ b/src/Umbraco.Web.Common/Filters/UmbracoBackOfficeAuthorizeFilter.cs @@ -23,7 +23,7 @@ namespace Umbraco.Web.Common.Filters /// internal static bool Enable = true; private readonly IHostingEnvironment _hostingEnvironment; - private readonly IUmbracoContextAccessor _umbracoContext; + private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor; private readonly IRuntimeState _runtimeState; private readonly LinkGenerator _linkGenerator; private readonly bool _redirectToUmbracoLogin; @@ -31,12 +31,13 @@ namespace Umbraco.Web.Common.Filters private UmbracoBackOfficeAuthorizeFilter( IHostingEnvironment hostingEnvironment, - IUmbracoContextAccessor umbracoContext, - IRuntimeState runtimeState, LinkGenerator linkGenerator, + IBackOfficeSecurityAccessor backOfficeSecurityAccessor, + IRuntimeState runtimeState, + LinkGenerator linkGenerator, bool redirectToUmbracoLogin, bool requireApproval, string redirectUrl) { _hostingEnvironment = hostingEnvironment ?? throw new ArgumentNullException(nameof(hostingEnvironment)); - _umbracoContext = umbracoContext ?? throw new ArgumentNullException(nameof(umbracoContext)); + _backOfficeSecurityAccessor = backOfficeSecurityAccessor; _runtimeState = runtimeState ?? throw new ArgumentNullException(nameof(runtimeState)); _linkGenerator = linkGenerator ?? throw new ArgumentNullException(nameof(linkGenerator)); _redirectToUmbracoLogin = redirectToUmbracoLogin; @@ -54,17 +55,17 @@ namespace Umbraco.Web.Common.Filters /// public UmbracoBackOfficeAuthorizeFilter( IHostingEnvironment hostingEnvironment, - IUmbracoContextAccessor umbracoContext, + IBackOfficeSecurityAccessor backOfficeSecurityAccessor, IRuntimeState runtimeState, LinkGenerator linkGenerator, - string redirectUrl) : this(hostingEnvironment, umbracoContext, runtimeState, linkGenerator, false, false, redirectUrl) + string redirectUrl) : this(hostingEnvironment, backOfficeSecurityAccessor, runtimeState, linkGenerator, false, false, redirectUrl) { } public UmbracoBackOfficeAuthorizeFilter( IHostingEnvironment hostingEnvironment, - IUmbracoContextAccessor umbracoContext, + IBackOfficeSecurityAccessor backOfficeSecurityAccessor, IRuntimeState runtimeState, LinkGenerator linkGenerator, - bool redirectToUmbracoLogin, bool requireApproval) : this(hostingEnvironment, umbracoContext, runtimeState, linkGenerator, redirectToUmbracoLogin, requireApproval, null) + bool redirectToUmbracoLogin, bool requireApproval) : this(hostingEnvironment, backOfficeSecurityAccessor, runtimeState, linkGenerator, redirectToUmbracoLogin, requireApproval, null) { } @@ -99,7 +100,7 @@ namespace Umbraco.Web.Common.Filters // otherwise we need to ensure that a user is logged in return _runtimeState.Level == RuntimeLevel.Install || _runtimeState.Level == RuntimeLevel.Upgrade - || _umbracoContext.UmbracoContext?.Security.ValidateCurrentUser(false, _requireApproval) == ValidateRequestAttempt.Success; + || _backOfficeSecurityAccessor?.BackOfficeSecurity.ValidateCurrentUser(false, _requireApproval) == ValidateRequestAttempt.Success; } catch (Exception) { diff --git a/src/Umbraco.Web.Common/Install/InstallAuthorizeAttribute.cs b/src/Umbraco.Web.Common/Install/InstallAuthorizeAttribute.cs index 6ccebc9b25..bddb4fd015 100644 --- a/src/Umbraco.Web.Common/Install/InstallAuthorizeAttribute.cs +++ b/src/Umbraco.Web.Common/Install/InstallAuthorizeAttribute.cs @@ -1,9 +1,9 @@ using System; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Filters; -using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Umbraco.Core; +using Umbraco.Core.Security; namespace Umbraco.Web.Common.Install { @@ -19,33 +19,42 @@ namespace Umbraco.Web.Common.Install private class InstallAuthorizeFilter : IAuthorizationFilter { + private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor; + private readonly IRuntimeState _runtimeState; + private readonly ILogger _logger; + + public InstallAuthorizeFilter( + IBackOfficeSecurityAccessor backOfficeSecurityAccessor, + IRuntimeState runtimeState, + ILogger logger) + { + _backOfficeSecurityAccessor = backOfficeSecurityAccessor; + _runtimeState = runtimeState; + _logger = logger; + } + public void OnAuthorization(AuthorizationFilterContext authorizationFilterContext) { - var serviceProvider = authorizationFilterContext.HttpContext.RequestServices; - var runtimeState = serviceProvider.GetService(); - var umbracoContext = serviceProvider.GetService(); - var logger = serviceProvider.GetService>(); - - if (!IsAllowed(runtimeState, umbracoContext, logger)) + if (!IsAllowed()) { authorizationFilterContext.Result = new ForbidResult(); } } - private static bool IsAllowed(IRuntimeState runtimeState, IUmbracoContext umbracoContext, ILogger logger) + private bool IsAllowed() { try { // if not configured (install or upgrade) then we can continue // otherwise we need to ensure that a user is logged in - return runtimeState.Level == RuntimeLevel.Install - || runtimeState.Level == RuntimeLevel.Upgrade - || (umbracoContext?.Security?.ValidateCurrentUser() ?? false); + return _runtimeState.Level == RuntimeLevel.Install + || _runtimeState.Level == RuntimeLevel.Upgrade + || (_backOfficeSecurityAccessor?.BackOfficeSecurity?.ValidateCurrentUser() ?? false); } catch (Exception ex) { - logger.LogError(ex, "An error occurred determining authorization"); + _logger.LogError(ex, "An error occurred determining authorization"); return false; } } diff --git a/src/Umbraco.Web.Common/Macros/MacroRenderer.cs b/src/Umbraco.Web.Common/Macros/MacroRenderer.cs index c0d2fdbdd4..43425d7bb8 100644 --- a/src/Umbraco.Web.Common/Macros/MacroRenderer.cs +++ b/src/Umbraco.Web.Common/Macros/MacroRenderer.cs @@ -25,6 +25,7 @@ namespace Umbraco.Web.Macros private readonly IProfilingLogger _profilingLogger; private readonly ILogger _logger; private readonly IUmbracoContextAccessor _umbracoContextAccessor; + private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor; private readonly ContentSettings _contentSettings; private readonly ILocalizedTextService _textService; private readonly AppCaches _appCaches; @@ -40,6 +41,7 @@ namespace Umbraco.Web.Macros IProfilingLogger profilingLogger , ILogger logger, IUmbracoContextAccessor umbracoContextAccessor, + IBackOfficeSecurityAccessor backOfficeSecurityAccessor, IOptions contentSettings, ILocalizedTextService textService, AppCaches appCaches, @@ -54,6 +56,7 @@ namespace Umbraco.Web.Macros _profilingLogger = profilingLogger ?? throw new ArgumentNullException(nameof(profilingLogger )); _logger = logger; _umbracoContextAccessor = umbracoContextAccessor ?? throw new ArgumentNullException(nameof(umbracoContextAccessor)); + _backOfficeSecurityAccessor = backOfficeSecurityAccessor; _contentSettings = contentSettings.Value ?? throw new ArgumentNullException(nameof(contentSettings)); _textService = textService; _appCaches = appCaches ?? throw new ArgumentNullException(nameof(appCaches)); @@ -89,7 +92,7 @@ namespace Umbraco.Web.Macros { object key = 0; - if (_umbracoContextAccessor.GetRequiredUmbracoContext().Security.IsAuthenticated()) + if (_backOfficeSecurityAccessor.BackOfficeSecurity.IsAuthenticated()) { key = _memberUserKeyProvider.GetMemberProviderUserKey() ?? 0; } diff --git a/src/Umbraco.Web.Common/UmbracoContext/UmbracoContext.cs b/src/Umbraco.Web.Common/UmbracoContext/UmbracoContext.cs index a0bc8b9140..56dd4b054e 100644 --- a/src/Umbraco.Web.Common/UmbracoContext/UmbracoContext.cs +++ b/src/Umbraco.Web.Common/UmbracoContext/UmbracoContext.cs @@ -21,6 +21,7 @@ namespace Umbraco.Web private readonly Lazy _publishedSnapshot; private string _previewToken; private bool? _previewing; + private IBackOfficeSecurity _backofficeSecurity; // initializes a new instance of the UmbracoContext class // internal for unit tests @@ -46,7 +47,7 @@ namespace Umbraco.Web ObjectCreated = DateTime.Now; UmbracoRequestId = Guid.NewGuid(); - Security = backofficeSecurity ?? throw new ArgumentNullException(nameof(backofficeSecurity)); + _backofficeSecurity = backofficeSecurity ?? throw new ArgumentNullException(nameof(backofficeSecurity)); // beware - we cannot expect a current user here, so detecting preview mode must be a lazy thing _publishedSnapshot = new Lazy(() => publishedSnapshotService.CreatePublishedSnapshot(PreviewToken)); @@ -74,11 +75,6 @@ namespace Umbraco.Web /// public Guid UmbracoRequestId { get; } - /// - /// Gets the BackofficeSecurity class - /// - public IBackOfficeSecurity Security { get; } - /// /// Gets the uri that is handled by ASP.NET after server-side rewriting took place. /// @@ -168,7 +164,7 @@ namespace Umbraco.Web var requestUrl = _requestAccessor.GetRequestUrl(); if (requestUrl != null && requestUrl.IsBackOfficeRequest(_globalSettings, _hostingEnvironment) == false - && Security.CurrentUser != null) + && _backofficeSecurity.CurrentUser != null) { var previewToken = _cookieManager.GetCookieValue(Constants.Web.PreviewCookieName); // may be null or empty _previewToken = previewToken.IsNullOrWhiteSpace() ? null : previewToken; @@ -190,8 +186,6 @@ namespace Umbraco.Web { // DisposableObject ensures that this runs only once - Security.DisposeIfDisposable(); - // help caches release resources // (but don't create caches just to dispose them) // context is not multi-threaded diff --git a/src/Umbraco.Web/Composing/Current.cs b/src/Umbraco.Web/Composing/Current.cs index b1e13745d8..8f698db995 100644 --- a/src/Umbraco.Web/Composing/Current.cs +++ b/src/Umbraco.Web/Composing/Current.cs @@ -21,6 +21,7 @@ using Umbraco.Core.Packaging; using Umbraco.Core.PropertyEditors; using Umbraco.Core.Runtime; using Umbraco.Core.Scoping; +using Umbraco.Core.Security; using Umbraco.Core.Services; using Umbraco.Core.Strings; using Umbraco.Core.Sync; @@ -87,6 +88,9 @@ namespace Umbraco.Web.Composing public static IUmbracoContext UmbracoContext => UmbracoContextAccessor.UmbracoContext; + public static IBackOfficeSecurityAccessor BackOfficeSecurityAccessor + => Factory.GetRequiredService(); + public static UmbracoHelper UmbracoHelper => Factory.GetRequiredService(); public static IUmbracoComponentRenderer UmbracoComponentRenderer diff --git a/src/Umbraco.Web/Mvc/UmbracoAuthorizeAttribute.cs b/src/Umbraco.Web/Mvc/UmbracoAuthorizeAttribute.cs index a9127aca17..8ada898c21 100644 --- a/src/Umbraco.Web/Mvc/UmbracoAuthorizeAttribute.cs +++ b/src/Umbraco.Web/Mvc/UmbracoAuthorizeAttribute.cs @@ -21,7 +21,7 @@ namespace Umbraco.Web.Mvc private IRuntimeState RuntimeState => _runtimeState ?? Current.RuntimeState; - private IBackOfficeSecurity BackOfficeSecurity => _backOfficeSecurityAccessor.BackOfficeSecurity ?? Current.UmbracoContext.Security; + private IBackOfficeSecurity BackOfficeSecurity => _backOfficeSecurityAccessor.BackOfficeSecurity ?? Current.BackOfficeSecurityAccessor.BackOfficeSecurity; /// /// THIS SHOULD BE ONLY USED FOR UNIT TESTS diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 8157a90715..ae2c1b8fb6 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -221,7 +221,6 @@ - diff --git a/src/Umbraco.Web/UmbracoHttpHandler.cs b/src/Umbraco.Web/UmbracoHttpHandler.cs index 8a76770fda..711af68613 100644 --- a/src/Umbraco.Web/UmbracoHttpHandler.cs +++ b/src/Umbraco.Web/UmbracoHttpHandler.cs @@ -13,12 +13,13 @@ namespace Umbraco.Web private UrlHelper _url; protected UmbracoHttpHandler() - : this(Current.UmbracoContextAccessor, Current.Services, Current.Logger, Current.ProfilingLogger) + : this(Current.UmbracoContextAccessor, Current.BackOfficeSecurityAccessor, Current.Services, Current.Logger, Current.ProfilingLogger) { } - protected UmbracoHttpHandler(IUmbracoContextAccessor umbracoContextAccessor,ServiceContext service, ILogger logger, IProfilingLogger profilingLogger ) + protected UmbracoHttpHandler(IUmbracoContextAccessor umbracoContextAccessor, IBackOfficeSecurityAccessor backOfficeSecurityAccessor,ServiceContext service, ILogger logger, IProfilingLogger profilingLogger ) { UmbracoContextAccessor = umbracoContextAccessor; + BackOfficeSecurityAccessor = backOfficeSecurityAccessor; Logger = logger; ProfilingLogger = profilingLogger ; Services = service; @@ -43,6 +44,8 @@ namespace Umbraco.Web /// public IUmbracoContextAccessor UmbracoContextAccessor { get; } + public IBackOfficeSecurityAccessor BackOfficeSecurityAccessor { get; } + /// /// Gets the services context. /// @@ -51,7 +54,7 @@ namespace Umbraco.Web /// /// Gets the web security helper. /// - public IBackOfficeSecurity Security => UmbracoContextAccessor.UmbracoContext.Security; + public IBackOfficeSecurity Security => BackOfficeSecurityAccessor.BackOfficeSecurity; /// /// Gets the Url helper. diff --git a/src/Umbraco.Web/UmbracoWebService.cs b/src/Umbraco.Web/UmbracoWebService.cs index 0d4c4646f0..27c6af2c8b 100644 --- a/src/Umbraco.Web/UmbracoWebService.cs +++ b/src/Umbraco.Web/UmbracoWebService.cs @@ -16,17 +16,18 @@ namespace Umbraco.Web { private UrlHelper _url; - protected UmbracoWebService(ILogger logger, IProfilingLogger profilingLogger, IUmbracoContextAccessor umbracoContextAccessor, ServiceContext services, GlobalSettings globalSettings) + protected UmbracoWebService(ILogger logger, IProfilingLogger profilingLogger, IUmbracoContextAccessor umbracoContextAccessor, IBackOfficeSecurityAccessor backOfficeSecurityAccessor, ServiceContext services, GlobalSettings globalSettings) { Logger = logger; ProfilingLogger = profilingLogger; UmbracoContextAccessor = umbracoContextAccessor; + BackOfficeSecurityAccessor = backOfficeSecurityAccessor; Services = services; GlobalSettings = globalSettings; } protected UmbracoWebService() - : this(Current.Logger, Current.ProfilingLogger, Current.UmbracoContextAccessor, Current.Services, new GlobalSettings()) + : this(Current.Logger, Current.ProfilingLogger, Current.UmbracoContextAccessor, Current.BackOfficeSecurityAccessor, Current.Services,new GlobalSettings()) { } @@ -50,6 +51,8 @@ namespace Umbraco.Web /// public IUmbracoContextAccessor UmbracoContextAccessor { get; } + public IBackOfficeSecurityAccessor BackOfficeSecurityAccessor { get; } + /// /// Gets the services context. /// @@ -63,7 +66,7 @@ namespace Umbraco.Web /// /// Gets the web security helper. /// - public IBackOfficeSecurity Security => UmbracoContext.Security; + public IBackOfficeSecurity Security => BackOfficeSecurityAccessor.BackOfficeSecurity; /// /// Gets the Url helper. diff --git a/src/Umbraco.Web/WebApi/UmbracoApiController.cs b/src/Umbraco.Web/WebApi/UmbracoApiController.cs index 724ea810c9..b1d8c7fcfe 100644 --- a/src/Umbraco.Web/WebApi/UmbracoApiController.cs +++ b/src/Umbraco.Web/WebApi/UmbracoApiController.cs @@ -7,6 +7,7 @@ using Umbraco.Core.Configuration.Models; using Umbraco.Core.Logging; using Umbraco.Core.Mapping; using Umbraco.Core.Persistence; +using Umbraco.Core.Security; using Umbraco.Core.Services; using Umbraco.Web.Routing; @@ -21,8 +22,8 @@ namespace Umbraco.Web.WebApi { } - protected UmbracoApiController(GlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ISqlContext sqlContext, ServiceContext services, AppCaches appCaches, IProfilingLogger logger, IRuntimeState runtimeState, UmbracoMapper umbracoMapper, IPublishedUrlProvider publishedUrlProvider) - : base(globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoMapper, publishedUrlProvider) + protected UmbracoApiController(GlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, IBackOfficeSecurityAccessor backOfficeSecurityAccessor, ISqlContext sqlContext, ServiceContext services, AppCaches appCaches, IProfilingLogger logger, IRuntimeState runtimeState, UmbracoMapper umbracoMapper, IPublishedUrlProvider publishedUrlProvider) + : base(globalSettings, umbracoContextAccessor, backOfficeSecurityAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoMapper, publishedUrlProvider) { } } diff --git a/src/Umbraco.Web/WebApi/UmbracoApiControllerBase.cs b/src/Umbraco.Web/WebApi/UmbracoApiControllerBase.cs index 7d9c620a6d..e5e123db88 100644 --- a/src/Umbraco.Web/WebApi/UmbracoApiControllerBase.cs +++ b/src/Umbraco.Web/WebApi/UmbracoApiControllerBase.cs @@ -41,6 +41,7 @@ namespace Umbraco.Web.WebApi : this( Current.Factory.GetRequiredService(), Current.Factory.GetRequiredService(), + Current.Factory.GetRequiredService(), Current.Factory.GetRequiredService(), Current.Factory.GetRequiredService(), Current.Factory.GetRequiredService(), @@ -54,9 +55,10 @@ namespace Umbraco.Web.WebApi /// /// Initializes a new instance of the class with all its dependencies. /// - protected UmbracoApiControllerBase(GlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ISqlContext sqlContext, ServiceContext services, AppCaches appCaches, IProfilingLogger logger, IRuntimeState runtimeState, UmbracoMapper umbracoMapper, IPublishedUrlProvider publishedUrlProvider) + protected UmbracoApiControllerBase(GlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, IBackOfficeSecurityAccessor backOfficeSecurityAccessor, ISqlContext sqlContext, ServiceContext services, AppCaches appCaches, IProfilingLogger logger, IRuntimeState runtimeState, UmbracoMapper umbracoMapper, IPublishedUrlProvider publishedUrlProvider) { UmbracoContextAccessor = umbracoContextAccessor; + BackOfficeSecurityAccessor = backOfficeSecurityAccessor; SqlContext = sqlContext; Services = services; AppCaches = appCaches; @@ -82,6 +84,8 @@ namespace Umbraco.Web.WebApi /// public virtual IUmbracoContextAccessor UmbracoContextAccessor { get; } + public IBackOfficeSecurityAccessor BackOfficeSecurityAccessor { get; } + /// /// Gets the sql context. @@ -118,7 +122,7 @@ namespace Umbraco.Web.WebApi /// /// Gets the web security helper. /// - public IBackOfficeSecurity Security => UmbracoContext.Security; + public IBackOfficeSecurity Security => BackOfficeSecurityAccessor.BackOfficeSecurity; /// /// Tries to get the current HttpContext. diff --git a/src/Umbraco.Web/WebApi/UmbracoAuthorizeAttribute.cs b/src/Umbraco.Web/WebApi/UmbracoAuthorizeAttribute.cs index 8e414be5ef..dea72b7be9 100644 --- a/src/Umbraco.Web/WebApi/UmbracoAuthorizeAttribute.cs +++ b/src/Umbraco.Web/WebApi/UmbracoAuthorizeAttribute.cs @@ -25,7 +25,7 @@ namespace Umbraco.Web.WebApi private IRuntimeState RuntimeState => _runtimeState ?? Current.RuntimeState; - private IBackOfficeSecurity BackOfficeSecurity => _backOfficeSecurityAccessor.BackOfficeSecurity ?? Current.UmbracoContext.Security; + private IBackOfficeSecurity BackOfficeSecurity => _backOfficeSecurityAccessor.BackOfficeSecurity ?? Current.BackOfficeSecurityAccessor.BackOfficeSecurity; /// /// THIS SHOULD BE ONLY USED FOR UNIT TESTS diff --git a/src/Umbraco.Web/WebApi/UmbracoAuthorizedApiController.cs b/src/Umbraco.Web/WebApi/UmbracoAuthorizedApiController.cs index 87627501bd..f744213276 100644 --- a/src/Umbraco.Web/WebApi/UmbracoAuthorizedApiController.cs +++ b/src/Umbraco.Web/WebApi/UmbracoAuthorizedApiController.cs @@ -8,6 +8,7 @@ using Umbraco.Core.Persistence; using Umbraco.Core.Services; using Umbraco.Web.Security; using Umbraco.Core.Mapping; +using Umbraco.Core.Security; using Umbraco.Web.Routing; namespace Umbraco.Web.WebApi @@ -36,8 +37,8 @@ namespace Umbraco.Web.WebApi { } - protected UmbracoAuthorizedApiController(GlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ISqlContext sqlContext, ServiceContext services, AppCaches appCaches, IProfilingLogger logger, IRuntimeState runtimeState, UmbracoMapper umbracoMapper, IPublishedUrlProvider publishedUrlProvider) - : base(globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoMapper, publishedUrlProvider) + protected UmbracoAuthorizedApiController(GlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, IBackOfficeSecurityAccessor backOfficeSecurityAccessor, ISqlContext sqlContext, ServiceContext services, AppCaches appCaches, IProfilingLogger logger, IRuntimeState runtimeState, UmbracoMapper umbracoMapper, IPublishedUrlProvider publishedUrlProvider) + : base(globalSettings, umbracoContextAccessor, backOfficeSecurityAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoMapper, publishedUrlProvider) { }