Beispiel #1
0
        public AccountController(
            IAzureTableRepo azureTableRepo
            , Nivra.AzureOperations.Utility authUtility
            , Nivra.AzureOperations.Utility userTokenUtility
            , AzureTableUserManager userManager)
        {
            if (azureTableRepo == null)
            {
                throw new ArgumentNullException(nameof(azureTableRepo));
            }
            if (authUtility == null)
            {
                throw new ArgumentNullException(nameof(authUtility));
            }

            this.azureTableRepo   = azureTableRepo;
            this.authUtility      = authUtility;
            this.userTokenUtility = userTokenUtility;
            this._userManager     = userManager;
            var userTwoFactorTokenProvider = new UserTwoFactorTokenProvider(this._userManager, userTokenUtility);

            this._userManager.RegisterTokenProvider("Default", userTwoFactorTokenProvider);
            this._userManager.RegisterTokenProvider("Authenticator", userTwoFactorTokenProvider);
            authCloudTable = this.azureTableRepo.Collection["Auth"];
        }
        public Tests()
        {
            Startup.Initialize();

            IConfiguration configuration = Startup.GetIConfiguration(TestContext.CurrentContext.TestDirectory);

            JwtTokenConfigurations.Load(configuration);

            Utility authUtility      = new Utility(configuration.GetValue <string>("ConnectionStrings:DefaultConnection"), "Auth");
            Utility userTokenUtility = new Utility(configuration.GetValue <string>("ConnectionStrings:DefaultConnection"), "UserTokens");

            AzureTableUserStore <AzureTableUser> azureTableUserStore = new AzureTableUserStore <AzureTableUser>(authUtility.Table, userTokenUtility);
            var loggerFactory = LoggerFactory.Create(builder =>
            {
                builder.AddConsole();
            });

            AzureTableUserManager userManager = new AzureTableUserManager(
                store: new AzureTableUserStore <AzureTableUser>(authUtility.Table, userTokenUtility),
                optionsAccessor: new OptionsAccessor <IdentityOptions>(),
                passwordHasher: new PasswordHasher <AzureTableUser>(),
                userValidators: new List <IUserValidator <AzureTableUser> >()
            {
                new UserValidator <AzureTableUser>()
            },
                passwordValidators: new List <IPasswordValidator <AzureTableUser> >()
            {
                new PasswordValidator <AzureTableUser>()
            },
                keyNormalizer: new LookupNormalizer(),
                errors: new IdentityErrorDescriber(),
                services: null,
                logger: loggerFactory.CreateLogger <UserManager <AzureTableUser> >(),
                textResourceManager: new Nivra.Localization.TextResourceManager(),
                emailSender: new EmailSender(new AuthMessageSenderOptions()
            {
                SendGridKey = "", SendGridUser = ""
            }),
                userTokenUtility: userTokenUtility
                );

            accountController = new Controllers.AccountController(Startup.AzureTableRepo, Startup.AuthUtility, Startup.UserTokenUtility, userManager);

            //
            _email    = Startup.Dict["Email"];
            _password = Startup.Dict["Password"];
        }
Beispiel #3
0
 public UserTwoFactorTokenProvider(AzureTableUserManager userManager, Utility userTokenUtility)
 {
     this.userManager      = userManager;
     this.UserTokenUtility = userTokenUtility;
 }