2020-08-21 14:52:47 +01:00
|
|
|
using System.Linq;
|
2020-03-25 15:06:22 +11:00
|
|
|
using Microsoft.AspNetCore.Http;
|
2020-10-27 10:53:01 +00:00
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
2020-08-21 14:52:47 +01:00
|
|
|
using Microsoft.Extensions.Options;
|
2020-03-25 15:06:22 +11:00
|
|
|
using Umbraco.Core;
|
|
|
|
|
using Umbraco.Core.Composing;
|
2020-08-21 14:52:47 +01:00
|
|
|
using Umbraco.Core.Configuration.Models;
|
|
|
|
|
using Umbraco.Core.Diagnostics;
|
2020-03-25 15:06:22 +11:00
|
|
|
using Umbraco.Core.Hosting;
|
2020-08-21 14:52:47 +01:00
|
|
|
using Umbraco.Core.Logging;
|
2020-03-25 15:06:22 +11:00
|
|
|
using Umbraco.Core.Runtime;
|
2020-03-30 21:27:35 +02:00
|
|
|
using Umbraco.Core.Security;
|
2020-09-22 12:54:51 +02:00
|
|
|
using Umbraco.Core.Services;
|
2020-08-21 14:52:47 +01:00
|
|
|
using Umbraco.Extensions;
|
|
|
|
|
using Umbraco.Net;
|
2020-03-26 06:59:58 +01:00
|
|
|
using Umbraco.Web.Common.AspNetCore;
|
2020-08-21 14:52:47 +01:00
|
|
|
using Umbraco.Web.Common.Controllers;
|
2020-04-20 12:20:47 +02:00
|
|
|
using Umbraco.Web.Common.Formatters;
|
2020-08-21 14:52:47 +01:00
|
|
|
using Umbraco.Web.Common.Install;
|
2020-03-27 11:39:17 +01:00
|
|
|
using Umbraco.Web.Common.Lifetime;
|
2020-04-20 12:20:47 +02:00
|
|
|
using Umbraco.Web.Common.Macros;
|
2020-05-14 22:14:00 +10:00
|
|
|
using Umbraco.Web.Common.Middleware;
|
|
|
|
|
using Umbraco.Web.Common.ModelBinding;
|
2020-08-21 14:52:47 +01:00
|
|
|
using Umbraco.Web.Common.Profiler;
|
2020-06-04 12:53:08 +02:00
|
|
|
using Umbraco.Web.Common.Routing;
|
2020-06-09 07:49:26 +02:00
|
|
|
using Umbraco.Web.Common.Security;
|
2020-08-21 14:52:47 +01:00
|
|
|
using Umbraco.Web.Common.Templates;
|
|
|
|
|
using Umbraco.Web.Composing.CompositionExtensions;
|
|
|
|
|
using Umbraco.Web.Macros;
|
2020-06-03 17:17:30 +02:00
|
|
|
using Umbraco.Web.Security;
|
2020-06-04 12:53:08 +02:00
|
|
|
using Umbraco.Web.Templates;
|
2020-03-25 15:06:22 +11:00
|
|
|
|
2020-03-27 11:39:17 +01:00
|
|
|
namespace Umbraco.Web.Common.Runtime
|
2020-03-25 15:06:22 +11:00
|
|
|
{
|
2020-05-19 14:51:05 +10:00
|
|
|
|
2020-03-25 15:06:22 +11:00
|
|
|
/// <summary>
|
|
|
|
|
/// Adds/replaces AspNetCore specific services
|
|
|
|
|
/// </summary>
|
|
|
|
|
[ComposeBefore(typeof(ICoreComposer))]
|
|
|
|
|
[ComposeAfter(typeof(CoreInitialComposer))]
|
2020-03-27 11:39:17 +01:00
|
|
|
public class AspNetCoreComposer : ComponentComposer<AspNetCoreComponent>, IComposer
|
2020-03-25 15:06:22 +11:00
|
|
|
{
|
2020-10-07 16:56:48 +11:00
|
|
|
public override void Compose(Composition composition)
|
2020-03-25 15:06:22 +11:00
|
|
|
{
|
2020-03-27 11:39:17 +01:00
|
|
|
base.Compose(composition);
|
|
|
|
|
|
2020-03-25 15:06:22 +11:00
|
|
|
// AspNetCore specific services
|
|
|
|
|
composition.RegisterUnique<IHttpContextAccessor, HttpContextAccessor>();
|
2020-04-20 12:20:47 +02:00
|
|
|
composition.RegisterUnique<IRequestAccessor, AspNetCoreRequestAccessor>();
|
2020-03-25 15:06:22 +11:00
|
|
|
|
|
|
|
|
// Our own netcore implementations
|
2020-04-20 12:20:47 +02:00
|
|
|
composition.RegisterMultipleUnique<IUmbracoApplicationLifetimeManager, IUmbracoApplicationLifetime, AspNetCoreUmbracoApplicationLifetime>();
|
2020-03-30 07:14:22 +02:00
|
|
|
|
2020-03-26 15:39:20 +11:00
|
|
|
composition.RegisterUnique<IApplicationShutdownRegistry, AspNetCoreApplicationShutdownRegistry>();
|
2020-03-27 11:39:17 +01:00
|
|
|
|
|
|
|
|
// The umbraco request lifetime
|
2020-04-01 20:00:27 +02:00
|
|
|
composition.RegisterMultipleUnique<IUmbracoRequestLifetime, IUmbracoRequestLifetimeManager, UmbracoRequestLifetime>();
|
2020-03-31 15:36:25 +02:00
|
|
|
|
2020-04-01 15:50:46 +02:00
|
|
|
//Password hasher
|
|
|
|
|
composition.RegisterUnique<IPasswordHasher, AspNetCorePasswordHasher>();
|
2020-03-30 21:27:35 +02:00
|
|
|
|
|
|
|
|
|
2020-04-01 20:00:27 +02:00
|
|
|
composition.RegisterUnique<ICookieManager, AspNetCoreCookieManager>();
|
2020-10-27 10:53:01 +00:00
|
|
|
composition.Services.AddTransient<IIpResolver, AspNetCoreIpResolver>();
|
2020-04-20 12:20:47 +02:00
|
|
|
composition.RegisterUnique<IUserAgentProvider, AspNetCoreUserAgentProvider>();
|
2020-04-01 20:00:27 +02:00
|
|
|
|
|
|
|
|
composition.RegisterMultipleUnique<ISessionIdResolver, ISessionManager, AspNetCoreSessionManager>();
|
2020-04-20 12:20:47 +02:00
|
|
|
|
2020-04-22 15:23:51 +10:00
|
|
|
composition.RegisterUnique<IMarchal, AspNetCoreMarchal>();
|
|
|
|
|
|
|
|
|
|
composition.RegisterUnique<IProfilerHtml, WebProfilerHtml>();
|
2020-04-22 13:08:43 +02:00
|
|
|
|
2020-04-20 12:20:47 +02:00
|
|
|
composition.RegisterUnique<IMacroRenderer, MacroRenderer>();
|
|
|
|
|
composition.RegisterUnique<IMemberUserKeyProvider, MemberUserKeyProvider>();
|
|
|
|
|
|
|
|
|
|
|
2020-04-28 12:31:15 +02:00
|
|
|
// register the umbraco context factory
|
|
|
|
|
composition.RegisterUnique<IUmbracoContextFactory, UmbracoContextFactory>();
|
2020-09-22 10:01:00 +02:00
|
|
|
composition.RegisterUnique<IBackofficeSecurityFactory, BackofficeSecurityFactory>();
|
|
|
|
|
composition.RegisterUnique<IBackofficeSecurityAccessor, HybridBackofficeSecurityAccessor>();
|
2020-04-28 12:31:15 +02:00
|
|
|
|
2020-04-20 12:20:47 +02:00
|
|
|
//register the install components
|
|
|
|
|
//NOTE: i tried to not have these registered if we weren't installing or upgrading but post install when the site restarts
|
|
|
|
|
//it still needs to use the install controller so we can't do that
|
|
|
|
|
composition.ComposeInstaller();
|
|
|
|
|
|
2020-05-14 17:04:16 +10:00
|
|
|
var umbracoApiControllerTypes = composition.TypeLoader.GetUmbracoApiControllers().ToList();
|
|
|
|
|
composition.WithCollectionBuilder<UmbracoApiControllerTypeCollectionBuilder>()
|
|
|
|
|
.Add(umbracoApiControllerTypes);
|
|
|
|
|
|
2020-05-26 14:42:19 +02:00
|
|
|
|
2020-05-14 17:04:16 +10:00
|
|
|
composition.RegisterUnique<InstallAreaRoutes>();
|
|
|
|
|
|
2020-05-14 22:14:00 +10:00
|
|
|
composition.RegisterUnique<UmbracoRequestLoggingMiddleware>();
|
|
|
|
|
composition.RegisterUnique<UmbracoRequestMiddleware>();
|
|
|
|
|
composition.RegisterUnique<BootFailedMiddleware>();
|
|
|
|
|
|
|
|
|
|
composition.RegisterUnique<UmbracoJsonModelBinder>();
|
2020-05-26 14:42:19 +02:00
|
|
|
|
2020-06-04 12:53:08 +02:00
|
|
|
composition.RegisterUnique<ITemplateRenderer, TemplateRenderer>();
|
|
|
|
|
composition.RegisterUnique<IPublicAccessChecker, PublicAccessChecker>();
|
2020-10-07 16:56:48 +11:00
|
|
|
composition.RegisterUnique(factory => new LegacyPasswordSecurity());
|
2020-03-25 15:06:22 +11:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|