コード例 #1
0
        // 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);
        }
コード例 #2
0
ファイル: UserService.cs プロジェクト: ImanRezaeipour/clinic
        /// <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);
        }
コード例 #3
0
 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();
 }
コード例 #4
0
        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"));
        }
コード例 #5
0
 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));
 }
コード例 #6
0
ファイル: UserServiceTests.cs プロジェクト: metalglove/Ultrix
 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();
 }
コード例 #7
0
 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();
 }
コード例 #8
0
 /// <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);
 }