public static MembershipRebootConfiguration <CustomUserAccount> Create()
        {
            var settings = SecuritySettings.Instance;

            settings.MultiTenant = false;

            var config = new MembershipRebootConfiguration <CustomUserAccount>(settings);

            config.RegisterPasswordValidator(new PasswordValidator());
            config.ConfigurePasswordComplexity(5, 3);

            config.AddCommandHandler(new CustomClaimsMapper());

            var delivery = new SmtpMessageDelivery();

            var appinfo = new AspNetApplicationInformation("Test", "Test Email Signature",
                                                           "UserAccount/Login",
                                                           "UserAccount/ChangeEmail/Confirm/",
                                                           "UserAccount/Register/Cancel/",
                                                           "UserAccount/PasswordReset/Confirm/");
            var formatter = new CustomEmailMessageFormatter(appinfo);

            config.AddEventHandler(new EmailAccountEventsHandler <CustomUserAccount>(formatter, delivery));
            config.AddEventHandler(new AuthenticationAuditEventHandler());
            config.AddEventHandler(new NotifyAccountOwnerWhenTooManyFailedLoginAttempts());

            config.AddValidationHandler(new PasswordChanging());
            config.AddEventHandler(new PasswordChanged());
            config.AddCommandHandler(new CustomValidationMessages());

            return(config);
        }
        public static MembershipRebootConfiguration<CustomUserAccount> Create()
        {
            var settings = SecuritySettings.Instance;
            settings.MultiTenant = false;
            
            var config = new MembershipRebootConfiguration<CustomUserAccount>(settings);
            config.AddEventHandler(new DebuggerEventHandler<CustomUserAccount>());

            config.RegisterPasswordValidator(new PasswordValidator());
            config.ConfigurePasswordComplexity(5, 3);

            config.AddCommandHandler(new CustomClaimsMapper());

            var delivery = new SmtpMessageDelivery();

            var appinfo = new AspNetApplicationInformation("Test", "Test Email Signature",
                "UserAccount/Login",
                "UserAccount/ChangeEmail/Confirm/",
                "UserAccount/Register/Cancel/",
                "UserAccount/PasswordReset/Confirm/");
            var formatter = new CustomEmailMessageFormatter(appinfo);

            config.AddEventHandler(new EmailAccountEventsHandler<CustomUserAccount>(formatter, delivery));
            config.AddEventHandler(new AuthenticationAuditEventHandler());
            config.AddEventHandler(new NotifyAccountOwnerWhenTooManyFailedLoginAttempts());

            config.AddValidationHandler(new PasswordChanging());
            config.AddEventHandler(new PasswordChanged());
            config.AddCommandHandler(new CustomValidationMessages());

            return config;
        }
        public static void AddCommandHandler <TCommand>(this MembershipRebootConfiguration config, Action <TCommand> action)

            where TCommand : ICommand
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }
            config.AddCommandHandler(new DelegateCommandHandler <TCommand>(action));
        }
Beispiel #4
0
        public void Init()
        {
            SecuritySettings.Instance.PasswordHashingIterationCount = 1; // tests will run faster

            configuration = new MembershipRebootConfiguration
            {
                RequireAccountVerification = false,
                PasswordResetFrequency     = 1 // every day
            };
            configuration.AddEventHandler(new KeyNotification());
            configuration.AddCommandHandler(new TestMapClaimsFromAccount());
            repository         = new FakeUserAccountRepository();
            userAccountService = new UserAccountService(configuration, repository);

            subject = new TestAuthenticationService(userAccountService);
        }
Beispiel #5
0
        public void Init()
        {
            SecuritySettings.Instance.PasswordHashingIterationCount = 1; // tests will run faster

            configuration = new MembershipRebootConfiguration
            {
                RequireAccountVerification = false
            };
            accountCreatedEvent = CaptureLatestEvent.For <AccountCreatedEvent <UserAccount> >();
            configuration.AddEventHandler(accountCreatedEvent);
            configuration.AddCommandHandler(new TestMapClaimsToAccountHandler());
            repository         = new FakeUserAccountRepository();
            userAccountService = new UserAccountService(configuration, repository);

            subject = new TestAuthenticationService(userAccountService);
        }
 public static void ConfigureTwoFactorAuthenticationCookies <TAccount>(this MembershipRebootConfiguration <TAccount> config, bool debugging = false)
     where TAccount : UserAccount
 {
     config.AddCommandHandler(new TwoFactorAuthPolicyCommandHandler(new AspNetCookieBasedTwoFactorAuthPolicy(debugging)));
 }