mirror of
https://github.com/bitwarden/server.git
synced 2025-05-28 23:04:50 -05:00
get rid of AddBasicCustomIdentityServices
This commit is contained in:
parent
f359ef4ee2
commit
88384836b5
@ -47,7 +47,6 @@ namespace Bit.Admin
|
|||||||
services.AddScoped<CurrentContext>();
|
services.AddScoped<CurrentContext>();
|
||||||
|
|
||||||
// Identity
|
// Identity
|
||||||
services.AddBasicCustomIdentityServices(globalSettings);
|
|
||||||
services.AddPasswordlessIdentityServices<ReadOnlyEnvIdentityUserStore>(globalSettings);
|
services.AddPasswordlessIdentityServices<ReadOnlyEnvIdentityUserStore>(globalSettings);
|
||||||
if(globalSettings.SelfHosted)
|
if(globalSettings.SelfHosted)
|
||||||
{
|
{
|
||||||
|
@ -153,13 +153,15 @@ namespace Bit.Core.Utilities
|
|||||||
public static IdentityBuilder AddCustomIdentityServices(
|
public static IdentityBuilder AddCustomIdentityServices(
|
||||||
this IServiceCollection services, GlobalSettings globalSettings)
|
this IServiceCollection services, GlobalSettings globalSettings)
|
||||||
{
|
{
|
||||||
|
services.TryAddTransient<ILookupNormalizer, LowerInvariantLookupNormalizer>();
|
||||||
services.AddSingleton<IOrganizationDuoWebTokenProvider, OrganizationDuoWebTokenProvider>();
|
services.AddSingleton<IOrganizationDuoWebTokenProvider, OrganizationDuoWebTokenProvider>();
|
||||||
|
services.Configure<PasswordHasherOptions>(options => options.IterationCount = 100000);
|
||||||
services.Configure<TwoFactorRememberTokenProviderOptions>(options =>
|
services.Configure<TwoFactorRememberTokenProviderOptions>(options =>
|
||||||
{
|
{
|
||||||
options.TokenLifespan = TimeSpan.FromDays(30);
|
options.TokenLifespan = TimeSpan.FromDays(30);
|
||||||
});
|
});
|
||||||
|
|
||||||
var identityBuilder = services.AddBasicCustomIdentityServices(globalSettings, options =>
|
var identityBuilder = services.AddIdentityWithoutCookieAuth<User, Role>(options =>
|
||||||
{
|
{
|
||||||
options.User = new UserOptions
|
options.User = new UserOptions
|
||||||
{
|
{
|
||||||
@ -184,6 +186,9 @@ namespace Bit.Core.Utilities
|
|||||||
});
|
});
|
||||||
|
|
||||||
identityBuilder
|
identityBuilder
|
||||||
|
.AddUserStore<UserStore>()
|
||||||
|
.AddRoleStore<RoleStore>()
|
||||||
|
.AddTokenProvider<DataProtectorTokenProvider<User>>(TokenOptions.DefaultProvider)
|
||||||
.AddTokenProvider<AuthenticatorTokenProvider>(TwoFactorProviderType.Authenticator.ToString())
|
.AddTokenProvider<AuthenticatorTokenProvider>(TwoFactorProviderType.Authenticator.ToString())
|
||||||
.AddTokenProvider<YubicoOtpTokenProvider>(TwoFactorProviderType.YubiKey.ToString())
|
.AddTokenProvider<YubicoOtpTokenProvider>(TwoFactorProviderType.YubiKey.ToString())
|
||||||
.AddTokenProvider<DuoWebTokenProvider>(TwoFactorProviderType.Duo.ToString())
|
.AddTokenProvider<DuoWebTokenProvider>(TwoFactorProviderType.Duo.ToString())
|
||||||
@ -194,25 +199,8 @@ namespace Bit.Core.Utilities
|
|||||||
return identityBuilder;
|
return identityBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IdentityBuilder AddBasicCustomIdentityServices(
|
|
||||||
this IServiceCollection services, GlobalSettings globalSettings,
|
|
||||||
Action<IdentityOptions> setAction = null)
|
|
||||||
{
|
|
||||||
services.TryAddTransient<ILookupNormalizer, LowerInvariantLookupNormalizer>();
|
|
||||||
services.Configure<PasswordHasherOptions>(options => options.IterationCount = 100000);
|
|
||||||
|
|
||||||
var identityBuilder = services.AddIdentityWithoutCookieAuth<User, Role>(setAction);
|
|
||||||
|
|
||||||
identityBuilder
|
|
||||||
.AddUserStore<UserStore>()
|
|
||||||
.AddRoleStore<RoleStore>()
|
|
||||||
.AddTokenProvider<DataProtectorTokenProvider<User>>(TokenOptions.DefaultProvider);
|
|
||||||
|
|
||||||
return identityBuilder;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IdentityBuilder AddPasswordlessIdentityServices<TUserStore>(
|
public static IdentityBuilder AddPasswordlessIdentityServices<TUserStore>(
|
||||||
this IServiceCollection services, GlobalSettings globalSettings) where TUserStore : class
|
this IServiceCollection services, GlobalSettings globalSettings) where TUserStore : class
|
||||||
{
|
{
|
||||||
services.TryAddTransient<ILookupNormalizer, LowerInvariantLookupNormalizer>();
|
services.TryAddTransient<ILookupNormalizer, LowerInvariantLookupNormalizer>();
|
||||||
services.Configure<DataProtectionTokenProviderOptions>(options =>
|
services.Configure<DataProtectionTokenProviderOptions>(options =>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user