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);
        }
示例#2
0
        public IdentityRepository()
        {
            var settings = SecuritySettings.FromConfiguration();

            settings.RequireAccountVerification = false;
            var config = new MembershipRebootConfiguration(settings);

            this.userSvc  = new UserAccountService(config, new BrockAllen.MembershipReboot.Ef.DefaultUserAccountRepository());
            this.groupSvc = new GroupService(new BrockAllen.MembershipReboot.Ef.DefaultGroupRepository());
        }
示例#3
0
        public IdentityRepository()
        {
            var settings = SecuritySettings.FromConfiguration();

            settings.RequireAccountVerification    = false;
            settings.PasswordHashingIterationCount = 50000;
            var config = new MembershipRebootConfiguration(settings);
            var uarepo = new BrockAllen.MembershipReboot.Ef.DefaultUserAccountRepository();

            this.userSvc   = new UserAccountService(config, uarepo);
            this.userQuery = uarepo;

            var grpRepo = new BrockAllen.MembershipReboot.Ef.DefaultGroupRepository();

            this.groupSvc   = new GroupService(config.DefaultTenant, grpRepo);
            this.groupQuery = grpRepo;
        }
示例#4
0
        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",
                                                             "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));

                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);
                }
            }
        }