diff --git a/src/Core/Identity/CustomIdentityServiceCollectionExtensions.cs b/src/Core/Identity/CustomIdentityServiceCollectionExtensions.cs index f45c4ccee7..c703e96ac1 100644 --- a/src/Core/Identity/CustomIdentityServiceCollectionExtensions.cs +++ b/src/Core/Identity/CustomIdentityServiceCollectionExtensions.cs @@ -1,4 +1,5 @@ using System; +using Bit.Core.Identity; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Identity; using Microsoft.Extensions.DependencyInjection.Extensions; @@ -28,7 +29,7 @@ namespace Microsoft.Extensions.DependencyInjection services.TryAddScoped, UserValidator>(); services.TryAddScoped, PasswordValidator>(); services.TryAddScoped, PasswordHasher>(); - services.TryAddScoped(); + services.TryAddScoped(); services.TryAddScoped, RoleValidator>(); // No interface for the error describer so we can add errors without rev'ing the interface services.TryAddScoped(); diff --git a/src/Core/Utilities/ServiceCollectionExtensions.cs b/src/Core/Utilities/ServiceCollectionExtensions.cs index f8a755468e..86079b401b 100644 --- a/src/Core/Utilities/ServiceCollectionExtensions.cs +++ b/src/Core/Utilities/ServiceCollectionExtensions.cs @@ -153,14 +153,13 @@ namespace Bit.Core.Utilities public static IdentityBuilder AddCustomIdentityServices( this IServiceCollection services, GlobalSettings globalSettings) { - services.TryAddTransient(); services.AddSingleton(); services.Configure(options => options.IterationCount = 100000); services.Configure(options => { options.TokenLifespan = TimeSpan.FromDays(30); }); - + var identityBuilder = services.AddIdentityWithoutCookieAuth(options => { options.User = new UserOptions @@ -199,7 +198,7 @@ namespace Bit.Core.Utilities return identityBuilder; } - public static IdentityBuilder AddPasswordlessIdentityServices( + public static Tuple AddPasswordlessIdentityServices( this IServiceCollection services, GlobalSettings globalSettings) where TUserStore : class { services.TryAddTransient(); @@ -208,11 +207,14 @@ namespace Bit.Core.Utilities options.TokenLifespan = TimeSpan.FromMinutes(15); }); - var identityBuilder = services.AddIdentity() + var passwordlessIdentityBuilder = services.AddIdentity() .AddUserStore() .AddRoleStore() .AddDefaultTokenProviders(); + var regularIdentityBuilder = services.AddIdentityCore() + .AddUserStore(); + services.TryAddScoped, PasswordlessSignInManager>(); services.ConfigureApplicationCookie(options => @@ -227,7 +229,7 @@ namespace Bit.Core.Utilities options.SlidingExpiration = true; }); - return identityBuilder; + return new Tuple(passwordlessIdentityBuilder, regularIdentityBuilder); } public static void AddIdentityAuthenticationServices(