protected void InitUserManager(
     BackOfficeUserManager manager,
     MembershipProviderBase membershipProvider,
     IdentityFactoryOptions <BackOfficeUserManager> options)
 {
     InitUserManager(manager, membershipProvider, UmbracoConfig.For.UmbracoSettings().Content, options);
 }
        /// <summary>
        /// Creates a BackOfficeUserManager instance with all default options and the default BackOfficeUserManager
        /// </summary>
        /// <param name="options"></param>
        /// <param name="userService"></param>
        /// <param name="entityService"></param>
        /// <param name="externalLoginService"></param>
        /// <param name="membershipProvider"></param>
        /// <param name="contentSectionConfig"></param>
        /// <returns></returns>
        public static BackOfficeUserManager Create(
            IdentityFactoryOptions <BackOfficeUserManager> options,
            IUserService userService,
            IEntityService entityService,
            IExternalLoginService externalLoginService,
            MembershipProviderBase membershipProvider,
            IContentSection contentSectionConfig)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }
            if (userService == null)
            {
                throw new ArgumentNullException("userService");
            }
            if (externalLoginService == null)
            {
                throw new ArgumentNullException("externalLoginService");
            }

            var manager = new BackOfficeUserManager(
                new BackOfficeUserStore(userService, entityService, externalLoginService, membershipProvider));

            manager.InitUserManager(manager, membershipProvider, contentSectionConfig, options);
            return(manager);
        }
Пример #3
0
 /// <summary>
 /// Initializes the user manager with the correct options
 /// </summary>
 /// <param name="manager"></param>
 /// <param name="membershipProvider"></param>
 /// <param name="options"></param>
 /// <returns></returns>
 protected void InitUserManager(
     BackOfficeUserManager manager,
     MembershipProviderBase membershipProvider,
     IdentityFactoryOptions <BackOfficeUserManager> options)
 {
     //NOTE: This method is mostly here for backwards compat
     base.InitUserManager(manager, membershipProvider, options.DataProtectionProvider);
 }
        public static BackOfficeUserManager Create(
            IdentityFactoryOptions <BackOfficeUserManager> options,
            BackOfficeUserStore customUserStore,
            MembershipProviderBase membershipProvider)
        {
            var manager = new BackOfficeUserManager(customUserStore, options, membershipProvider);

            return(manager);
        }
Пример #5
0
        /// <summary>
        /// Initializes the user manager with the correct options
        /// </summary>
        /// <param name="manager"></param>
        /// <param name="membershipProvider"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        protected void InitUserManager(BackOfficeUserManager manager, MembershipProviderBase membershipProvider, IdentityFactoryOptions <BackOfficeUserManager> options)
        {
            // Configure validation logic for usernames
            manager.UserValidator = new UserValidator <BackOfficeIdentityUser, int>(manager)
            {
                AllowOnlyAlphanumericUserNames = false,
                RequireUniqueEmail             = true
            };

            // Configure validation logic for passwords
            manager.PasswordValidator = new PasswordValidator
            {
                RequiredLength          = membershipProvider.MinRequiredPasswordLength,
                RequireNonLetterOrDigit = membershipProvider.MinRequiredNonAlphanumericCharacters > 0,
                RequireDigit            = false,
                RequireLowercase        = false,
                RequireUppercase        = false
                                          //TODO: Do we support the old regex match thing that membership providers used?
            };

            //use a custom hasher based on our membership provider
            manager.PasswordHasher = new MembershipPasswordHasher(membershipProvider);

            var dataProtectionProvider = options.DataProtectionProvider;

            if (dataProtectionProvider != null)
            {
                manager.UserTokenProvider = new DataProtectorTokenProvider <BackOfficeIdentityUser, int>(dataProtectionProvider.Create("ASP.NET Identity"));
            }

            manager.UserLockoutEnabledByDefault          = true;
            manager.MaxFailedAccessAttemptsBeforeLockout = membershipProvider.MaxInvalidPasswordAttempts;
            //NOTE: This just needs to be in the future, we currently don't support a lockout timespan, it's either they are locked
            // or they are not locked, but this determines what is set on the account lockout date which corresponds to whether they are
            // locked out or not.
            manager.DefaultAccountLockoutTimeSpan = TimeSpan.FromDays(30);

            //custom identity factory for creating the identity object for which we auth against in the back office
            manager.ClaimsIdentityFactory = new BackOfficeClaimsIdentityFactory();

            //NOTE: Not implementing these, if people need custom 2 factor auth, they'll need to implement their own UserStore to suport it

            //// Register two factor authentication providers. This application uses Phone and Emails as a step of receiving a code for verifying the user
            //// You can write your own provider and plug in here.
            //manager.RegisterTwoFactorProvider("PhoneCode", new PhoneNumberTokenProvider<ApplicationUser>
            //{
            //    MessageFormat = "Your security code is: {0}"
            //});
            //manager.RegisterTwoFactorProvider("EmailCode", new EmailTokenProvider<ApplicationUser>
            //{
            //    Subject = "Security Code",
            //    BodyFormat = "Your security code is: {0}"
            //});

            //manager.EmailService = new EmailService();
            //manager.SmsService = new SmsService();
        }
Пример #6
0
        public BackOfficeUserManager(
            IUserStore <BackOfficeIdentityUser, int> store,
            IdentityFactoryOptions <BackOfficeUserManager> options,
            MembershipProviderBase membershipProvider)
            : base(store)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }
            var manager = new BackOfficeUserManager(store);

            InitUserManager(manager, membershipProvider, options);
        }
 public BackOfficeSignInManager(BackOfficeUserManager userManager, IAuthenticationManager authenticationManager, ILogger logger, IOwinRequest request)
     : base(userManager, authenticationManager)
 {
     if (logger == null)
     {
         throw new ArgumentNullException("logger");
     }
     if (request == null)
     {
         throw new ArgumentNullException("request");
     }
     _logger            = logger;
     _request           = request;
     AuthenticationType = Constants.Security.BackOfficeAuthenticationType;
 }