mirror of
https://github.com/bitwarden/server.git
synced 2025-07-03 17:12:49 -05:00
More CanAccessPremium checks
This commit is contained in:
@ -153,16 +153,13 @@ namespace Bit.Core.Utilities
|
||||
public static IdentityBuilder AddCustomIdentityServices(
|
||||
this IServiceCollection services, GlobalSettings globalSettings)
|
||||
{
|
||||
services.AddTransient<ILookupNormalizer, LowerInvariantLookupNormalizer>();
|
||||
services.AddSingleton<IOrganizationDuoWebTokenProvider, OrganizationDuoWebTokenProvider>();
|
||||
|
||||
services.Configure<PasswordHasherOptions>(options => options.IterationCount = 75000);
|
||||
services.Configure<TwoFactorRememberTokenProviderOptions>(options =>
|
||||
{
|
||||
options.TokenLifespan = TimeSpan.FromDays(30);
|
||||
});
|
||||
|
||||
var identityBuilder = services.AddIdentityWithoutCookieAuth<User, Role>(options =>
|
||||
var identityBuilder = services.AddBasicCustomIdentityServices(globalSettings, options =>
|
||||
{
|
||||
options.User = new UserOptions
|
||||
{
|
||||
@ -187,9 +184,6 @@ namespace Bit.Core.Utilities
|
||||
});
|
||||
|
||||
identityBuilder
|
||||
.AddUserStore<UserStore>()
|
||||
.AddRoleStore<RoleStore>()
|
||||
.AddTokenProvider<DataProtectorTokenProvider<User>>(TokenOptions.DefaultProvider)
|
||||
.AddTokenProvider<AuthenticatorTokenProvider>(TwoFactorProviderType.Authenticator.ToString())
|
||||
.AddTokenProvider<YubicoOtpTokenProvider>(TwoFactorProviderType.YubiKey.ToString())
|
||||
.AddTokenProvider<DuoWebTokenProvider>(TwoFactorProviderType.Duo.ToString())
|
||||
@ -200,11 +194,27 @@ namespace Bit.Core.Utilities
|
||||
return identityBuilder;
|
||||
}
|
||||
|
||||
public static IdentityBuilder AddPasswordlessIdentityServices<TUserStore>(
|
||||
this IServiceCollection services, GlobalSettings globalSettings) where TUserStore : class
|
||||
public static IdentityBuilder AddBasicCustomIdentityServices(
|
||||
this IServiceCollection services, GlobalSettings globalSettings,
|
||||
Action<IdentityOptions> setAction = null)
|
||||
{
|
||||
services.AddTransient<ILookupNormalizer, LowerInvariantLookupNormalizer>();
|
||||
services.TryAddTransient<ILookupNormalizer, LowerInvariantLookupNormalizer>();
|
||||
services.Configure<PasswordHasherOptions>(options => options.IterationCount = 75000);
|
||||
|
||||
var identityBuilder = services.AddIdentityWithoutCookieAuth<User, Role>(setAction);
|
||||
|
||||
identityBuilder
|
||||
.AddUserStore<UserStore>()
|
||||
.AddRoleStore<RoleStore>()
|
||||
.AddTokenProvider<DataProtectorTokenProvider<User>>(TokenOptions.DefaultProvider);
|
||||
|
||||
return identityBuilder;
|
||||
}
|
||||
|
||||
public static IdentityBuilder AddPasswordlessIdentityServices<TUserStore>(
|
||||
this IServiceCollection services, GlobalSettings globalSettings) where TUserStore : class
|
||||
{
|
||||
services.TryAddTransient<ILookupNormalizer, LowerInvariantLookupNormalizer>();
|
||||
services.Configure<DataProtectionTokenProviderOptions>(options =>
|
||||
{
|
||||
options.TokenLifespan = TimeSpan.FromMinutes(15);
|
||||
|
Reference in New Issue
Block a user