public SmsAuthenticationOperationFixture(ITestOutputHelper outputHelper)
        {
            var generateAndSendSmsCodeOperationStub = new Mock <IConfirmationCodeStore>();
            var resourceOwnerRepositoryStub         = new Mock <IResourceOwnerRepository>();
            var subjectBuilderStub = new Mock <ISubjectBuilder>();

            subjectBuilderStub.Setup(x => x.BuildSubject(It.IsAny <IEnumerable <Claim> >(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(DateTimeOffset.UtcNow.Ticks.ToString);
            _smsAuthenticationOperation = new SmsAuthenticationOperation(
                new RuntimeSettings(),
                null,
                generateAndSendSmsCodeOperationStub.Object,
                resourceOwnerRepositoryStub.Object,
                subjectBuilderStub.Object,
                Array.Empty <IAccountFilter>(),
                new Mock <IEventPublisher>().Object,
                new TestOutputLogger("test", outputHelper));
        }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CodeController"/> class.
 /// </summary>
 /// <param name="settings"></param>
 /// <param name="smsClient">The SMS client.</param>
 /// <param name="confirmationCodeStore">The confirmation code store.</param>
 /// <param name="resourceOwnerRepository">The resource owner repository.</param>
 /// <param name="subjectBuilder">The subject builder.</param>
 /// <param name="accountFilters">The account filters.</param>
 /// <param name="eventPublisher">The event publisher.</param>
 /// <param name="logger">The logger</param>
 public CodeController(
     RuntimeSettings settings,
     ISmsClient smsClient,
     IConfirmationCodeStore confirmationCodeStore,
     IResourceOwnerRepository resourceOwnerRepository,
     ISubjectBuilder subjectBuilder,
     IEnumerable <IAccountFilter> accountFilters,
     IEventPublisher eventPublisher,
     ILogger <CodeController> logger)
 {
     _smsAuthenticationOperation = new SmsAuthenticationOperation(
         settings,
         smsClient,
         confirmationCodeStore,
         resourceOwnerRepository,
         subjectBuilder,
         accountFilters.ToArray(),
         eventPublisher,
         logger);
 }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AuthenticateController"/> class.
        /// </summary>
        /// <param name="smsClient">The SMS client.</param>
        /// <param name="dataProtectionProvider">The data protection provider.</param>
        /// <param name="urlHelperFactory">The URL helper factory.</param>
        /// <param name="actionContextAccessor">The action context accessor.</param>
        /// <param name="eventPublisher">The event publisher.</param>
        /// <param name="authorizationCodeStore">The authorization code store.</param>
        /// <param name="authenticationService">The authentication service.</param>
        /// <param name="authenticationSchemeProvider">The authentication scheme provider.</param>
        /// <param name="twoFactorAuthenticationHandler">The two factor authentication handler.</param>
        /// <param name="subjectBuilder">The subject builder.</param>
        /// <param name="consentRepository">The consent repository.</param>
        /// <param name="scopeRepository">The scope repository.</param>
        /// <param name="tokenStore">The token store.</param>
        /// <param name="resourceOwnerRepository">The resource owner repository.</param>
        /// <param name="confirmationCodeStore">The confirmation code store.</param>
        /// <param name="clientStore">The client store.</param>
        /// <param name="jwksStore">The JWKS store.</param>
        /// <param name="accountFilters">The account filters.</param>
        /// <param name="logger">The controller logger.</param>
        /// <param name="runtimeSettings">The runtime settings.</param>
        public AuthenticateController(
            ISmsClient smsClient,
            IDataProtectionProvider dataProtectionProvider,
            IUrlHelperFactory urlHelperFactory,
            IActionContextAccessor actionContextAccessor,
            IEventPublisher eventPublisher,
            IAuthorizationCodeStore authorizationCodeStore,
            IAuthenticationService authenticationService,
            IAuthenticationSchemeProvider authenticationSchemeProvider,
            ITwoFactorAuthenticationHandler twoFactorAuthenticationHandler,
            ISubjectBuilder subjectBuilder,
            IConsentRepository consentRepository,
            IScopeRepository scopeRepository,
            ITokenStore tokenStore,
            IResourceOwnerRepository resourceOwnerRepository,
            IConfirmationCodeStore confirmationCodeStore,
            IClientStore clientStore,
            IJwksStore jwksStore,
            IEnumerable <IAccountFilter> accountFilters,
            ILogger <AuthenticateController> logger,
            RuntimeSettings runtimeSettings)
            : base(
                dataProtectionProvider,
                urlHelperFactory,
                actionContextAccessor,
                eventPublisher,
                authenticationService,
                authenticationSchemeProvider,
                twoFactorAuthenticationHandler,
                authorizationCodeStore,
                consentRepository,
                scopeRepository,
                tokenStore,
                resourceOwnerRepository,
                confirmationCodeStore,
                clientStore,
                jwksStore,
                subjectBuilder,
                accountFilters,
                logger,
                runtimeSettings)
        {
            _eventPublisher        = eventPublisher;
            _confirmationCodeStore = confirmationCodeStore;
            _logger           = logger;
            _getUserOperation = new GetUserOperation(resourceOwnerRepository, logger);
            var generateSms = new GenerateAndSendSmsCodeOperation(smsClient, confirmationCodeStore, logger);

            _smsAuthenticationOperation = new SmsAuthenticationOperation(
                runtimeSettings,
                smsClient,
                confirmationCodeStore,
                resourceOwnerRepository,
                subjectBuilder,
                accountFilters.ToArray(),
                eventPublisher,
                logger);
            _validateConfirmationCode = new ValidateConfirmationCodeAction(confirmationCodeStore);
            _authenticateHelper       = new AuthenticateHelper(
                authorizationCodeStore,
                tokenStore,
                scopeRepository,
                consentRepository,
                clientStore,
                jwksStore,
                eventPublisher,
                logger);
            _generateAndSendSmsCodeOperation = generateSms;
        }