public static MembershipRebootConfiguration Create()
        {
            var config = new MembershipRebootConfiguration();

            //config.RequireAccountVerification = false;
            config.AddEventHandler(new DebuggerEventHandler());

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

            var emailFormatter = new MyEmailFormatter2(appinfo);

            // uncomment if you want email notifications -- also update smtp settings in web.config
            config.AddEventHandler(new EmailAccountEventsHandler(emailFormatter));

            // uncomment to enable SMS notifications -- also update TwilloSmsEventHandler class below
            //config.AddEventHandler(new TwilloSmsEventHandler(appinfo));

            // uncomment to ensure proper password complexity
            //config.ConfigurePasswordComplexity();

            var debugging = false;

#if DEBUG
            debugging = true;
#endif
            // this config enables cookies to be issued once user logs in with mobile code
            config.ConfigureTwoFactorAuthenticationCookies(debugging);

            return(config);
        }
        public static MembershipRebootConfiguration Create()
        {
            var config = new MembershipRebootConfiguration();

            config.RequireAccountVerification = false;

            config.AddEventHandler(new DebuggerEventHandler());

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

            // uncomment if you want email notifications -- also update smtp settings in web.config
            config.AddEventHandler(new EmailAccountEventsHandler(emailFormatter));
            //config.AddEventHandler(new TwilloSmsEventHandler(appinfo));
            // set to false for production
            config.ConfigureAspNetCookieBasedTwoFactorAuthPolicy(debugging: true);

            // uncomment to ensure proper password complexity
            //config.ConfigurePasswordComplexity();

            return(config);
        }
        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());

            return config;
        }
        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 Create()
        {
            var config = new MembershipRebootConfiguration();
            //config.RequireAccountVerification = false;
            config.AddEventHandler(new DebuggerEventHandler());

            var appinfo = new AspNetApplicationInformation("Test", "Test Email Signature",
                "UserAccount/Login", 
                "UserAccount/ChangeEmail/Confirm/",
                "UserAccount/Register/Cancel/",
                "UserAccount/PasswordReset/Confirm/");
            var emailFormatter = new EmailMessageFormatter(appinfo);
            // uncomment if you want email notifications -- also update smtp settings in web.config
            config.AddEventHandler(new EmailAccountEventsHandler(emailFormatter));

            // uncomment to enable SMS notifications -- also update TwilloSmsEventHandler class below
            //config.AddEventHandler(new TwilloSmsEventHandler(appinfo));
            
            // uncomment to ensure proper password complexity
            //config.ConfigurePasswordComplexity();

            var debugging = false;
#if DEBUG
            debugging = true;
#endif
            // this config enables cookies to be issued once user logs in with mobile code
            config.ConfigureTwoFactorAuthenticationCookies(debugging);

            return config;
        }
Пример #6
0
        private static MembershipRebootConfiguration CreateMembershipRebootConfiguration(IAppBuilder app)
        {
            var config = new MembershipRebootConfiguration();

            // config.RequireAccountVerification = false;
            config.AddEventHandler(new DebuggerEventHandler());

            var appInfo = new OwinApplicationInformation(
                app,
                "Test",
                "Test Email Signature",
                "/UserAccount/Login",
                "/UserAccount/ChangeEmail/Confirm/",
                "/UserAccount/Register/Cancel/",
                "/UserAccount/PasswordReset/Confirm/");

            var emailFormatter = new EmailMessageFormatter(appInfo);

            // uncomment if you want email notifications -- also update smtp settings in web.config
            config.AddEventHandler(new EmailAccountEventsHandler(emailFormatter));
            // uncomment to enable SMS notifications -- also update TwilloSmsEventHandler class below
            //config.AddEventHandler(new TwilloSmsEventHandler(appinfo));

            // uncomment to ensure proper password complexity
            //config.ConfigurePasswordComplexity();

            return(config);
        }
        public static MembershipRebootConfiguration Create()
        {
            var settings = SecuritySettings.Instance;
            var config = new MembershipRebootConfiguration(settings, new DelegateFactory(()=>new DefaultUserAccountRepository(settings.ConnectionStringName)));

            var appinfo = new Lazy<ApplicationInformation>(() =>
            {
                // build URL
                var baseUrl = HttpContext.Current.GetApplicationUrl();
                // area name
                baseUrl += "UserAccount/";

                return new ApplicationInformation
                {
                    ApplicationName = "Test",
                    LoginUrl = baseUrl + "Login",
                    VerifyAccountUrl = baseUrl + "Register/Confirm/",
                    CancelNewAccountUrl = baseUrl + "Register/Cancel/",
                    ConfirmPasswordResetUrl = baseUrl + "PasswordReset/Confirm/",
                    ConfirmChangeEmailUrl = baseUrl + "ChangeEmail/Confirm/"
                };
            });
            var emailFormatter = new EmailMessageFormatter(appinfo);
            if (settings.RequireAccountVerification)
            {
                //config.AddEventHandler(new EmailAccountCreatedEventHandler(emailFormatter));
            }
            //config.AddEventHandler(new EmailAccountEventsHandler(emailFormatter));
            config.AddEventHandler(new TwilloSmsEventHandler(appinfo));

            config.ConfigureAspNetCookieBasedTwoFactorAuthPolicy();
            
            return config;
        }
Пример #8
0
        public static void ConfigureSolutionFormsProviders(this IServiceCollection services, ApplicationAccountInformation appAccountInformation, StmpDeliveryConfig smtpConfig)
        {
            services.AddTransient <IHttpContextAccessor, HttpContextAccessor>();
            services.AddSingleton(p => RavenContext.DocumentStore);
            //services.AddSingleton(p => new MembershipRebootConfiguration<ApplicationUser>(p.GetService<IOptions<SecuritySettings>>().Value));
            services.AddSingleton(p =>
            {
                var contextAccessor = p.GetService <IHttpContextAccessor>();
                var appInfo         = new NewAspNetApplicationInformation(contextAccessor, "Solution Forms", "Solution Forms Team", appAccountInformation.RelativeLoginUrl, appAccountInformation.RelativeConfirmChangeEmailUrl, appAccountInformation.RelativeCancelVerificationUrl, appAccountInformation.RelativeConfirmPasswordResetUrl)
                {
                    CancelVerificationUrl   = appAccountInformation.CancelVerificationUrl,
                    ConfirmChangeEmailUrl   = appAccountInformation.ConfirmChangeEmailUrl,
                    ConfirmPasswordResetUrl = appAccountInformation.ConfirmChangeEmailUrl,
                };
                var config = new MembershipRebootConfiguration <ApplicationUser>(p.GetService <IOptions <SecuritySettings> >().Value);
                //todo: get application URL builder from services and pass into appInfo constructor.
                config.AddEventHandler(new EmailAccountEventsHandler <ApplicationUser>(new EmailMessageFormatter <ApplicationUser>(appInfo), new SmtpMessageDelivery(smtpConfig)));
                return(config);
            });
            services.AddScoped <UserAccountService <ApplicationUser> >();
            services.AddScoped <DataFormsProvider>();
            services.AddScoped <DataSourcesProvider>();
            services.AddScoped <IUserAccountRepository <ApplicationUser>, MembershipProvider>();
            services.AddScoped <AuthenticationService <ApplicationUser> >(provider =>
                                                                          new AspNetAuthenticationService(
                                                                              provider.GetService <UserAccountService <ApplicationUser> >(),
                                                                              provider.GetService <IHttpContextAccessor>().HttpContext));

            services.AddScoped <TenantProvider>();
            services.AddScoped <PaymentProvider>();
        }
Пример #9
0
        public static MembershipRebootConfiguration Create()
        {
            var settings = SecuritySettings.Instance;
            var config   = new MembershipRebootConfiguration(settings, new DelegateFactory(() => new DefaultUserAccountRepository(settings.ConnectionStringName)));

            var appinfo = new Lazy <ApplicationInformation>(() =>
            {
                // build URL
                var baseUrl = HttpContext.Current.GetApplicationUrl();
                // area name
                baseUrl += "UserAccount/";

                return(new ApplicationInformation
                {
                    ApplicationName = "Test",
                    LoginUrl = baseUrl + "Login",
                    VerifyAccountUrl = baseUrl + "Register/Confirm/",
                    CancelNewAccountUrl = baseUrl + "Register/Cancel/",
                    ConfirmPasswordResetUrl = baseUrl + "PasswordReset/Confirm/",
                    ConfirmChangeEmailUrl = baseUrl + "ChangeEmail/Confirm/"
                });
            });
            var emailFormatter = new EmailMessageFormatter(appinfo);

            if (settings.RequireAccountVerification)
            {
                //config.AddEventHandler(new EmailAccountCreatedEventHandler(emailFormatter));
            }
            //config.AddEventHandler(new EmailAccountEventsHandler(emailFormatter));
            config.AddEventHandler(new TwilloSmsEventHandler(appinfo));

            config.ConfigureAspNetCookieBasedTwoFactorAuthPolicy();

            return(config);
        }
        public static MembershipRebootConfiguration Create()
        {
            var settings = SecuritySettings.FromConfiguration();
            var config   = new MembershipRebootConfiguration(settings);

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

            if (settings.RequireAccountVerification)
            {
                // uncomment if you want email notifications -- also update smtp settings in web.config
                //config.AddEventHandler(new EmailAccountCreatedEventHandler(emailFormatter));
            }
            // uncomment if you want email notifications -- also update smtp settings in web.config
            //config.AddEventHandler(new EmailAccountEventsHandler(emailFormatter));
            config.AddEventHandler(new TwilloSmsEventHandler(appinfo));
            config.ConfigureAspNetCookieBasedTwoFactorAuthPolicy();

            return(config);
        }
Пример #11
0
        public static void AddEventHandler <TEvent>(this MembershipRebootConfiguration config, Action <TEvent> action)

            where TEvent : IEvent
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }
            config.AddEventHandler(new DelegateEventHandler <TEvent>(action));
        }
        public async Task Invoke(IDictionary <string, object> env)
        {
            var ctx = new OwinContext(env);

            using (var db = new BrockAllen.MembershipReboot.Ef.DefaultUserAccountRepository())
            {
                var settings = SecuritySettings.FromConfiguration();
                var mrConfig = new MembershipRebootConfiguration(settings);
                mrConfig.ConfigureCookieBasedTwoFactorAuthPolicy(new OwinCookieBasedTwoFactorAuthPolicy(env));

                var appInfo = new OwinApplicationInformation(env,
                                                             "Test", "Test Email Signature",
                                                             "/Login",
                                                             "/Register/Confirm/",
                                                             "/Register/Cancel/",
                                                             "/PasswordReset/Confirm/",
                                                             "/ChangeEmail/Confirm/");

                var emailFormatter = new EmailMessageFormatter(appInfo);
                if (settings.RequireAccountVerification)
                {
                    // uncomment if you want email notifications -- also update smtp settings in web.config
                    mrConfig.AddEventHandler(new EmailAccountCreatedEventHandler(emailFormatter));
                }
                // uncomment if you want email notifications -- also update smtp settings in web.config
                mrConfig.AddEventHandler(new EmailAccountEventsHandler(emailFormatter));

                var uaSvc = new UserAccountService(mrConfig, db);
                var anSvc = new OwinAuthenticationService(uaSvc, env);
                try
                {
                    ctx.SetUserAccountService(uaSvc);
                    ctx.SetAuthenticationService(anSvc);

                    await next(env);
                }
                finally
                {
                    ctx.SetUserAccountService(null);
                    ctx.SetAuthenticationService(null);
                }
            }
        }
        public void Init()
        {
            oldIterations = SecuritySettings.Instance.PasswordHashingIterationCount;
            SecuritySettings.Instance.PasswordHashingIterationCount = 1; // tests will run faster

            configuration = new MembershipRebootConfiguration();
            key = new KeyNotification();
            configuration.AddEventHandler(key);
            repository = new FakeUserAccountRepository();
            subject = new TestUserAccountService(configuration, repository);
        }
        public static MembershipRebootConfiguration Create()
        {
            var config = new MembershipRebootConfiguration();
            //config.RequireAccountVerification = false;

            config.AddEventHandler(new DebuggerEventHandler());

            var appinfo = new AspNetApplicationInformation("Test", "Test Email Signature",
                "UserAccount/Login", 
                "UserAccount/ChangeEmail/Confirm/",
                "UserAccount/Register/Cancel/",
                "UserAccount/PasswordReset/Confirm/");
            var emailFormatter = new EmailMessageFormatter(appinfo);
            // uncomment if you want email notifications -- also update smtp settings in web.config
            config.AddEventHandler(new EmailAccountEventsHandler(emailFormatter));
            //config.AddEventHandler(new TwilloSmsEventHandler(appinfo));
            // uncomment to ensure proper password complexity
            //config.ConfigurePasswordComplexity();
            
            return config;
        }
Пример #15
0
        public static MembershipRebootConfiguration Create()
        {
            var settings = SecuritySettings.Instance;

            settings.MultiTenant = false;

            var config = new MembershipRebootConfiguration(settings, () => new CustomRepository());

            config.RegisterPasswordValidator(new PasswordValidator());

            var delivery  = new SmtpMessageDelivery();
            var formatter = new CustomEmailMessageFormatter(new Lazy <ApplicationInformation>(() =>
            {
                // build URL
                var baseUrl = HttpContext.Current.GetApplicationUrl();
                // area name
                baseUrl += "UserAccount/";

                return(new ApplicationInformation
                {
                    ApplicationName = "Test",
                    LoginUrl = baseUrl + "Login",
                    VerifyAccountUrl = baseUrl + "Register/Confirm/",
                    CancelNewAccountUrl = baseUrl + "Register/Cancel/",
                    ConfirmPasswordResetUrl = baseUrl + "PasswordReset/Confirm/",
                    ConfirmChangeEmailUrl = baseUrl + "ChangeEmail/Confirm/"
                });
            }));

            if (settings.RequireAccountVerification)
            {
                config.AddEventHandler(new EmailAccountCreatedEventHandler(formatter, delivery));
            }
            config.AddEventHandler(new EmailAccountEventsHandler(formatter, delivery));
            config.AddEventHandler(new AuthenticationAuditEventHandler());
            config.AddEventHandler(new NotifyAccountOwnerWhenTooManyFailedLoginAttempts());

            return(config);
        }
        public void Init()
        {
            oldIterations = SecuritySettings.Instance.PasswordHashingIterationCount;
            SecuritySettings.Instance.PasswordHashingIterationCount = 1; // tests will run faster

            configuration = new MembershipRebootConfiguration();
            key           = new KeyNotification();
            configuration.AddEventHandler(key);
            repository         = new FakeUserAccountRepository();
            userAccountService = new UserAccountService(configuration, repository);

            subject = new TestAuthenticationService(userAccountService);
        }
        public static MembershipRebootConfiguration Create()
        {
            var config = new MembershipRebootConfiguration
            {
                MultiTenant = true,
                RequireAccountVerification     = true,
                EmailIsUsername                = true,
                AllowLoginAfterAccountCreation = true
            };

            config.AddEventHandler(new DebuggerEventHandler());

            return(config);
        }
        public static MembershipRebootConfiguration Create()
        {
            var settings = SecuritySettings.Instance;
            settings.MultiTenant = false;
            
            var config = new MembershipRebootConfiguration(settings, ()=>new CustomRepository());
            config.RegisterPasswordValidator(new PasswordValidator());

            var delivery = new SmtpMessageDelivery();
            var formatter = new CustomEmailMessageFormatter(new Lazy<ApplicationInformation>(() =>
            {
                // build URL
                var baseUrl = HttpContext.Current.GetApplicationUrl();
                // area name
                baseUrl += "UserAccount/";

                return new ApplicationInformation
                {
                    ApplicationName = "Test",
                    LoginUrl = baseUrl + "Login",
                    VerifyAccountUrl = baseUrl + "Register/Confirm/",
                    CancelNewAccountUrl = baseUrl + "Register/Cancel/",
                    ConfirmPasswordResetUrl = baseUrl + "PasswordReset/Confirm/",
                    ConfirmChangeEmailUrl = baseUrl + "ChangeEmail/Confirm/"
                };
            }));

            if (settings.RequireAccountVerification)
            {
                config.AddEventHandler(new EmailAccountCreatedEventHandler(formatter, delivery));
            }
            config.AddEventHandler(new EmailAccountEventsHandler(formatter, delivery));
            config.AddEventHandler(new AuthenticationAuditEventHandler());
            config.AddEventHandler(new NotifyAccountOwnerWhenTooManyFailedLoginAttempts());

            return config;
        }
        public void Init()
        {
            SecuritySettings.Instance.PasswordHashingIterationCount = 1; // tests will run faster

            configuration = new MembershipRebootConfiguration
            {
                RequireAccountVerification = false
            };
            key = new KeyNotification();
            configuration.AddEventHandler(key);
            repository = new FakeUserAccountRepository();
            userAccountService = new UserAccountService(configuration, repository);

            subject = new TestAuthenticationService(userAccountService);
        }
Пример #20
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);
        }
Пример #21
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);
        }
        private static MembershipRebootConfiguration CreateMembershipRebootConfiguration(IAppBuilder app)
        {
            var appInfo = new OwinApplicationInformation(
                app,
                "Test",
                "Test Email Signature",
                "/Login",
                "/Register/Confirm/",
                "/Register/Cancel/",
                "/PasswordReset/Confirm/");

            var config         = new MembershipRebootConfiguration();
            var emailFormatter = new EmailMessageFormatter(appInfo);

            // uncomment if you want email notifications -- also update smtp settings in web.config
            config.AddEventHandler(new EmailAccountEventsHandler(emailFormatter));
            return(config);
        }
        private static void ConfigureMembershipReboot(IAppBuilder app)
        {
            System.Data.Entity.Database.SetInitializer(new System.Data.Entity.MigrateDatabaseToLatestVersion <DefaultMembershipRebootDatabase, BrockAllen.MembershipReboot.Ef.Migrations.Configuration>());
            var cookieOptions = new CookieAuthenticationOptions
            {
                AuthenticationType = MembershipRebootOwinConstants.AuthenticationType
            };
            Func <IDictionary <string, object>, UserAccountService> uaFunc = env =>
            {
                var appInfo = new OwinApplicationInformation(
                    env,
                    "Test",
                    "Test Email Signature",
                    "/Login",
                    "/Register/Confirm/",
                    "/Register/Cancel/",
                    "/PasswordReset/Confirm/");

                var config         = new MembershipRebootConfiguration();
                var emailFormatter = new EmailMessageFormatter(appInfo);
                // uncomment if you want email notifications -- also update smtp settings in web.config
                config.AddEventHandler(new EmailAccountEventsHandler(emailFormatter));

                var svc       = new UserAccountService(config, new DefaultUserAccountRepository());
                var debugging = false;
#if DEBUG
                debugging = true;
#endif
                svc.ConfigureTwoFactorAuthenticationCookies(env, debugging);
                return(svc);
            };
            Func <IDictionary <string, object>, AuthenticationService> authFunc = env =>
            {
                return(new OwinAuthenticationService(cookieOptions.AuthenticationType, uaFunc(env), env));
            };

            app.UseMembershipReboot(cookieOptions, uaFunc, authFunc);
        }
        public static MembershipRebootConfiguration Create()
        {
            var settings = SecuritySettings.FromConfiguration();
            var config = new MembershipRebootConfiguration(settings);

            var appinfo = new AspNetApplicationInformation("Test", "Test Email Signature",
                "UserAccount/Login", 
                "UserAccount/Register/Confirm/",
                "UserAccount/Register/Cancel/",
                "UserAccount/PasswordReset/Confirm/",
                "UserAccount/ChangeEmail/Confirm/");
            var emailFormatter = new EmailMessageFormatter(appinfo);
            if (settings.RequireAccountVerification)
            {
                // uncomment if you want email notifications -- also update smtp settings in web.config
                //config.AddEventHandler(new EmailAccountCreatedEventHandler(emailFormatter));
            }
            // uncomment if you want email notifications -- also update smtp settings in web.config
            //config.AddEventHandler(new EmailAccountEventsHandler(emailFormatter));
            config.AddEventHandler(new TwilloSmsEventHandler(appinfo));
            config.ConfigureAspNetCookieBasedTwoFactorAuthPolicy();
            
            return config;
        }