// 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 static void Initialize(TestContext testContext) { ApplicationUserValidator = new ApplicationUserValidator(); FollowerValidator = new FollowerValidator(); CredentialValidator = new CredentialValidator(); CredentialTypeValidator = new CredentialTypeValidator(); RoleValidator = new RoleValidator(); UserRoleValidator = new UserRoleValidator(); RolePermissionValidator = new RolePermissionValidator(); PermissionValidator = new PermissionValidator(); }
public ApplicationUserManager(IUserCustomStore <TUser> store) : base(store) { UserValidator = new ApplicationUserValidator <TUser>(this) { //RequireUniqueEmail = true, }; this.EmailService = new EmailService(); //var provider = new DpapiDataProtectionProvider("AppName"); //this.UserTokenProvider = new DataProtectorTokenProvider<TUser, string>(provider.Create("ASP.NET Identity")); ; //new DataProtectorTokenProvider<ApplicationUser, long>(provider.Create("PasswordReset")); }
public UserService(UserManager <ApplicationUser> userManager, IMapper mapper, ApplicationDbContext applicationDbContext, ILogger <UserService> logger, ApplicationUserValidator applicationUserValidator ) { this.userManager = userManager ?? throw new ArgumentNullException(nameof(userManager)); this.mapper = mapper ?? throw new ArgumentNullException(nameof(mapper)); this.applicationDbContext = applicationDbContext ?? throw new ArgumentNullException(nameof(applicationDbContext)); this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); this.applicationUserValidator = applicationUserValidator ?? throw new ArgumentNullException(nameof(applicationUserValidator)); }
public static void Initialize(TestContext testContext) { ApplicationUserValidator = new ApplicationUserValidator(); FollowerValidator = new FollowerValidator(); CredentialValidator = new CredentialValidator(); CredentialTypeValidator = new CredentialTypeValidator(); RoleValidator = new RoleValidator(); UserRoleValidator = new UserRoleValidator(); RolePermissionValidator = new RolePermissionValidator(); PermissionValidator = new PermissionValidator(); Hasher = new Pbkdf2Hasher(); SaltGenerator = new RandomSaltGenerator(); }
public static void Initialize(TestContext testContext) { MemeValidator = new MemeValidator(); ApplicationUserValidator = new ApplicationUserValidator(); FollowerValidator = new FollowerValidator(); CredentialValidator = new CredentialValidator(); CredentialTypeValidator = new CredentialTypeValidator(); RoleValidator = new RoleValidator(); UserRoleValidator = new UserRoleValidator(); RolePermissionValidator = new RolePermissionValidator(); PermissionValidator = new PermissionValidator(); MemeFetcherService = new LocalMemeFetcherService(); SharedMemeValidator = new SharedMemeValidator(); CommentValidator = new CommentValidator(); Hasher = new Pbkdf2Hasher(); SaltGenerator = new RandomSaltGenerator(); }
/// <summary> /// Initializes a new instance of the <see cref="ApplicationUserManager"/> class. /// </summary> /// <param name="store"></param> public ApplicationUserManager(IUserStore <ApplicationUser, string> store) : base(store) { // Configure validation logic for usernames UserValidator = new ApplicationUserValidator <ApplicationUser>(this) { AllowOnlyAlphanumericUserNames = true, RequireUniqueEmail = false }; // Configure validation logic for passwords PasswordValidator = new PasswordValidator { RequiredLength = 8, RequireNonLetterOrDigit = false, RequireDigit = true, RequireLowercase = true, RequireUppercase = true }; }
static void Test() { _ = new ApplicationUserValidator(null); }