Merge remote-tracking branch 'origin/v12/dev' into v13/dev

# Conflicts:
#	src/Umbraco.Infrastructure/CompatibilitySuppressions.xml
#	src/Umbraco.Infrastructure/Migrations/MigrationPlanExecutor.cs
#	src/Umbraco.Infrastructure/Migrations/UnscopedMigrationBase.cs
#	tests/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Migrations/MigrationPlanTests.cs
remove double request to get init status
This commit is contained in:
Bjarke Berg
2023-04-14 10:23:04 +02:00
23 changed files with 371 additions and 56 deletions

View File

@@ -104,23 +104,8 @@ stages:
echo "##vso[task.setvariable variable=majorVersion;isOutput=true]$major"
displayName: Set major version
name: determineMajorVersion
- task: PowerShell@2
displayName: Prepare nupkg
inputs:
targetType: inline
script: |
$umbracoVersion = "$(Build.BuildNumber)" -replace "\+",".g"
$templatePaths = Get-ChildItem 'templates/**/.template.config/template.json'
foreach ($templatePath in $templatePaths) {
$a = Get-Content $templatePath -Raw | ConvertFrom-Json
if ($a.symbols -and $a.symbols.UmbracoVersion) {
$a.symbols.UmbracoVersion.defaultValue = $umbracoVersion
$a | ConvertTo-Json -Depth 32 | Set-Content $templatePath
}
}
dotnet pack $(solution) --configuration $(buildConfiguration) --no-build --property:PackageOutputPath=$(Build.ArtifactStagingDirectory)/nupkg
- script: dotnet pack $(solution) --configuration $(buildConfiguration) --no-build --property:PackageOutputPath=$(Build.ArtifactStagingDirectory)/nupkg
displayName: Run dotnet pack
- script: |
sha="$(Build.SourceVersion)"
sha=${sha:0:7}

View File

@@ -441,6 +441,40 @@
}
}
},
"/umbraco/management/api/v1/data-type/{id}/is-used": {
"get": {
"tags": [
"Data Type"
],
"operationId": "GetDataTypeByIdIsUsed",
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "string",
"format": "uuid"
}
}
],
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"type": "boolean"
}
}
}
},
"404": {
"description": "Not Found"
}
}
}
},
"/umbraco/management/api/v1/data-type/{id}/move": {
"post": {
"tags": [
@@ -4810,6 +4844,53 @@
}
}
},
"/umbraco/management/api/v1/property-type/is-used": {
"get": {
"tags": [
"Property Type"
],
"operationId": "GetPropertyTypeIsUsed",
"parameters": [
{
"name": "contentTypeId",
"in": "query",
"schema": {
"type": "string",
"format": "uuid"
}
},
{
"name": "propertyAlias",
"in": "query",
"schema": {
"type": "string"
}
}
],
"responses": {
"400": {
"description": "Bad Request",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProblemDetailsModel"
}
}
}
},
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PagedBooleanModel"
}
}
}
}
}
}
},
"/umbraco/management/api/v1/published-cache/collect": {
"post": {
"tags": [
@@ -10124,6 +10205,26 @@
},
"additionalProperties": false
},
"PagedBooleanModel": {
"required": [
"items",
"total"
],
"type": "object",
"properties": {
"total": {
"type": "integer",
"format": "int64"
},
"items": {
"type": "array",
"items": {
"type": "boolean"
}
}
},
"additionalProperties": false
},
"PagedContentTreeItemResponseModel": {
"required": [
"items",

View File

@@ -50,10 +50,10 @@
</Target>
<!-- Create and pack empty file to add TFM dependency -->
<Target Name="PackTargetFrameworkFile" BeforeTargets="Build">
<Target Name="GetTargetFrameworkPackageFiles" BeforeTargets="GenerateNuspec">
<WriteLinesToFile File="$(IntermediateOutputPath)_._" />
<ItemGroup>
<None Include="$(IntermediateOutputPath)_._" Pack="true" PackagePath="lib\$(TargetFramework)" />
<_PackageFiles Include="$(IntermediateOutputPath)_._" PackagePath="lib\$(TargetFramework)" />
</ItemGroup>
</Target>
</Project>

View File

@@ -14,10 +14,10 @@
</ItemGroup>
<!-- Create and pack empty file to add TFM dependency -->
<Target Name="PackTargetFrameworkFile" BeforeTargets="Build">
<Target Name="GetTargetFrameworkPackageFiles" BeforeTargets="GenerateNuspec">
<WriteLinesToFile File="$(IntermediateOutputPath)_._" />
<ItemGroup>
<None Include="$(IntermediateOutputPath)_._" Pack="true" PackagePath="lib\$(TargetFramework)" />
<_PackageFiles Include="$(IntermediateOutputPath)_._" PackagePath="lib\$(TargetFramework)" />
</ItemGroup>
</Target>
</Project>

View File

@@ -29,6 +29,7 @@ public sealed class RichTextEditorPastedImages
private readonly IPublishedUrlProvider _publishedUrlProvider;
private readonly IShortStringHelper _shortStringHelper;
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
private readonly string _tempFolderAbsolutePath;
public RichTextEditorPastedImages(
IUmbracoContextAccessor umbracoContextAccessor,
@@ -52,6 +53,9 @@ public sealed class RichTextEditorPastedImages
_mediaUrlGenerators = mediaUrlGenerators;
_shortStringHelper = shortStringHelper;
_publishedUrlProvider = publishedUrlProvider;
_tempFolderAbsolutePath = _hostingEnvironment.MapPathContentRoot(Constants.SystemDirectories.TempImageUploads);
}
/// <summary>
@@ -85,12 +89,14 @@ public sealed class RichTextEditorPastedImages
continue;
}
if (IsValidPath(tmpImgPath) == false)
var absoluteTempImagePath = Path.GetFullPath(_hostingEnvironment.MapPathContentRoot(tmpImgPath));
if (IsValidPath(absoluteTempImagePath) == false)
{
continue;
}
var absoluteTempImagePath = _hostingEnvironment.MapPathContentRoot(tmpImgPath);
var fileName = Path.GetFileName(absoluteTempImagePath);
var safeFileName = fileName.ToSafeFileName(_shortStringHelper);
@@ -191,5 +197,8 @@ public sealed class RichTextEditorPastedImages
return htmlDoc.DocumentNode.OuterHtml;
}
private bool IsValidPath(string imagePath) => imagePath.StartsWith(Constants.SystemDirectories.TempImageUploads);
private bool IsValidPath(string imagePath)
{
return imagePath.StartsWith(_tempFolderAbsolutePath);
}
}

View File

@@ -54,11 +54,20 @@ public class UmbracoMemberAuthorizeFilter : IAsyncAuthorizationFilter
IMemberManager memberManager = context.HttpContext.RequestServices.GetRequiredService<IMemberManager>();
if (!await IsAuthorizedAsync(memberManager))
if (memberManager.IsLoggedIn())
{
if (!await IsAuthorizedAsync(memberManager))
{
context.HttpContext.SetReasonPhrase(
"Resource restricted: the member is not of a permitted type or group.");
context.Result = new ForbidResult();
}
}
else
{
context.HttpContext.SetReasonPhrase(
"Resource restricted: either member is not logged on or is not of a permitted type or group.");
context.Result = new ForbidResult();
"Resource restricted: the member is not logged in.");
context.Result = new UnauthorizedResult();
}
}

View File

@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core.Routing;
@@ -44,6 +45,12 @@ public sealed class ConfigureMemberCookieOptions : IConfigureNamedOptions<Cookie
// When we are signed in with the cookie, assign the principal to the current HttpContext
ctx.HttpContext.SetPrincipalForRequest(ctx.Principal);
return Task.CompletedTask;
},
OnRedirectToAccessDenied = ctx =>
{
ctx.Response.StatusCode = StatusCodes.Status403Forbidden;
return Task.CompletedTask;
},
};

View File

@@ -8,10 +8,12 @@
<NoDefaultExcludes>true</NoDefaultExcludes>
<IncludeContentInPack>true</IncludeContentInPack>
<ContentTargetFolders>.</ContentTargetFolders>
<NoWarn>NU5128</NoWarn>
</PropertyGroup>
<ItemGroup>
<Content Include="UmbracoPackage\**" Exclude="bin;obj" />
<Content Include="UmbracoPackageRcl\**" Exclude="bin;obj" />
<Content Include="UmbracoProject\**" Exclude="bin;obj" />
<Content Include="..\src\Umbraco.Web.UI\Program.cs">
<Link>UmbracoProject\Program.cs</Link>
@@ -42,4 +44,25 @@
<PackagePath>UmbracoProject\wwwroot</PackagePath>
</Content>
</ItemGroup>
<!-- Update template.json files with the default UmbracoVersion value set to the current build version -->
<ItemGroup>
<PackageReference Include="Umbraco.JsonSchema.Extensions" Version="0.3.0" PrivateAssets="all" />
</ItemGroup>
<Target Name="GetUpdatedTemplateJsonPackageFiles" BeforeTargets="GenerateNuspec" AfterTargets="GetBuildVersion;GetUmbracoBuildVersion">
<ItemGroup>
<_TemplateJsonFiles Include="**\.template.config\template.json" Exclude="bin\**;obj\**" />
<_TemplateJsonFiles>
<DestinationFile>$(IntermediateOutputPath)%(RelativeDir)%(Filename)%(Extension)</DestinationFile>
</_TemplateJsonFiles>
</ItemGroup>
<Copy SourceFiles="@(_TemplateJsonFiles)" DestinationFiles="%(DestinationFile)" />
<JsonPathUpdateValue JsonFile="%(_TemplateJsonFiles.DestinationFile)" Path="$.symbols.UmbracoVersion.defaultValue" Value="&quot;$(PackageVersion)&quot;" />
<ItemGroup>
<_PackageFiles Remove="@(_TemplateJsonFiles)" />
<_PackageFiles Include="%(_TemplateJsonFiles.DestinationFile)">
<PackagePath>%(RelativeDir)</PackagePath>
</_PackageFiles>
</ItemGroup>
</Target>
</Project>

View File

@@ -3,11 +3,16 @@
"symbolInfo": {
"Framework": {
"longName": "Framework",
"shortName": "F"
"shortName": "F",
"isHidden": true
},
"UmbracoVersion": {
"longName": "version",
"shortName": "v"
},
"SkipRestore": {
"longName": "no-restore",
"shortName": ""
}
}
}

View File

@@ -41,9 +41,16 @@
"description": "The version of Umbraco.Cms to add as PackageReference.",
"type": "parameter",
"datatype": "string",
"defaultValue": "10.0.0-rc1",
"defaultValue": "*",
"replaces": "UMBRACO_VERSION_FROM_TEMPLATE"
},
"SkipRestore": {
"displayName": "Skip restore",
"description": "If specified, skips the automatic restore of the project on create.",
"type": "parameter",
"datatype": "bool",
"defaultValue": "false"
},
"Namespace": {
"type": "derived",
"valueSource": "name",
@@ -83,5 +90,19 @@
{
"path": "UmbracoPackage.csproj"
}
],
"postActions": [
{
"id": "restore",
"condition": "(!SkipRestore)",
"description": "Restore NuGet packages required by this project.",
"manualInstructions": [
{
"text": "Run 'dotnet restore'"
}
],
"actionId": "210D431B-A78B-4D2F-B762-4ED3E3EA9025",
"continueOnError": true
}
]
}

View File

@@ -0,0 +1,22 @@
{
"$schema": "https://json.schemastore.org/dotnetcli.host.json",
"symbolInfo": {
"Framework": {
"longName": "Framework",
"shortName": "F",
"isHidden": true
},
"UmbracoVersion": {
"longName": "version",
"shortName": ""
},
"SkipRestore": {
"longName": "no-restore",
"shortName": ""
},
"SupportPagesAndViews": {
"longName": "support-pages-and-views",
"shortName": "s"
}
}
}

View File

@@ -0,0 +1,20 @@
{
"$schema": "https://json.schemastore.org/ide.host.json",
"order": 0,
"icon": "../../icon.png",
"description": {
"id": "UmbracoPackageRcl",
"text": "Umbraco Package RCL - An empty Umbraco package/plugin (Razor Class Library)."
},
"symbolInfo": [
{
"id": "UmbracoVersion",
"isVisible": true
},
{
"id": "SupportPagesAndViews",
"isVisible": true,
"persistenceScope": "templateGroup"
}
]
}

View File

@@ -0,0 +1,82 @@
{
"$schema": "https://json.schemastore.org/template.json",
"author": "Umbraco HQ",
"classifications": [
"Web",
"CMS",
"Umbraco",
"Package",
"Plugin",
"Razor Class Library"
],
"name": "Umbraco Package RCL",
"description": "An empty Umbraco package/plugin (Razor Class Library).",
"groupIdentity": "Umbraco.Templates.UmbracoPackageRcl",
"identity": "Umbraco.Templates.UmbracoPackageRcl.CSharp",
"shortName": "umbracopackage-rcl",
"tags": {
"language": "C#",
"type": "project"
},
"sourceName": "UmbracoPackage",
"defaultName": "UmbracoPackage1",
"preferNameDirectory": true,
"symbols": {
"Framework": {
"displayName": "Framework",
"description": "The target framework for the project.",
"type": "parameter",
"datatype": "choice",
"choices": [
{
"displayName": ".NET 7.0",
"description": "Target net7.0",
"choice": "net7.0"
}
],
"defaultValue": "net7.0",
"replaces": "net7.0"
},
"UmbracoVersion": {
"displayName": "Umbraco version",
"description": "The version of Umbraco.Cms to add as PackageReference.",
"type": "parameter",
"datatype": "string",
"defaultValue": "*",
"replaces": "UMBRACO_VERSION_FROM_TEMPLATE"
},
"SkipRestore": {
"displayName": "Skip restore",
"description": "If specified, skips the automatic restore of the project on create.",
"type": "parameter",
"datatype": "bool",
"defaultValue": "false"
},
"SupportPagesAndViews": {
"type": "parameter",
"datatype": "bool",
"defaultValue": "false",
"displayName": "Support pages and views",
"description": "Whether to support adding traditional Razor pages and Views to this library."
}
},
"primaryOutputs": [
{
"path": "UmbracoPackage.csproj"
}
],
"postActions": [
{
"id": "restore",
"condition": "(!SkipRestore)",
"description": "Restore NuGet packages required by this project.",
"manualInstructions": [
{
"text": "Run 'dotnet restore'"
}
],
"actionId": "210D431B-A78B-4D2F-B762-4ED3E3EA9025",
"continueOnError": true
}
]
}

View File

@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<AddRazorSupportForMvc Condition="'$(SupportPagesAndViews)' == 'True'">true</AddRazorSupportForMvc>
<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">UmbracoPackage</RootNamespace>
<StaticWebAssetBasePath>App_Plugins/UmbracoPackage</StaticWebAssetBasePath>
</PropertyGroup>
<PropertyGroup>
<PackageId>UmbracoPackage</PackageId>
<Product>UmbracoPackage</Product>
<Title>UmbracoPackage</Title>
<Description>...</Description>
<PackageTags>umbraco plugin package</PackageTags>
</PropertyGroup>
<ItemGroup Condition="'$(SupportPagesAndViews)' == 'True'">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Umbraco.Cms.Web.Website" Version="UMBRACO_VERSION_FROM_TEMPLATE" />
<PackageReference Include="Umbraco.Cms.Web.BackOffice" Version="UMBRACO_VERSION_FROM_TEMPLATE" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,5 @@
{
"name": "UmbracoPackage",
"version": "",
"allowPackageTelemetry": true
}

View File

@@ -3,7 +3,8 @@
"symbolInfo": {
"Framework": {
"longName": "Framework",
"shortName": "F"
"shortName": "F",
"isHidden": true
},
"UmbracoVersion": {
"longName": "version",
@@ -55,14 +56,15 @@
},
"PackageProjectName": {
"longName": "PackageTestSiteName",
"shortName": "p"
"shortName": "p",
"isHidden": true
}
},
"usageExamples": [
"dotnet new umbraco -n MyNewProject",
"dotnet new umbraco -n MyNewProject --no-restore",
"dotnet new umbraco -n MyNewProject --development-database-type SQLite",
"dotnet new umbraco -n MyNewProject --development-database-type LocalDB",
"dotnet new umbraco -n MyNewProject --friendly-name \"Friendly Admin User\" --email admin@example.com --password password1234 --connection-string \"Server=ConnectionStringHere\""
"dotnet new umbraco --name MyNewProject",
"dotnet new umbraco --name MyNewProject --no-restore",
"dotnet new umbraco --name MyNewProject --development-database-type SQLite",
"dotnet new umbraco --name MyNewProject --development-database-type LocalDB",
"dotnet new umbraco --name MyNewProject --friendly-name \"Administrator\" --email admin@example.com --password 1234567890 --connection-string \"Server=(local);Database=MyNewProject;Trusted_Connection=True;\""
]
}

View File

@@ -13,19 +13,18 @@
},
{
"id": "UseHttpsRedirect",
"isVisible": true
},
{
"id": "SkipRestore",
"isVisible": true
"isVisible": true,
"persistenceScope": "templateGroup"
},
{
"id": "ExcludeGitignore",
"isVisible": true
"isVisible": true,
"persistenceScope": "templateGroup"
},
{
"id": "MinimalGitignore",
"isVisible": true
"isVisible": true,
"persistenceScope": "templateGroup"
},
{
"id": "ConnectionString",
@@ -37,7 +36,8 @@
},
{
"id": "DevelopmentDatabaseType",
"isVisible": true
"isVisible": true,
"persistenceScope": "templateGroup"
},
{
"id": "UnattendedUserName",
@@ -54,10 +54,6 @@
{
"id": "NoNodesViewPath",
"isVisible": true
},
{
"id": "PackageProjectName",
"isVisible": true
}
]
}

View File

@@ -51,7 +51,7 @@
"description": "The version of Umbraco.Cms to add as PackageReference.",
"type": "parameter",
"datatype": "string",
"defaultValue": "10.0.0-rc1",
"defaultValue": "*",
"replaces": "UMBRACO_VERSION_FROM_TEMPLATE"
},
"UseHttpsRedirect": {

View File

@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- https://learn.microsoft.com/en-us/dotnet/fundamentals/package-validation/diagnostic-ids -->
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>

View File

@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- https://learn.microsoft.com/en-us/dotnet/fundamentals/package-validation/diagnostic-ids -->
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>

View File

@@ -74,11 +74,10 @@ public class MigrationPlanTests
var executor = new MigrationPlanExecutor(
scopeProvider,
scopeProvider,
loggerFactory,
migrationBuilder,
databaseFactory,
Mock.Of<IPublishedSnapshotService>(),
distributedCache);
loggerFactory,
migrationBuilder,
databaseFactory,
Mock.Of<IPublishedSnapshotService>(), distributedCache);
var plan = new MigrationPlan("default")
.From(string.Empty)

View File

@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "11.3.0-rc",
"version": "13.0.0-rc",
"assemblyVersion": {
"precision": "build"
},