Merge remote-tracking branch 'origin/v10/dev' into v10/feature/nullable-reference-types-in-Umbraco-Core
# Conflicts: # build/build.ps1 # src/Umbraco.Core/Configuration/ConfigConnectionString.cs # src/Umbraco.Core/Configuration/Models/ConnectionStrings.cs # src/Umbraco.Core/Install/InstallSteps/TelemetryIdentifierStep.cs # src/Umbraco.Core/Models/ContentType.cs # src/Umbraco.Infrastructure/Migrations/Install/DatabaseBuilder.cs # tests/Umbraco.Tests.AcceptanceTest/package.json
This commit is contained in:
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Data.Common;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Reflection;
|
||||
using Dazinator.Extensions.FileProviders.GlobPatternFilter;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
@@ -144,10 +145,8 @@ namespace Umbraco.Extensions
|
||||
builder.Services.AddUnique<IHostingEnvironment, AspNetCoreHostingEnvironment>();
|
||||
builder.Services.AddHostedService(factory => factory.GetRequiredService<IRuntime>());
|
||||
|
||||
// Add supported databases
|
||||
builder.AddUmbracoSqlServerSupport();
|
||||
builder.AddUmbracoSqlCeSupport();
|
||||
builder.Services.AddSingleton<DatabaseSchemaCreatorFactory>();
|
||||
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IDatabaseProviderMetadata, CustomConnectionStringDatabaseProviderMetadata>());
|
||||
|
||||
// Must be added here because DbProviderFactories is netstandard 2.1 so cannot exist in Infra for now
|
||||
builder.Services.AddSingleton<IDbProviderFactoryCreator>(factory => new DbProviderFactoryCreator(
|
||||
@@ -155,7 +154,8 @@ namespace Umbraco.Extensions
|
||||
factory.GetServices<ISqlSyntaxProvider>(),
|
||||
factory.GetServices<IBulkSqlInsertProvider>(),
|
||||
factory.GetServices<IDatabaseCreator>(),
|
||||
factory.GetServices<IProviderSpecificMapperFactory>()
|
||||
factory.GetServices<IProviderSpecificMapperFactory>(),
|
||||
factory.GetServices<IProviderSpecificInterceptor>()
|
||||
));
|
||||
|
||||
builder.AddCoreInitialServices();
|
||||
@@ -191,6 +191,11 @@ namespace Umbraco.Extensions
|
||||
private static IUmbracoBuilder AddHttpClients(this IUmbracoBuilder builder)
|
||||
{
|
||||
builder.Services.AddHttpClient();
|
||||
builder.Services.AddHttpClient(Constants.HttpClients.IgnoreCertificateErrors)
|
||||
.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler
|
||||
{
|
||||
ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator
|
||||
});
|
||||
return builder;
|
||||
}
|
||||
|
||||
@@ -382,66 +387,6 @@ namespace Umbraco.Extensions
|
||||
return builder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds SqlCe support for Umbraco
|
||||
/// </summary>
|
||||
private static IUmbracoBuilder AddUmbracoSqlCeSupport(this IUmbracoBuilder builder)
|
||||
{
|
||||
try
|
||||
{
|
||||
var binFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||
if (binFolder != null)
|
||||
{
|
||||
var dllPath = Path.Combine(binFolder, "Umbraco.Persistence.SqlCe.dll");
|
||||
var umbSqlCeAssembly = Assembly.LoadFrom(dllPath);
|
||||
|
||||
Type sqlCeSyntaxProviderType = umbSqlCeAssembly.GetType("Umbraco.Cms.Persistence.SqlCe.SqlCeSyntaxProvider");
|
||||
Type sqlCeBulkSqlInsertProviderType = umbSqlCeAssembly.GetType("Umbraco.Cms.Persistence.SqlCe.SqlCeBulkSqlInsertProvider");
|
||||
Type sqlCeDatabaseCreatorType = umbSqlCeAssembly.GetType("Umbraco.Cms.Persistence.SqlCe.SqlCeDatabaseCreator");
|
||||
Type sqlCeSpecificMapperFactory = umbSqlCeAssembly.GetType("Umbraco.Cms.Persistence.SqlCe.SqlCeSpecificMapperFactory");
|
||||
|
||||
if (!(sqlCeSyntaxProviderType is null
|
||||
|| sqlCeBulkSqlInsertProviderType is null
|
||||
|| sqlCeDatabaseCreatorType is null
|
||||
|| sqlCeSpecificMapperFactory is null))
|
||||
{
|
||||
builder.Services.AddSingleton(typeof(ISqlSyntaxProvider), sqlCeSyntaxProviderType);
|
||||
builder.Services.AddSingleton(typeof(IBulkSqlInsertProvider), sqlCeBulkSqlInsertProviderType);
|
||||
builder.Services.AddSingleton(typeof(IDatabaseCreator), sqlCeDatabaseCreatorType);
|
||||
builder.Services.AddSingleton(typeof(IProviderSpecificMapperFactory), sqlCeSpecificMapperFactory);
|
||||
}
|
||||
|
||||
var sqlCeAssembly = Assembly.LoadFrom(Path.Combine(binFolder, "System.Data.SqlServerCe.dll"));
|
||||
|
||||
var sqlCe = sqlCeAssembly.GetType("System.Data.SqlServerCe.SqlCeProviderFactory");
|
||||
if (!(sqlCe is null))
|
||||
{
|
||||
DbProviderFactories.RegisterFactory(Cms.Core.Constants.DbProviderNames.SqlCe, sqlCe);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Ignore if SqlCE is not available
|
||||
}
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds Sql Server support for Umbraco
|
||||
/// </summary>
|
||||
private static IUmbracoBuilder AddUmbracoSqlServerSupport(this IUmbracoBuilder builder)
|
||||
{
|
||||
DbProviderFactories.RegisterFactory(Cms.Core.Constants.DbProviderNames.SqlServer, SqlClientFactory.Instance);
|
||||
|
||||
builder.Services.AddSingleton<ISqlSyntaxProvider, SqlServerSyntaxProvider>();
|
||||
builder.Services.AddSingleton<IBulkSqlInsertProvider, SqlServerBulkSqlInsertProvider>();
|
||||
builder.Services.AddSingleton<IDatabaseCreator, SqlServerDatabaseCreator>();
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
private static IProfiler GetWebProfiler(IConfiguration config)
|
||||
{
|
||||
var isDebug = config.GetValue<bool>($"{Cms.Core.Constants.Configuration.ConfigHosting}:Debug");
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Umbraco.Extensions
|
||||
/// <returns></returns>
|
||||
public static string GetControllerName(Type controllerType)
|
||||
{
|
||||
if (!controllerType.Name.EndsWith("Controller"))
|
||||
if (!controllerType.Name.EndsWith("Controller") && !controllerType.Name.EndsWith("Controller`1"))
|
||||
{
|
||||
throw new InvalidOperationException("The controller type " + controllerType + " does not follow conventions, MVC Controller class names must be suffixed with the term 'Controller'");
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Umbraco.Extensions
|
||||
public static class FriendlyUrlHelperExtensions
|
||||
{
|
||||
|
||||
private static IUmbracoContext UmbracoContext { get; } =
|
||||
private static IUmbracoContext UmbracoContext =>
|
||||
StaticServiceProvider.Instance.GetRequiredService<IUmbracoContextAccessor>().GetRequiredUmbracoContext();
|
||||
|
||||
private static IDataProtectionProvider DataProtectionProvider { get; } =
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http.Extensions;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Primitives;
|
||||
using Umbraco.Cms.Core.Configuration.Models;
|
||||
using Umbraco.Cms.Core.Routing;
|
||||
|
||||
@@ -136,5 +137,25 @@ namespace Umbraco.Extensions
|
||||
|
||||
return new Uri(routingSettings.UmbracoApplicationUrl);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Umbraco `ufprt` encrypted string from the current request
|
||||
/// </summary>
|
||||
/// <param name="request">The current request</param>
|
||||
/// <returns>The extracted `ufprt` token.</returns>
|
||||
public static string GetUfprt(this HttpRequest request)
|
||||
{
|
||||
if (request.HasFormContentType && request.Form.TryGetValue("ufprt", out StringValues formVal) && formVal != StringValues.Empty)
|
||||
{
|
||||
return formVal.ToString();
|
||||
}
|
||||
|
||||
if (request.Query.TryGetValue("ufprt", out StringValues queryVal) && queryVal != StringValues.Empty)
|
||||
{
|
||||
return queryVal.ToString();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace Umbraco.Cms.Web.Common.Filters
|
||||
{
|
||||
if (context == null) throw new ArgumentNullException(nameof(context));
|
||||
|
||||
var ufprt = context.HttpContext.Request.Form["ufprt"];
|
||||
var ufprt = context.HttpContext.Request.GetUfprt();
|
||||
|
||||
if (context.ActionDescriptor is ControllerActionDescriptor controllerActionDescriptor)
|
||||
{
|
||||
|
||||
@@ -195,7 +195,8 @@ namespace Umbraco.Cms.Web.Common.Routing
|
||||
var routeValues = new RouteValueDictionary();
|
||||
|
||||
// To get the matchedEndpoint of the provide url
|
||||
RouteEndpoint matchedEndpoint = routeEndpoints
|
||||
RouteEndpoint matchedEndpoint = routeEndpoints?
|
||||
.Where(e => e.RoutePattern.RawText != null)
|
||||
.Where(e => new TemplateMatcher(
|
||||
TemplateParser.Parse(e.RoutePattern.RawText),
|
||||
new RouteValueDictionary())
|
||||
|
||||
@@ -30,7 +30,8 @@ namespace Umbraco.Cms.Web.Common.Security
|
||||
ClaimsIdentity newIdentity = refreshingPrincipal.NewPrincipal.Identities.First();
|
||||
ClaimsIdentity currentIdentity = refreshingPrincipal.CurrentPrincipal.Identities.First();
|
||||
|
||||
newIdentity.MergeClaimsFromCookieIdentity(currentIdentity);
|
||||
// Since this is refreshing an existing principal, we want to merge all claims.
|
||||
newIdentity.MergeAllClaims(currentIdentity);
|
||||
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
|
||||
@@ -76,8 +76,6 @@ namespace Umbraco.Cms.Web.Common.Security
|
||||
}
|
||||
else
|
||||
{
|
||||
string username;
|
||||
|
||||
MemberIdentityUser currentMember = await GetCurrentMemberAsync();
|
||||
|
||||
// If a member could not be resolved from the provider, we are clearly not authorized and can break right here
|
||||
@@ -87,7 +85,6 @@ namespace Umbraco.Cms.Web.Common.Security
|
||||
}
|
||||
|
||||
int memberId = int.Parse(currentMember.Id, CultureInfo.InvariantCulture);
|
||||
username = currentMember.UserName;
|
||||
|
||||
// If types defined, check member is of one of those types
|
||||
IList<string> allowTypesList = allowTypes as IList<string> ?? allowTypes.ToList();
|
||||
@@ -98,10 +95,11 @@ namespace Umbraco.Cms.Web.Common.Security
|
||||
}
|
||||
|
||||
// If specific members defined, check member is of one of those
|
||||
if (allowAction && allowMembers.Any())
|
||||
var allowMembersList = allowMembers.ToList();
|
||||
if (allowAction && allowMembersList.Any())
|
||||
{
|
||||
// Allow only if member's Id is in the list
|
||||
allowAction = allowMembers.Contains(memberId);
|
||||
allowAction = allowMembersList.Contains(memberId);
|
||||
}
|
||||
|
||||
// If groups defined, check member is of one of those groups
|
||||
@@ -121,7 +119,7 @@ namespace Umbraco.Cms.Web.Common.Security
|
||||
public bool IsLoggedIn()
|
||||
{
|
||||
HttpContext httpContext = _httpContextAccessor.HttpContext;
|
||||
return httpContext?.User != null && httpContext.User.Identity.IsAuthenticated;
|
||||
return httpContext?.User.Identity?.IsAuthenticated ?? false;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
Reference in New Issue
Block a user