Files
Umbraco-CMS/src/Umbraco.Web.BackOffice/Extensions/UmbracoBackOfficeServiceCollectionExtensions.cs

28 lines
1.1 KiB
C#
Raw Normal View History

2020-05-15 16:52:51 +01:00
using System.Collections.Generic;
using Microsoft.AspNetCore.Identity;
2020-05-15 15:21:15 +01:00
using Microsoft.Extensions.DependencyInjection;
2020-05-15 16:52:51 +01:00
using Umbraco.Core.Composing;
2020-05-15 15:21:15 +01:00
using Umbraco.Core.Mapping;
using Umbraco.Web.BackOffice.Identity;
namespace Umbraco.Extensions
{
public static class UmbracoBackOfficeServiceCollectionExtensions
{
2020-05-15 16:52:51 +01:00
public static void AddUmbracoBackOfficeIdentity(this IServiceCollection services, IFactory factory)
2020-05-15 15:21:15 +01:00
{
2020-05-15 16:52:51 +01:00
// UmbracoMapper - hack?
services.AddSingleton<IdentityMapDefinition>();
services.AddSingleton(s => new MapDefinitionCollection(new[] {s.GetService<IdentityMapDefinition>()}));
services.AddSingleton<UmbracoMapper>();
2020-05-15 15:21:15 +01:00
services.AddIdentity<BackOfficeIdentityUser, IdentityRole>()
.AddDefaultTokenProviders()
.AddUserStore<BackOfficeUserStore>();
// .AddClaimsPrincipalFactory<UserClaimsPrincipalFactory<BackOfficeIdentityUser, IdentityRole>>() // TODO: extract custom claims principal factory
// .AddUserManager<BackOfficeUserManager<BackOfficeIdentityUser>>()
}
}
}