From 2fa4149b62ad23055ef4624369d4f2e8fa74ea53 Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Thu, 27 Jun 2024 10:47:41 +0200 Subject: [PATCH 1/4] Use the configured backoffice url to initialize openiddict if it is available and just fallback to the one from the first request. (#16660) Fixes https://github.com/umbraco/Umbraco-CMS/issues/16179 --- ...ceAuthorizationInitializationMiddleware.cs | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Cms.Api.Management/Middleware/BackOfficeAuthorizationInitializationMiddleware.cs b/src/Umbraco.Cms.Api.Management/Middleware/BackOfficeAuthorizationInitializationMiddleware.cs index c9179215df..4da821337d 100644 --- a/src/Umbraco.Cms.Api.Management/Middleware/BackOfficeAuthorizationInitializationMiddleware.cs +++ b/src/Umbraco.Cms.Api.Management/Middleware/BackOfficeAuthorizationInitializationMiddleware.cs @@ -1,10 +1,15 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Extensions; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; using Umbraco.Cms.Core; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.DependencyInjection; +using Umbraco.Cms.Core.Hosting; using Umbraco.Cms.Core.Routing; using Umbraco.Cms.Core.Services; using Umbraco.Cms.Infrastructure.Security; +using Umbraco.Extensions; namespace Umbraco.Cms.Api.Management.Middleware; @@ -16,15 +21,40 @@ public class BackOfficeAuthorizationInitializationMiddleware : IMiddleware private readonly UmbracoRequestPaths _umbracoRequestPaths; private readonly IServiceProvider _serviceProvider; private readonly IRuntimeState _runtimeState; + private readonly IOptions _globalSettings; + private readonly IOptions _webRoutingSettings; + private readonly IHostingEnvironment _hostingEnvironment; + [Obsolete("Use the non-obsolete constructor. This will be removed in Umbraco 16.")] public BackOfficeAuthorizationInitializationMiddleware( UmbracoRequestPaths umbracoRequestPaths, IServiceProvider serviceProvider, IRuntimeState runtimeState) + : this( + umbracoRequestPaths, + serviceProvider, + runtimeState, + StaticServiceProvider.Instance.GetRequiredService>(), + StaticServiceProvider.Instance.GetRequiredService>(), + StaticServiceProvider.Instance.GetRequiredService() + ) + { + } + + public BackOfficeAuthorizationInitializationMiddleware( + UmbracoRequestPaths umbracoRequestPaths, + IServiceProvider serviceProvider, + IRuntimeState runtimeState, + IOptions globalSettings, + IOptions webRoutingSettings, + IHostingEnvironment hostingEnvironment) { _umbracoRequestPaths = umbracoRequestPaths; _serviceProvider = serviceProvider; _runtimeState = runtimeState; + _globalSettings = globalSettings; + _webRoutingSettings = webRoutingSettings; + _hostingEnvironment = hostingEnvironment; } public async Task InvokeAsync(HttpContext context, RequestDelegate next) @@ -47,6 +77,7 @@ public class BackOfficeAuthorizationInitializationMiddleware : IMiddleware return; } + if (_umbracoRequestPaths.IsBackOfficeRequest(context.Request.Path) == false) { return; @@ -55,9 +86,13 @@ public class BackOfficeAuthorizationInitializationMiddleware : IMiddleware await _firstBackOfficeRequestLocker.WaitAsync(); if (_firstBackOfficeRequest == false) { + Uri? backOfficeUrl = string.IsNullOrWhiteSpace(_webRoutingSettings.Value.UmbracoApplicationUrl) is false + ? new Uri($"{_webRoutingSettings.Value.UmbracoApplicationUrl.TrimEnd('/')}{_globalSettings.Value.GetBackOfficePath(_hostingEnvironment).EnsureStartsWith('/')}") + : null; + using IServiceScope scope = _serviceProvider.CreateScope(); IBackOfficeApplicationManager backOfficeApplicationManager = scope.ServiceProvider.GetRequiredService(); - await backOfficeApplicationManager.EnsureBackOfficeApplicationAsync(new Uri(context.Request.GetDisplayUrl())); + await backOfficeApplicationManager.EnsureBackOfficeApplicationAsync(backOfficeUrl ?? new Uri(context.Request.GetDisplayUrl())); _firstBackOfficeRequest = true; } From 921598b6677867f468bc9296cb44754399f20184 Mon Sep 17 00:00:00 2001 From: Sven Geusens Date: Fri, 28 Jun 2024 09:28:55 +0200 Subject: [PATCH 2/4] Fixed toolbar not showing for seeded,untouched and then migrated RTE datatypes (#16665) Moved 14.1 migrations into their own namespace Co-authored-by: Sven Geusens (cherry picked from commit d170193a95a6da9f9e01e7d9831e4e8688f445be) --- .../Migrations/Upgrade/UmbracoPlan.cs | 5 ++- .../MigrateOldRichTextSeedConfiguration.cs | 38 +++++++++++++++++++ .../MigrateRichTextConfiguration.cs | 2 +- 3 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 src/Umbraco.Infrastructure/Migrations/Upgrade/V_14_1_0/MigrateOldRichTextSeedConfiguration.cs rename src/Umbraco.Infrastructure/Migrations/Upgrade/{V_14_0_0 => V_14_1_0}/MigrateRichTextConfiguration.cs (93%) diff --git a/src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs b/src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs index 91ca3b4d58..8502e4c529 100644 --- a/src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs +++ b/src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs @@ -84,6 +84,9 @@ public class UmbracoPlan : MigrationPlan // we need to re-run this migration, as it was flawed for V14 RC3 (the migration can run twice without any issues) To("{6FB5CA9E-C823-473B-A14C-FE760D75943C}"); To("{827360CA-0855-42A5-8F86-A51F168CB559}"); - To("{FEF2DAF4-5408-4636-BB0E-B8798DF8F095}"); + + // To 14.1.0 + To("{FEF2DAF4-5408-4636-BB0E-B8798DF8F095}"); + To("{A385C5DF-48DC-46B4-A742-D5BB846483BC}"); } } diff --git a/src/Umbraco.Infrastructure/Migrations/Upgrade/V_14_1_0/MigrateOldRichTextSeedConfiguration.cs b/src/Umbraco.Infrastructure/Migrations/Upgrade/V_14_1_0/MigrateOldRichTextSeedConfiguration.cs new file mode 100644 index 0000000000..765fba03d1 --- /dev/null +++ b/src/Umbraco.Infrastructure/Migrations/Upgrade/V_14_1_0/MigrateOldRichTextSeedConfiguration.cs @@ -0,0 +1,38 @@ +using NPoco; +using Umbraco.Cms.Core; +using Umbraco.Cms.Infrastructure.Persistence; +using Umbraco.Cms.Infrastructure.Persistence.Dtos; +using Umbraco.Extensions; + +namespace Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_14_1_0; + +public class MigrateOldRichTextSeedConfiguration : MigrationBase +{ + private const string OldSeedValue = + "{\"value\":\",code,undo,redo,cut,copy,mcepasteword,stylepicker,bold,italic,bullist,numlist,outdent,indent,mcelink,unlink,mceinsertanchor,mceimage,umbracomacro,mceinserttable,umbracoembed,mcecharmap,|1|1,2,3,|0|500,400|1049,|true|\"}"; + + private const string NewDefaultValue = + "{\"toolbar\":[\"styles\",\"bold\",\"italic\",\"alignleft\",\"aligncenter\",\"alignright\",\"bullist\",\"numlist\",\"outdent\",\"indent\",\"sourcecode\",\"link\",\"umbmediapicker\",\"umbembeddialog\"],\"mode\":\"Classic\",\"maxImageSize\":500}"; + public MigrateOldRichTextSeedConfiguration(IMigrationContext context) : base(context) + { + } + + protected override void Migrate() + { + Sql sql = Sql() + .Select() + .From() + .Where(x => + x.EditorAlias.Equals(Constants.PropertyEditors.Aliases.RichText) + && x.Configuration == OldSeedValue); + + List dataTypeDtos = Database.Fetch(sql); + + foreach (DataTypeDto dataTypeDto in dataTypeDtos) + { + // Update the configuration + dataTypeDto.Configuration = NewDefaultValue; + Database.Update(dataTypeDto); + } + } +} diff --git a/src/Umbraco.Infrastructure/Migrations/Upgrade/V_14_0_0/MigrateRichTextConfiguration.cs b/src/Umbraco.Infrastructure/Migrations/Upgrade/V_14_1_0/MigrateRichTextConfiguration.cs similarity index 93% rename from src/Umbraco.Infrastructure/Migrations/Upgrade/V_14_0_0/MigrateRichTextConfiguration.cs rename to src/Umbraco.Infrastructure/Migrations/Upgrade/V_14_1_0/MigrateRichTextConfiguration.cs index 950259f575..bca328eb3f 100644 --- a/src/Umbraco.Infrastructure/Migrations/Upgrade/V_14_0_0/MigrateRichTextConfiguration.cs +++ b/src/Umbraco.Infrastructure/Migrations/Upgrade/V_14_1_0/MigrateRichTextConfiguration.cs @@ -4,7 +4,7 @@ using Umbraco.Cms.Infrastructure.Persistence; using Umbraco.Cms.Infrastructure.Persistence.Dtos; using Umbraco.Extensions; -namespace Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_14_0_0; +namespace Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_14_1_0; public class MigrateRichTextConfiguration : MigrationBase { From 2010a241fe33da55c4279ad0f9a39836391813f3 Mon Sep 17 00:00:00 2001 From: Zeegaan Date: Fri, 28 Jun 2024 09:30:06 +0200 Subject: [PATCH 3/4] Bumb version --- version.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.json b/version.json index cf30f7b7d2..31fd8e32c7 100644 --- a/version.json +++ b/version.json @@ -1,6 +1,6 @@ { "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json", - "version": "14.1.0-rc", + "version": "14.1.0-rc2", "assemblyVersion": { "precision": "build" }, From 2185be1b0323f4f0b6de5ad4f1c15a92212fabd3 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Fri, 28 Jun 2024 15:26:28 +0200 Subject: [PATCH 4/4] update backoffice submodule --- src/Umbraco.Web.UI.Client | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI.Client b/src/Umbraco.Web.UI.Client index b316ce3b52..144378a4cb 160000 --- a/src/Umbraco.Web.UI.Client +++ b/src/Umbraco.Web.UI.Client @@ -1 +1 @@ -Subproject commit b316ce3b5276d0b08d297df3c46a27d83ffabedd +Subproject commit 144378a4cb16be8499b38db8e217b1d24050db75