From 768d95588fc83d1f0539d880b499d2eb4f7c8df8 Mon Sep 17 00:00:00 2001 From: Shannon Date: Wed, 13 May 2020 16:09:54 +1000 Subject: [PATCH] Moves the PreviewController to netcore, ports the UmbracoAuthorizeAttribute to netcore, routes the minimal back office controllers and dynamically routes based on runtime. --- .../Editors/BackOfficeModel.cs | 6 +- .../Editors/BackOfficePreviewModel.cs | 6 +- .../Web/CookieManagerExtensions.cs | 23 ++++ src/Umbraco.Core/Web/ICookieManager.cs | 1 + .../Controllers/AuthenticationController.cs | 15 +++ .../Controllers/BackOfficeController.cs | 1 + .../Controllers}/PreviewController.cs | 45 +++---- .../Filters/UmbracoAuthorizeAttribute.cs | 35 ++++++ .../Filters/UmbracoAuthorizeFilter.cs | 113 ++++++++++++++++++ .../Routing/BackOfficeAreaRoutes.cs | 65 ++++++++-- .../Editors/BackOfficeController.cs | 6 +- src/Umbraco.Web/HttpCookieExtensions.cs | 14 --- src/Umbraco.Web/Mvc/BackOfficeArea.cs | 4 +- .../Mvc/UmbracoAuthorizeAttribute.cs | 5 +- src/Umbraco.Web/Umbraco.Web.csproj | 3 - .../WebApi/UmbracoAuthorizeAttribute.cs | 5 +- 16 files changed, 278 insertions(+), 69 deletions(-) rename src/{Umbraco.Web => Umbraco.Core}/Editors/BackOfficeModel.cs (87%) rename src/{Umbraco.Web => Umbraco.Core}/Editors/BackOfficePreviewModel.cs (75%) create mode 100644 src/Umbraco.Core/Web/CookieManagerExtensions.cs create mode 100644 src/Umbraco.Web.BackOffice/Controllers/AuthenticationController.cs rename src/{Umbraco.Web/Editors => Umbraco.Web.BackOffice/Controllers}/PreviewController.cs (79%) create mode 100644 src/Umbraco.Web.BackOffice/Filters/UmbracoAuthorizeAttribute.cs create mode 100644 src/Umbraco.Web.BackOffice/Filters/UmbracoAuthorizeFilter.cs diff --git a/src/Umbraco.Web/Editors/BackOfficeModel.cs b/src/Umbraco.Core/Editors/BackOfficeModel.cs similarity index 87% rename from src/Umbraco.Web/Editors/BackOfficeModel.cs rename to src/Umbraco.Core/Editors/BackOfficeModel.cs index cf1b4a3879..779e290aad 100644 --- a/src/Umbraco.Web/Editors/BackOfficeModel.cs +++ b/src/Umbraco.Core/Editors/BackOfficeModel.cs @@ -7,12 +7,12 @@ using Umbraco.Web.Trees; namespace Umbraco.Web.Editors { - + // TODO: Almost nothing here needs to exist since we can inject these into the view public class BackOfficeModel { public BackOfficeModel(UmbracoFeatures features, IGlobalSettings globalSettings, IUmbracoVersion umbracoVersion, IContentSettings contentSettings, TreeCollection treeCollection, - IHttpContextAccessor httpContextAccessor, IHostingEnvironment hostingEnvironment, + IHostingEnvironment hostingEnvironment, IRuntimeSettings runtimeSettings, ISecuritySettings securitySettings) { Features = features; @@ -20,7 +20,6 @@ namespace Umbraco.Web.Editors UmbracoVersion = umbracoVersion; ContentSettings = contentSettings; TreeCollection = treeCollection; - HttpContextAccessor = httpContextAccessor; HostingEnvironment = hostingEnvironment; RuntimeSettings = runtimeSettings; SecuritySettings = securitySettings; @@ -32,7 +31,6 @@ namespace Umbraco.Web.Editors public IUmbracoVersion UmbracoVersion { get; } public IContentSettings ContentSettings { get; } public TreeCollection TreeCollection { get; } - public IHttpContextAccessor HttpContextAccessor { get; } public IHostingEnvironment HostingEnvironment { get; } public IRuntimeSettings RuntimeSettings { get; set; } public ISecuritySettings SecuritySettings { get; set; } diff --git a/src/Umbraco.Web/Editors/BackOfficePreviewModel.cs b/src/Umbraco.Core/Editors/BackOfficePreviewModel.cs similarity index 75% rename from src/Umbraco.Web/Editors/BackOfficePreviewModel.cs rename to src/Umbraco.Core/Editors/BackOfficePreviewModel.cs index 2235d8fdaf..db37bba9ce 100644 --- a/src/Umbraco.Web/Editors/BackOfficePreviewModel.cs +++ b/src/Umbraco.Core/Editors/BackOfficePreviewModel.cs @@ -2,20 +2,20 @@ using Umbraco.Core.Configuration; using Umbraco.Core.Configuration.UmbracoSettings; using Umbraco.Core.Hosting; -using Umbraco.Core.IO; using Umbraco.Core.Models; using Umbraco.Web.Features; using Umbraco.Web.Trees; namespace Umbraco.Web.Editors { + // TODO: Almost nothing here needs to exist since we can inject these into the view public class BackOfficePreviewModel : BackOfficeModel { private readonly UmbracoFeatures _features; public IEnumerable Languages { get; } - public BackOfficePreviewModel(UmbracoFeatures features, IGlobalSettings globalSettings, IUmbracoVersion umbracoVersion, IEnumerable languages, IContentSettings contentSettings, TreeCollection treeCollection, IHttpContextAccessor httpContextAccessor, IHostingEnvironment hostingEnvironment, IRuntimeSettings runtimeSettings, ISecuritySettings securitySettings) - : base(features, globalSettings, umbracoVersion, contentSettings, treeCollection, httpContextAccessor, hostingEnvironment, runtimeSettings, securitySettings) + public BackOfficePreviewModel(UmbracoFeatures features, IGlobalSettings globalSettings, IUmbracoVersion umbracoVersion, IEnumerable languages, IContentSettings contentSettings, TreeCollection treeCollection, IHostingEnvironment hostingEnvironment, IRuntimeSettings runtimeSettings, ISecuritySettings securitySettings) + : base(features, globalSettings, umbracoVersion, contentSettings, treeCollection, hostingEnvironment, runtimeSettings, securitySettings) { _features = features; Languages = languages; diff --git a/src/Umbraco.Core/Web/CookieManagerExtensions.cs b/src/Umbraco.Core/Web/CookieManagerExtensions.cs new file mode 100644 index 0000000000..5a1f748aaf --- /dev/null +++ b/src/Umbraco.Core/Web/CookieManagerExtensions.cs @@ -0,0 +1,23 @@ +using Umbraco.Core; + +namespace Umbraco.Web +{ + public static class CookieManagerExtensions + { + public static string GetPreviewCookieValue(this ICookieManager cookieManager) + { + return cookieManager.GetCookieValue(Constants.Web.PreviewCookieName); + } + + /// + /// Does a preview cookie exist ? + /// + /// + /// + public static bool HasPreviewCookie(this ICookieManager cookieManager) + { + return cookieManager.HasCookie(Constants.Web.PreviewCookieName); + } + } + +} diff --git a/src/Umbraco.Core/Web/ICookieManager.cs b/src/Umbraco.Core/Web/ICookieManager.cs index dc5d3f65c2..39eda89222 100644 --- a/src/Umbraco.Core/Web/ICookieManager.cs +++ b/src/Umbraco.Core/Web/ICookieManager.cs @@ -1,5 +1,6 @@ namespace Umbraco.Web { + public interface ICookieManager { void ExpireCookie(string cookieName); diff --git a/src/Umbraco.Web.BackOffice/Controllers/AuthenticationController.cs b/src/Umbraco.Web.BackOffice/Controllers/AuthenticationController.cs new file mode 100644 index 0000000000..ae8470ea33 --- /dev/null +++ b/src/Umbraco.Web.BackOffice/Controllers/AuthenticationController.cs @@ -0,0 +1,15 @@ +using Microsoft.AspNetCore.Mvc; +using Umbraco.Web.Common.Attributes; +using Umbraco.Web.Common.Filters; + +namespace Umbraco.Web.BackOffice.Controllers +{ + [Area(Umbraco.Core.Constants.Web.Mvc.BackOfficeArea)] + //[ValidationFilter] // TODO: I don't actually think this is required with our custom Application Model conventions applied + [TypeFilter(typeof(AngularJsonOnlyConfigurationAttribute))] + [IsBackOffice] + public class AuthenticationController : ControllerBase + { + // TODO: We need to import the logic from Umbraco.Web.Editors.AuthenticationController and it should not be an auto-routed api controller + } +} diff --git a/src/Umbraco.Web.BackOffice/Controllers/BackOfficeController.cs b/src/Umbraco.Web.BackOffice/Controllers/BackOfficeController.cs index f29cede61b..5d5fd120de 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/BackOfficeController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/BackOfficeController.cs @@ -10,6 +10,7 @@ using Umbraco.Web.WebAssets; namespace Umbraco.Web.BackOffice.Controllers { + [Area(Umbraco.Core.Constants.Web.Mvc.BackOfficeArea)] public class BackOfficeController : Controller { diff --git a/src/Umbraco.Web/Editors/PreviewController.cs b/src/Umbraco.Web.BackOffice/Controllers/PreviewController.cs similarity index 79% rename from src/Umbraco.Web/Editors/PreviewController.cs rename to src/Umbraco.Web.BackOffice/Controllers/PreviewController.cs index c501323200..bd2aeac475 100644 --- a/src/Umbraco.Web/Editors/PreviewController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/PreviewController.cs @@ -1,25 +1,28 @@ -using System; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.ViewEngines; +using System; using System.Threading.Tasks; -using System.Web; -using System.Web.Mvc; -using System.Web.UI; using Umbraco.Core; using Umbraco.Core.Configuration; using Umbraco.Core.Configuration.UmbracoSettings; using Umbraco.Core.Hosting; using Umbraco.Core.Services; using Umbraco.Core.WebAssets; -using Umbraco.Web.Composing; +using Umbraco.Web.BackOffice.Filters; +using Umbraco.Web.Common.ActionResults; +using Umbraco.Web.Common.Filters; +using Umbraco.Web.Editors; using Umbraco.Web.Features; -using Umbraco.Web.Mvc; using Umbraco.Web.PublishedCache; using Umbraco.Web.Trees; using Umbraco.Web.WebAssets; using Constants = Umbraco.Core.Constants; -namespace Umbraco.Web.Editors +namespace Umbraco.Web.BackOffice.Controllers { [DisableBrowserCache] + [Area(Umbraco.Core.Constants.Web.Mvc.BackOfficeArea)] public class PreviewController : Controller { private readonly UmbracoFeatures _features; @@ -36,6 +39,7 @@ namespace Umbraco.Web.Editors private readonly IRuntimeSettings _runtimeSettings; private readonly ISecuritySettings _securitySettings; private readonly IRuntimeMinifier _runtimeMinifier; + private readonly ICompositeViewEngine _viewEngines; public PreviewController( UmbracoFeatures features, @@ -51,7 +55,8 @@ namespace Umbraco.Web.Editors ICookieManager cookieManager, IRuntimeSettings settings, ISecuritySettings securitySettings, - IRuntimeMinifier runtimeMinifier) + IRuntimeMinifier runtimeMinifier, + ICompositeViewEngine viewEngines) { _features = features; _globalSettings = globalSettings; @@ -67,6 +72,7 @@ namespace Umbraco.Web.Editors _runtimeSettings = settings; _securitySettings = securitySettings; _runtimeMinifier = runtimeMinifier; + _viewEngines = viewEngines; } [UmbracoAuthorize(redirectToUmbracoLogin: true)] @@ -75,15 +81,13 @@ namespace Umbraco.Web.Editors { var availableLanguages = _localizationService.GetAllLanguages(); - var model = new BackOfficePreviewModel(_features, _globalSettings, _umbracoVersion, availableLanguages, _contentSettings, _treeCollection, _httpContextAccessor, _hostingEnvironment, _runtimeSettings, _securitySettings); + var model = new BackOfficePreviewModel(_features, _globalSettings, _umbracoVersion, availableLanguages, _contentSettings, _treeCollection, _hostingEnvironment, _runtimeSettings, _securitySettings); if (model.PreviewExtendedHeaderView.IsNullOrWhiteSpace() == false) { - var viewEngineResult = ViewEngines.Engines.FindPartialView(ControllerContext, model.PreviewExtendedHeaderView); + var viewEngineResult = _viewEngines.FindView(ControllerContext, model.PreviewExtendedHeaderView, false); if (viewEngineResult.View == null) - { throw new InvalidOperationException("Could not find the view " + model.PreviewExtendedHeaderView + ", the following locations were searched: " + Environment.NewLine + string.Join(Environment.NewLine, viewEngineResult.SearchedLocations)); - } } return View(_globalSettings.GetBackOfficePath(_hostingEnvironment).EnsureEndsWith('/') + "Views/Preview/" + "Index.cshtml", model); @@ -94,13 +98,14 @@ namespace Umbraco.Web.Editors /// /// [MinifyJavaScriptResult(Order = 0)] - [OutputCache(Order = 1, VaryByParam = "none", Location = OutputCacheLocation.Server, Duration = 5000)] + // TODO: Replace this with response caching https://docs.microsoft.com/en-us/aspnet/core/performance/caching/response?view=aspnetcore-3.1 + //[OutputCache(Order = 1, VaryByParam = "none", Location = OutputCacheLocation.Server, Duration = 5000)] public async Task Application() { var files = await _runtimeMinifier.GetAssetPathsAsync(BackOfficeWebAssets.UmbracoPreviewJsBundleName); var result = BackOfficeJavaScriptInitializer.GetJavascriptInitialization(files, "umbraco.preview", _globalSettings, _hostingEnvironment); - return JavaScript(result); + return new JavaScriptResult(result); } /// @@ -114,7 +119,7 @@ namespace Umbraco.Web.Editors var previewToken = _publishedSnapshotService.EnterPreview(user, id); - Response.Cookies.Set(new HttpCookie(Constants.Web.PreviewCookieName, previewToken)); + _cookieManager.SetCookieValue(Constants.Web.PreviewCookieName, previewToken); // use a numeric url because content may not be in cache and so .Url would fail var query = culture.IsNullOrWhiteSpace() ? string.Empty : $"?culture={culture}"; @@ -126,17 +131,15 @@ namespace Umbraco.Web.Editors public ActionResult End(string redir = null) { var previewToken = _cookieManager.GetPreviewCookieValue(); - var service = Current.PublishedSnapshotService; - service.ExitPreview(previewToken); - System.Web.HttpContext.Current.ExpireCookie(Constants.Web.PreviewCookieName); + _publishedSnapshotService.ExitPreview(previewToken); + + _cookieManager.ExpireCookie(Constants.Web.PreviewCookieName); if (Uri.IsWellFormedUriString(redir, UriKind.Relative) && redir.StartsWith("//") == false - && Uri.TryCreate(redir, UriKind.Relative, out Uri url)) - { + && Uri.TryCreate(redir, UriKind.Relative, out var url)) return Redirect(url.ToString()); - } return Redirect("/"); } diff --git a/src/Umbraco.Web.BackOffice/Filters/UmbracoAuthorizeAttribute.cs b/src/Umbraco.Web.BackOffice/Filters/UmbracoAuthorizeAttribute.cs new file mode 100644 index 0000000000..47bfa80956 --- /dev/null +++ b/src/Umbraco.Web.BackOffice/Filters/UmbracoAuthorizeAttribute.cs @@ -0,0 +1,35 @@ +using Microsoft.AspNetCore.Mvc; + +namespace Umbraco.Web.BackOffice.Filters +{ + /// + /// Ensures authorization is successful for a back office user. + /// + public class UmbracoAuthorizeAttribute : TypeFilterAttribute + { + /// + /// Default constructor + /// + public UmbracoAuthorizeAttribute() : base(typeof(UmbracoAuthorizeFilter)) + { + } + + /// + /// Constructor with redirect umbraco login behavior + /// + /// + public UmbracoAuthorizeAttribute(bool redirectToUmbracoLogin) : base(typeof(UmbracoAuthorizeFilter)) + { + Arguments = new object[] { redirectToUmbracoLogin }; + } + + /// + /// Constructor with redirect url behavior + /// + /// + public UmbracoAuthorizeAttribute(string redirectUrl) : base(typeof(UmbracoAuthorizeFilter)) + { + Arguments = new object[] { redirectUrl }; + } + } +} diff --git a/src/Umbraco.Web.BackOffice/Filters/UmbracoAuthorizeFilter.cs b/src/Umbraco.Web.BackOffice/Filters/UmbracoAuthorizeFilter.cs new file mode 100644 index 0000000000..9a590b5c87 --- /dev/null +++ b/src/Umbraco.Web.BackOffice/Filters/UmbracoAuthorizeFilter.cs @@ -0,0 +1,113 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Filters; +using Microsoft.AspNetCore.Routing; +using System; +using Umbraco.Core; +using Umbraco.Extensions; +using Umbraco.Web.Security; + +namespace Umbraco.Web.BackOffice.Filters +{ + + /// + /// Ensures authorization is successful for a back office user. + /// + public class UmbracoAuthorizeFilter : IAuthorizationFilter + { + private readonly bool _requireApproval; + + /// + /// Can be used by unit tests to enable/disable this filter + /// + internal static bool Enable = true; + + private readonly IUmbracoContextAccessor _umbracoContext; + private readonly IRuntimeState _runtimeState; + private readonly LinkGenerator _linkGenerator; + private readonly bool _redirectToUmbracoLogin; + private string _redirectUrl; + + /// + /// Default constructor + /// + /// + /// + /// + public UmbracoAuthorizeFilter( + IUmbracoContextAccessor umbracoContext, IRuntimeState runtimeState, LinkGenerator linkGenerator) + { + _umbracoContext = umbracoContext ?? throw new ArgumentNullException(nameof(umbracoContext)); + _runtimeState = runtimeState ?? throw new ArgumentNullException(nameof(runtimeState)); + _linkGenerator = linkGenerator ?? throw new ArgumentNullException(nameof(linkGenerator)); + } + + /// + /// Constructor with redirect umbraco login behavior + /// + /// + /// + /// + /// If true will redirect to the umbraco login page if not authorized + public UmbracoAuthorizeFilter( + IUmbracoContextAccessor umbracoContext, IRuntimeState runtimeState, LinkGenerator linkGenerator, + bool redirectToUmbracoLogin) + : this(umbracoContext, runtimeState, linkGenerator) + { + _redirectToUmbracoLogin = redirectToUmbracoLogin; + } + + /// + /// Constructor with redirect url behavior + /// + /// + /// + /// /// + /// If specified will redirect to this URL if not authorized + public UmbracoAuthorizeFilter( + IUmbracoContextAccessor umbracoContext, IRuntimeState runtimeState, LinkGenerator linkGenerator, + string redirectUrl) + : this(umbracoContext, runtimeState, linkGenerator) + { + _redirectUrl = redirectUrl; + } + + public void OnAuthorization(AuthorizationFilterContext context) + { + if (!IsAuthorized()) + { + if (_redirectToUmbracoLogin) + { + _redirectUrl = _linkGenerator.GetBackOfficeUrl(); + } + + if (!_redirectUrl.IsNullOrWhiteSpace()) + { + context.Result = new RedirectResult(_redirectUrl); + } + else + { + context.Result = new ForbidResult(); + } + } + } + + private bool IsAuthorized() + { + if (Enable == false) + return true; + + 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.UmbracoContext?.Security.ValidateCurrentUser(false, _requireApproval) == ValidateRequestAttempt.Success; + } + catch (Exception) + { + return false; + } + } + } +} diff --git a/src/Umbraco.Web.BackOffice/Routing/BackOfficeAreaRoutes.cs b/src/Umbraco.Web.BackOffice/Routing/BackOfficeAreaRoutes.cs index 9acb8a6e36..d5dd6f00f0 100644 --- a/src/Umbraco.Web.BackOffice/Routing/BackOfficeAreaRoutes.cs +++ b/src/Umbraco.Web.BackOffice/Routing/BackOfficeAreaRoutes.cs @@ -13,27 +13,58 @@ namespace Umbraco.Web.BackOffice.Routing { private readonly IGlobalSettings _globalSettings; private readonly IHostingEnvironment _hostingEnvironment; + private readonly IRuntimeState _runtimeState; + private readonly string _umbracoAreaPathSegment; - public BackOfficeAreaRoutes(IGlobalSettings globalSettings, IHostingEnvironment hostingEnvironment) + public BackOfficeAreaRoutes(IGlobalSettings globalSettings, IHostingEnvironment hostingEnvironment, IRuntimeState runtimeState) { _globalSettings = globalSettings; _hostingEnvironment = hostingEnvironment; + _runtimeState = runtimeState; + _umbracoAreaPathSegment = _globalSettings.GetUmbracoMvcArea(_hostingEnvironment); } public void CreateRoutes(IEndpointRouteBuilder endpoints) { - var umbracoPath = _globalSettings.GetUmbracoMvcArea(_hostingEnvironment); + switch (_runtimeState.Level) + { + case RuntimeLevel.Install: + // a new install so we don't route the back office + break; + case RuntimeLevel.Upgrade: + // for upgrades we only need to route the back office and auth controllers + MapMinimalBackOffice(endpoints); + break; + case RuntimeLevel.Run: - // TODO: We need to auto-route "Umbraco Api Controllers" for the back office + MapMinimalBackOffice(endpoints); - // TODO: We will also need to detect runtime state here and redirect to the installer, - // Potentially switch this to dynamic routing so we can essentially disable/overwrite the back office routes to redirect to install - // when required, example https://www.strathweb.com/2019/08/dynamic-controller-routing-in-asp-net-core-3-0/ + endpoints.MapAreaControllerRoute( + "Umbraco_preview", // TODO: Same name as before but we should change these so they have a convention + Constants.Web.Mvc.BackOfficeArea, + $"{_umbracoAreaPathSegment}/preview/{{Action}}/{{editor?}}", + new { controller = ControllerExtensions.GetControllerName(), action = "Index" }); + AutoRouteBackOfficeControllers(endpoints); + + break; + case RuntimeLevel.BootFailed: + case RuntimeLevel.Unknown: + case RuntimeLevel.Boot: + break; + } + } + + /// + /// Map the minimal routes required to load the back office login and auth + /// + /// + private void MapMinimalBackOffice(IEndpointRouteBuilder endpoints) + { endpoints.MapAreaControllerRoute( "Umbraco_back_office", // TODO: Same name as before but we should change these so they have a convention Constants.Web.Mvc.BackOfficeArea, - $"{umbracoPath}/{{Action}}/{{id?}}", + $"{_umbracoAreaPathSegment}/{{Action}}/{{id?}}", new { controller = ControllerExtensions.GetControllerName(), action = "Default" }, // Limit the action/id to only allow characters - this is so this route doesn't hog all other // routes like: /umbraco/channels/word.aspx, etc... @@ -44,12 +75,22 @@ namespace Umbraco.Web.BackOffice.Routing id = @"[a-zA-Z]*" }); + var authControllerName = ControllerExtensions.GetControllerName(); endpoints.MapAreaControllerRoute( - "Umbraco_preview", // TODO: Same name as before but we should change these so they have a convention - Constants.Web.Mvc.BackOfficeArea, - $"{umbracoPath}/preview/{{Action}}/{{editor?}}", - // TODO: Change this to use ControllerExtensions.GetControllerName once the PreviewController is moved to Umbraco.Web.BackOffice.Controllers - new { controller = "Preview", action = "Index" }); + $"umbraco-{Constants.Web.Mvc.BackOfficeArea.ToLowerInvariant()}-{authControllerName.ToLowerInvariant()}", + Constants.Web.Mvc.BackOfficeArea, + // TODO: The "BackOffice" path name needs to be a constant - actually all of these routes need to be in a helper so the names are by convention + $"{_umbracoAreaPathSegment}/BackOffice/{authControllerName}/{{Action}}/{{id?}}", + new { controller = authControllerName, action = "Default" }); + + } + + /// + /// Auto-routes all back office controllers + /// + private void AutoRouteBackOfficeControllers(IEndpointRouteBuilder endpoints) + { + } } } diff --git a/src/Umbraco.Web/Editors/BackOfficeController.cs b/src/Umbraco.Web/Editors/BackOfficeController.cs index 7e3638d96a..34a08a37ca 100644 --- a/src/Umbraco.Web/Editors/BackOfficeController.cs +++ b/src/Umbraco.Web/Editors/BackOfficeController.cs @@ -104,9 +104,9 @@ namespace Umbraco.Web.Editors { return await RenderDefaultOrProcessExternalLoginAsync( () => - View(GlobalSettings.GetBackOfficePath(_hostingEnvironment).EnsureEndsWith('/') + "Views/Default.cshtml", new BackOfficeModel(_features, GlobalSettings, _umbracoVersion, _contentSettings, _treeCollection, _httpContextAccessor, _hostingEnvironment, _runtimeSettings, _securitySettings)), + View(GlobalSettings.GetBackOfficePath(_hostingEnvironment).EnsureEndsWith('/') + "Views/Default.cshtml", new BackOfficeModel(_features, GlobalSettings, _umbracoVersion, _contentSettings, _treeCollection, _hostingEnvironment, _runtimeSettings, _securitySettings)), () => - View(GlobalSettings.GetBackOfficePath(_hostingEnvironment).EnsureEndsWith('/') + "Views/Default.cshtml", new BackOfficeModel(_features, GlobalSettings, _umbracoVersion, _contentSettings, _treeCollection, _httpContextAccessor, _hostingEnvironment, _runtimeSettings, _securitySettings)) + View(GlobalSettings.GetBackOfficePath(_hostingEnvironment).EnsureEndsWith('/') + "Views/Default.cshtml", new BackOfficeModel(_features, GlobalSettings, _umbracoVersion, _contentSettings, _treeCollection, _hostingEnvironment, _runtimeSettings, _securitySettings)) ); } @@ -184,7 +184,7 @@ namespace Umbraco.Web.Editors { return await RenderDefaultOrProcessExternalLoginAsync( //The default view to render when there is no external login info or errors - () => View(GlobalSettings.GetBackOfficePath(_hostingEnvironment).EnsureEndsWith('/') + "Views/AuthorizeUpgrade.cshtml", new BackOfficeModel(_features, GlobalSettings, _umbracoVersion, _contentSettings, _treeCollection, _httpContextAccessor, _hostingEnvironment, _runtimeSettings, _securitySettings)), + () => View(GlobalSettings.GetBackOfficePath(_hostingEnvironment).EnsureEndsWith('/') + "Views/AuthorizeUpgrade.cshtml", new BackOfficeModel(_features, GlobalSettings, _umbracoVersion, _contentSettings, _treeCollection, _hostingEnvironment, _runtimeSettings, _securitySettings)), //The ActionResult to perform if external login is successful () => Redirect("/")); } diff --git a/src/Umbraco.Web/HttpCookieExtensions.cs b/src/Umbraco.Web/HttpCookieExtensions.cs index d30827be65..9e780f8740 100644 --- a/src/Umbraco.Web/HttpCookieExtensions.cs +++ b/src/Umbraco.Web/HttpCookieExtensions.cs @@ -97,20 +97,6 @@ namespace Umbraco.Web return null; } - public static string GetPreviewCookieValue(this ICookieManager cookieManager) - { - return cookieManager.GetCookieValue(Constants.Web.PreviewCookieName); - } - /// - /// Does a preview cookie exist ? - /// - /// - /// - public static bool HasPreviewCookie(this ICookieManager cookieManager) - { - return cookieManager.HasCookie(Constants.Web.PreviewCookieName); - } - /// /// Does a preview cookie exist ? /// diff --git a/src/Umbraco.Web/Mvc/BackOfficeArea.cs b/src/Umbraco.Web/Mvc/BackOfficeArea.cs index 37b9f7e44b..156a896bb5 100644 --- a/src/Umbraco.Web/Mvc/BackOfficeArea.cs +++ b/src/Umbraco.Web/Mvc/BackOfficeArea.cs @@ -7,9 +7,7 @@ using Umbraco.Web.Editors; namespace Umbraco.Web.Mvc { - /// - /// An area registration for back office components - /// + // TODO: This has been ported to netcore, can be removed internal class BackOfficeArea : AreaRegistration { private readonly IGlobalSettings _globalSettings; diff --git a/src/Umbraco.Web/Mvc/UmbracoAuthorizeAttribute.cs b/src/Umbraco.Web/Mvc/UmbracoAuthorizeAttribute.cs index cb594d1e7d..dc647a5fe3 100644 --- a/src/Umbraco.Web/Mvc/UmbracoAuthorizeAttribute.cs +++ b/src/Umbraco.Web/Mvc/UmbracoAuthorizeAttribute.cs @@ -7,9 +7,8 @@ using Umbraco.Core.Configuration; namespace Umbraco.Web.Mvc { - /// - /// Ensures authorization is successful for a back office user. - /// + // TODO: This has been migrated to netcore and can be removed when ready + public sealed class UmbracoAuthorizeAttribute : AuthorizeAttribute { // see note in HttpInstallAuthorizeAttribute diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index b7c1e6e0b5..fd20d4ef6e 100755 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -154,7 +154,6 @@ - @@ -237,7 +236,6 @@ - @@ -265,7 +263,6 @@ - diff --git a/src/Umbraco.Web/WebApi/UmbracoAuthorizeAttribute.cs b/src/Umbraco.Web/WebApi/UmbracoAuthorizeAttribute.cs index 7566a4d78f..000c4860c6 100644 --- a/src/Umbraco.Web/WebApi/UmbracoAuthorizeAttribute.cs +++ b/src/Umbraco.Web/WebApi/UmbracoAuthorizeAttribute.cs @@ -7,9 +7,8 @@ using Umbraco.Web.Security; namespace Umbraco.Web.WebApi { - /// - /// Ensures authorization is successful for a back office user. - /// + // TODO: This has been migrated to netcore and can be removed when ready + public sealed class UmbracoAuthorizeAttribute : AuthorizeAttribute { private readonly bool _requireApproval;