// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { string connectionString = Configuration.GetConnectionString("DefaultConnection"); services.AddMvc(); // Add application services. services.AddTransient <IEmailSender, AuthMessageSender>(); services.AddTransient <ISmsSender, AuthMessageSender>(); IdentityBuilder identityBuilder = services .AddIdentity <ApplicationUser, ApplicationRole>(options => { options.Password = ApplicationPasswordValidator.Configure(); options.User = ApplicationUserValidator.Configure(); }) .AddPasswordValidator <SameCharacterPasswordValidator>() .AddPasswordValidator <CommonlyUsedPasswordValidator>() .AddUserValidator <EmailDomainOfUserValidator>() .AddDefaultTokenProviders(); IIdentityServerBuilder identityServerBuilder = services .AddIdentityServer() //.AddSigningCredential() .AddTemporarySigningCredential(); AuthConfig.ConfigureServices(services, identityBuilder, identityServerBuilder, connectionString); }
/// <summary> /// </summary> public async Task InitialUserServiceAsync() { // Process ClaimsIdentityFactory = new ApplicationClaimsIdentityFactory(); UserValidator = new ApplicationUserValidator <User, Guid>(this) { AllowOnlyAlphanumericUserNames = false, RequireUniqueEmail = false }; PasswordValidator = new ApplicationPasswordValidator { RequiredLength = 5, RequireNonLetterOrDigit = false, RequireDigit = false, RequireLowercase = false, RequireUppercase = false }; UserLockoutEnabledByDefault = true; DefaultAccountLockoutTimeSpan = TimeSpan.FromMinutes(5); MaxFailedAccessAttemptsBeforeLockout = 5; if (_dataProtectionProvider == null) { return; } var dataProtector = _dataProtectionProvider.Create("Application Identity"); UserTokenProvider = new DataProtectorTokenProvider <User, Guid>(dataProtector); }
public void Setup() { _validator = new ApplicationPasswordValidator <ApplicationUser>(); }