2020-12-23 12:02:23 +11:00
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2021-09-17 12:02:04 -06:00
|
|
|
using Microsoft.AspNetCore.Routing;
|
2020-12-23 12:02:23 +11:00
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
2021-09-17 12:02:04 -06:00
|
|
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
2020-12-23 12:02:23 +11:00
|
|
|
using Microsoft.Extensions.Options;
|
2021-02-09 10:22:42 +01:00
|
|
|
using Umbraco.Cms.Core.DependencyInjection;
|
2021-02-12 10:41:07 +01:00
|
|
|
using Umbraco.Cms.Infrastructure.DependencyInjection;
|
2021-08-06 11:37:10 +02:00
|
|
|
using Umbraco.Cms.Web.Common.Middleware;
|
2021-02-10 11:42:04 +01:00
|
|
|
using Umbraco.Cms.Web.Common.Routing;
|
2021-02-10 14:21:48 +01:00
|
|
|
using Umbraco.Cms.Web.Website.Collections;
|
2021-04-09 15:24:12 +10:00
|
|
|
using Umbraco.Cms.Web.Website.Models;
|
2021-02-10 14:21:48 +01:00
|
|
|
using Umbraco.Cms.Web.Website.Routing;
|
|
|
|
|
using Umbraco.Cms.Web.Website.ViewEngines;
|
2021-09-17 12:02:04 -06:00
|
|
|
using static Microsoft.Extensions.DependencyInjection.ServiceDescriptor;
|
2020-12-23 12:02:23 +11:00
|
|
|
|
2021-02-10 14:21:48 +01:00
|
|
|
namespace Umbraco.Extensions
|
2020-12-23 12:02:23 +11:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <see cref="IUmbracoBuilder"/> extensions for umbraco front-end website
|
|
|
|
|
/// </summary>
|
2022-01-19 09:21:50 +01:00
|
|
|
public static partial class UmbracoBuilderExtensions
|
2020-12-23 12:02:23 +11:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Add services for the umbraco front-end website
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static IUmbracoBuilder AddWebsite(this IUmbracoBuilder builder)
|
|
|
|
|
{
|
2020-12-24 18:11:16 +11:00
|
|
|
builder.WithCollectionBuilder<SurfaceControllerTypeCollectionBuilder>()
|
|
|
|
|
.Add(builder.TypeLoader.GetSurfaceControllers());
|
|
|
|
|
|
2021-01-04 15:43:30 +11:00
|
|
|
// Configure MVC startup options for custom view locations
|
2021-01-14 23:14:35 +11:00
|
|
|
builder.Services.ConfigureOptions<RenderRazorViewEngineOptionsSetup>();
|
|
|
|
|
builder.Services.ConfigureOptions<PluginRazorViewEngineOptionsSetup>();
|
2020-12-23 12:02:23 +11:00
|
|
|
|
|
|
|
|
// Wraps all existing view engines in a ProfilerViewEngine
|
|
|
|
|
builder.Services.AddTransient<IConfigureOptions<MvcViewOptions>, ProfilingViewEngineWrapperMvcViewOptionsSetup>();
|
|
|
|
|
|
|
|
|
|
// TODO figure out if we need more to work on load balanced setups
|
|
|
|
|
builder.Services.AddDataProtection();
|
2021-04-09 15:24:12 +10:00
|
|
|
builder.Services.AddAntiforgery();
|
2020-12-23 12:02:23 +11:00
|
|
|
|
2021-09-17 10:29:24 -06:00
|
|
|
builder.Services.AddSingleton<UmbracoRouteValueTransformer>();
|
2021-02-03 15:47:27 +11:00
|
|
|
builder.Services.AddSingleton<IControllerActionSearcher, ControllerActionSearcher>();
|
2021-09-17 12:02:04 -06:00
|
|
|
builder.Services.TryAddEnumerable(Singleton<MatcherPolicy, NotFoundSelectorPolicy>());
|
2021-01-08 02:10:13 +11:00
|
|
|
builder.Services.AddSingleton<IUmbracoRouteValuesFactory, UmbracoRouteValuesFactory>();
|
2021-01-13 11:08:48 +11:00
|
|
|
builder.Services.AddSingleton<IRoutableDocumentFilter, RoutableDocumentFilter>();
|
2020-12-23 12:02:23 +11:00
|
|
|
|
2021-04-09 15:24:12 +10:00
|
|
|
builder.Services.AddSingleton<FrontEndRoutes>();
|
|
|
|
|
|
|
|
|
|
builder.Services.AddSingleton<MemberModelBuilderFactory>();
|
2021-02-02 14:48:01 +11:00
|
|
|
|
2021-09-21 10:49:45 -06:00
|
|
|
builder.Services.AddSingleton<IPublicAccessRequestHandler, PublicAccessRequestHandler>();
|
2021-08-06 11:37:10 +02:00
|
|
|
builder.Services.AddSingleton<BasicAuthenticationMiddleware>();
|
Implements Public Access in netcore (#10137)
* Getting new netcore PublicAccessChecker in place
* Adds full test coverage for PublicAccessChecker
* remove PublicAccessComposer
* adjust namespaces, ensure RoleManager works, separate public access controller, reduce content controller
* Implements the required methods on IMemberManager, removes old migrated code
* Updates routing to be able to re-route, Fixes middleware ordering ensuring endpoints are last, refactors pipeline options, adds public access middleware, ensures public access follows all hops
* adds note
* adds note
* Cleans up ext methods, ensures that members identity is added on both front-end and back ends. updates how UmbracoApplicationBuilder works in that it explicitly starts endpoints at the time of calling.
* Changes name to IUmbracoEndpointBuilder
* adds note
* Fixing tests, fixing error describers so there's 2x one for back office, one for members, fixes TryConvertTo, fixes login redirect
* fixing build
* Fixes keepalive, fixes PublicAccessMiddleware to not throw, updates startup code to be more clear and removes magic that registers middleware.
* adds note
* removes unused filter, fixes build
* fixes WebPath and tests
* Looks up entities in one query
* remove usings
* Fix test, remove stylesheet
* Set status code before we write to response to avoid error
* Ensures that users and members are validated when logging in. Shares more code between users and members.
* Fixes RepositoryCacheKeys to ensure the keys are normalized
* oops didn't mean to commit this
* Fix casing issues with caching, stop boxing value types for all cache operations, stop re-creating string keys in DefaultRepositoryCachePolicy
* bah, far out this keeps getting recommitted. sorry
Co-authored-by: Bjarke Berg <mail@bergmania.dk>
2021-04-20 15:11:45 +10:00
|
|
|
|
2021-02-01 16:53:24 +11:00
|
|
|
builder
|
|
|
|
|
.AddDistributedCache()
|
|
|
|
|
.AddModelsBuilder();
|
2021-01-04 13:22:29 +11:00
|
|
|
|
Implements Public Access in netcore (#10137)
* Getting new netcore PublicAccessChecker in place
* Adds full test coverage for PublicAccessChecker
* remove PublicAccessComposer
* adjust namespaces, ensure RoleManager works, separate public access controller, reduce content controller
* Implements the required methods on IMemberManager, removes old migrated code
* Updates routing to be able to re-route, Fixes middleware ordering ensuring endpoints are last, refactors pipeline options, adds public access middleware, ensures public access follows all hops
* adds note
* adds note
* Cleans up ext methods, ensures that members identity is added on both front-end and back ends. updates how UmbracoApplicationBuilder works in that it explicitly starts endpoints at the time of calling.
* Changes name to IUmbracoEndpointBuilder
* adds note
* Fixing tests, fixing error describers so there's 2x one for back office, one for members, fixes TryConvertTo, fixes login redirect
* fixing build
* Fixes keepalive, fixes PublicAccessMiddleware to not throw, updates startup code to be more clear and removes magic that registers middleware.
* adds note
* removes unused filter, fixes build
* fixes WebPath and tests
* Looks up entities in one query
* remove usings
* Fix test, remove stylesheet
* Set status code before we write to response to avoid error
* Ensures that users and members are validated when logging in. Shares more code between users and members.
* Fixes RepositoryCacheKeys to ensure the keys are normalized
* oops didn't mean to commit this
* Fix casing issues with caching, stop boxing value types for all cache operations, stop re-creating string keys in DefaultRepositoryCachePolicy
* bah, far out this keeps getting recommitted. sorry
Co-authored-by: Bjarke Berg <mail@bergmania.dk>
2021-04-20 15:11:45 +10:00
|
|
|
builder.AddMembersIdentity();
|
|
|
|
|
|
2020-12-23 12:02:23 +11:00
|
|
|
return builder;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|