2021-11-19 16:11:12 +01:00
|
|
|
using Microsoft.AspNetCore.Authentication.Cookies;
|
|
|
|
|
using Microsoft.AspNetCore.Identity;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
|
|
|
|
using Microsoft.Extensions.Options;
|
|
|
|
|
|
2021-11-20 13:52:28 +01:00
|
|
|
namespace zero.Identity;
|
2021-11-19 16:11:12 +01:00
|
|
|
|
|
|
|
|
internal class IdentityModule : ZeroModule
|
|
|
|
|
{
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
public override void Register(IZeroModuleConfiguration config)
|
|
|
|
|
{
|
|
|
|
|
config.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<CookieAuthenticationOptions>, PostConfigureCookieAuthenticationOptions>());
|
|
|
|
|
|
|
|
|
|
config.Services.AddZeroIdentity<BackofficeUser, BackofficeUserRole>();
|
|
|
|
|
config.Services.Replace<IUserClaimsPrincipalFactory<BackofficeUser>, ZeroBackofficeClaimsPrincipalFactory<BackofficeUser, BackofficeUserRole>>();
|
|
|
|
|
config.Services.Replace<IUserStore<BackofficeUser>, RavenCoreUserStore<BackofficeUser, BackofficeUserRole>>(ServiceLifetime.Scoped);
|
|
|
|
|
config.Services.Replace<IRoleStore<BackofficeUserRole>, RavenCoreRoleStore<BackofficeUserRole>>(ServiceLifetime.Scoped);
|
|
|
|
|
|
|
|
|
|
config.Services.AddAuthentication(Constants.Auth.BackofficeScheme);
|
|
|
|
|
//.AddZeroBackofficeCookie<BackofficeUser, BackofficeUserRole>(); // TODO
|
|
|
|
|
|
|
|
|
|
config.Services.AddAuthorization();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
public override void Configure(IZeroOptions options)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|