Example #1
0
        public ViewPageViewModel()
        {
            _deviceActionService     = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService");
            _cipherService           = ServiceContainer.Resolve <ICipherService>("cipherService");
            _stateService            = ServiceContainer.Resolve <IStateService>("stateService");
            _totpService             = ServiceContainer.Resolve <ITotpService>("totpService");
            _platformUtilsService    = ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService");
            _auditService            = ServiceContainer.Resolve <IAuditService>("auditService");
            _messagingService        = ServiceContainer.Resolve <IMessagingService>("messagingService");
            _eventService            = ServiceContainer.Resolve <IEventService>("eventService");
            _passwordRepromptService = ServiceContainer.Resolve <IPasswordRepromptService>("passwordRepromptService");
            _localizeService         = ServiceContainer.Resolve <ILocalizeService>("localizeService");
            _clipboardService        = ServiceContainer.Resolve <IClipboardService>("clipboardService");
            _logger = ServiceContainer.Resolve <ILogger>("logger");

            CopyCommand               = new AsyncCommand <string>((id) => CopyAsync(id, null), onException: ex => _logger.Exception(ex), allowsMultipleExecutions: false);
            CopyUriCommand            = new AsyncCommand <LoginUriView>(uriView => CopyAsync("LoginUri", uriView.Uri), onException: ex => _logger.Exception(ex), allowsMultipleExecutions: false);
            CopyFieldCommand          = new AsyncCommand <FieldView>(field => CopyAsync(field.Type == FieldType.Hidden ? "H_FieldValue" : "FieldValue", field.Value), onException: ex => _logger.Exception(ex), allowsMultipleExecutions: false);
            LaunchUriCommand          = new Command <LoginUriView>(LaunchUri);
            TogglePasswordCommand     = new Command(TogglePassword);
            ToggleCardNumberCommand   = new Command(ToggleCardNumber);
            ToggleCardCodeCommand     = new Command(ToggleCardCode);
            CheckPasswordCommand      = new Command(CheckPasswordAsync);
            DownloadAttachmentCommand = new Command <AttachmentView>(DownloadAttachmentAsync);

            PageTitle = AppResources.ViewItem;
        }
Example #2
0
        public ViewPageViewModel()
        {
            _deviceActionService     = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService");
            _cipherService           = ServiceContainer.Resolve <ICipherService>("cipherService");
            _userService             = ServiceContainer.Resolve <IUserService>("userService");
            _totpService             = ServiceContainer.Resolve <ITotpService>("totpService");
            _platformUtilsService    = ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService");
            _auditService            = ServiceContainer.Resolve <IAuditService>("auditService");
            _messagingService        = ServiceContainer.Resolve <IMessagingService>("messagingService");
            _eventService            = ServiceContainer.Resolve <IEventService>("eventService");
            _passwordRepromptService = ServiceContainer.Resolve <IPasswordRepromptService>("passwordRepromptService");
            _localizeService         = ServiceContainer.Resolve <ILocalizeService>("localizeService");
            _clipboardService        = ServiceContainer.Resolve <IClipboardService>("clipboardService");

            CopyCommand               = new Command <string>((id) => CopyAsync(id, null));
            CopyUriCommand            = new Command <LoginUriView>(CopyUri);
            CopyFieldCommand          = new Command <FieldView>(CopyField);
            LaunchUriCommand          = new Command <LoginUriView>(LaunchUri);
            TogglePasswordCommand     = new Command(TogglePassword);
            ToggleCardNumberCommand   = new Command(ToggleCardNumber);
            ToggleCardCodeCommand     = new Command(ToggleCardCode);
            CheckPasswordCommand      = new Command(CheckPasswordAsync);
            DownloadAttachmentCommand = new Command <AttachmentView>(DownloadAttachmentAsync);

            PageTitle = AppResources.ViewItem;
        }
Example #3
0
 public TotpController(
     ITotpService totpService,
     IStringLocalizer <TotpController> localizer
     )
 {
     TotpService = totpService ?? throw new ArgumentNullException(nameof(totpService));
     Localizer   = localizer ?? throw new ArgumentNullException(nameof(localizer));
 }
Example #4
0
 public ExtensionTableSource(AppExtensionContext context, UIViewController controller)
 {
     _cipherService = ServiceContainer.Resolve <ICipherService>("cipherService");
     _totpService   = ServiceContainer.Resolve <ITotpService>("totpService");
     _stateService  = ServiceContainer.Resolve <IStateService>("stateService");
     _searchService = ServiceContainer.Resolve <ISearchService>("searchService");
     _context       = context;
     _controller    = controller;
 }
Example #5
0
 public PrivilegedAccessQueryHandler(ISecretRepository secretRepository,
                                     ITotpService totpService,
                                     IOAuthTokenService tokenService,
                                     ICacheProvider cacheProvider,
                                     ILogger logger)
 {
     _secretRepository = secretRepository;
     _totpService      = totpService;
     _tokenService     = tokenService;
     _cacheProvider    = cacheProvider;
     _logger           = logger;
 }
Example #6
0
        /// <summary>
        /// Sends a new code via the selected channel.
        /// </summary>
        /// <param name="service">The service to use.</param>
        /// <param name="configureMessage">The delegate that will be used to build the message.</param>
        /// <exception cref="TotpServiceException">used to pass errors between service and the caller.</exception>
        public static Task <TotpResult> Send(this ITotpService service, Action <TotpMessageBuilder> configureMessage)
        {
            if (configureMessage == null)
            {
                throw new ArgumentNullException(nameof(configureMessage));
            }
            var messageBuilder = new TotpMessageBuilder();

            configureMessage(messageBuilder);
            var totpMessage = messageBuilder.Build();

            return(service.Send(totpMessage.ClaimsPrincipal, totpMessage.Message, totpMessage.DeliveryChannel, totpMessage.Purpose, totpMessage.SecurityToken, totpMessage.PhoneNumberOrEmail));
        }
Example #7
0
 public AuthService(
     IUserRepository userRepository,
     IEncrypter encrypter,
     ITokenService tokenService,
     IMapper mapper,
     ITotpService totpService)
 {
     _userRepository = userRepository;
     _encrypter      = encrypter;
     _tokenService   = tokenService;
     _mapper         = mapper;
     _totpService    = totpService;
 }
Example #8
0
 /// <summary>
 /// Creates a new instance of <see cref="OtpAuthenticateExtensionGrantValidator"/>.
 /// </summary>
 /// <param name="validator">Validates an access token.</param>
 /// <param name="userManager">Provides the APIs for managing user in a persistence store.</param>
 /// <param name="totpOptions">Configuration used in <see cref="System.Security.Rfc6238AuthenticationService"/> service.</param>
 /// <param name="identityMessageDescriber">Provides an extensibility point for altering localizing used inside the package.</param>
 /// <param name="totpService">Used to generate, send and verify time based one time passwords.</param>
 public OtpAuthenticateExtensionGrantValidator(
     ITokenValidator validator,
     UserManager <User> userManager,
     TotpOptions totpOptions,
     IdentityMessageDescriber identityMessageDescriber,
     ITotpService totpService
     )
 {
     _tokenValidator               = validator ?? throw new ArgumentNullException(nameof(validator));
     _userManager                  = userManager ?? throw new ArgumentNullException(nameof(userManager));
     _identityMessageDescriber     = identityMessageDescriber ?? throw new ArgumentNullException(nameof(identityMessageDescriber));
     _totpService                  = totpService ?? throw new ArgumentNullException(nameof(totpService));
     _rfc6238AuthenticationService = new Rfc6238AuthenticationService(totpOptions.Timestep, totpOptions.CodeLength);
 }
Example #9
0
 public CompleteRegistrationRequestValidator(
     IAuthorizationCodeChallengeStore codeChallengeStore,
     IClientStore clientStore,
     ILogger <CompleteRegistrationRequestValidator> logger,
     ISystemClock systemClock,
     ITokenValidator tokenValidator,
     ITotpService totpService
     ) : base(clientStore, tokenValidator)
 {
     CodeChallengeStore = codeChallengeStore;
     Logger             = logger ?? throw new ArgumentNullException(nameof(logger));
     SystemClock        = systemClock ?? throw new ArgumentNullException(nameof(systemClock));
     TotpService        = totpService ?? throw new ArgumentNullException(nameof(totpService));
 }
 /// <summary>
 /// Creates a new instance of <see cref="ConsentController"/>.
 /// </summary>
 /// <param name="interaction">Provide services be used by the user interface to communicate with IdentityServer.</param>
 /// <param name="clientStore">Retrieval of client configuration.</param>
 /// <param name="resourceStore">Resource retrieval.</param>
 /// <param name="events">Interface for the event service.</param>
 /// <param name="logger">Represents a type used to perform logging.</param>
 /// <param name="totpService"></param>
 public ConsentController(
     IIdentityServerInteractionService interaction,
     IClientStore clientStore,
     IResourceStore resourceStore,
     IEventService events,
     ILogger <ConsentController> logger,
     ITotpService totpService
     )
 {
     _interaction   = interaction ?? throw new ArgumentNullException(nameof(interaction));
     _clientStore   = clientStore ?? throw new ArgumentNullException(nameof(clientStore));
     _resourceStore = resourceStore ?? throw new ArgumentNullException(nameof(resourceStore));
     _events        = events ?? throw new ArgumentNullException(nameof(events));
     _logger        = logger ?? throw new ArgumentNullException(nameof(logger));
     _totpService   = totpService ?? throw new ArgumentNullException(nameof(totpService));
 }
Example #11
0
        public OptionsPageViewModel()
        {
            _totpService      = ServiceContainer.Resolve <ITotpService>("totpService");
            _stateService     = ServiceContainer.Resolve <IStateService>("stateService");
            _messagingService = ServiceContainer.Resolve <IMessagingService>("messagingService");

            PageTitle = AppResources.Options;
            var iosIos = Device.RuntimePlatform == Device.iOS;

            ClearClipboardOptions = new List <KeyValuePair <int?, string> >
            {
                new KeyValuePair <int?, string>(null, AppResources.Never),
                new KeyValuePair <int?, string>(10, AppResources.TenSeconds),
                new KeyValuePair <int?, string>(20, AppResources.TwentySeconds),
                new KeyValuePair <int?, string>(30, AppResources.ThirtySeconds),
                new KeyValuePair <int?, string>(60, AppResources.OneMinute)
            };
            if (!iosIos)
            {
                ClearClipboardOptions.Add(new KeyValuePair <int?, string>(120, AppResources.TwoMinutes));
                ClearClipboardOptions.Add(new KeyValuePair <int?, string>(300, AppResources.FiveMinutes));
            }
            ThemeOptions = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>(null, AppResources.ThemeDefault),
                new KeyValuePair <string, string>(ThemeManager.Light, AppResources.Light),
                new KeyValuePair <string, string>(ThemeManager.Dark, AppResources.Dark),
                new KeyValuePair <string, string>(ThemeManager.Black, AppResources.Black),
                new KeyValuePair <string, string>(ThemeManager.Nord, AppResources.Nord),
            };
            AutoDarkThemeOptions = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>(ThemeManager.Dark, AppResources.Dark),
                new KeyValuePair <string, string>(ThemeManager.Black, AppResources.Black),
                new KeyValuePair <string, string>(ThemeManager.Nord, AppResources.Nord),
            };
            UriMatchOptions = new List <KeyValuePair <UriMatchType?, string> >
            {
                new KeyValuePair <UriMatchType?, string>(UriMatchType.Domain, AppResources.BaseDomain),
                new KeyValuePair <UriMatchType?, string>(UriMatchType.Host, AppResources.Host),
                new KeyValuePair <UriMatchType?, string>(UriMatchType.StartsWith, AppResources.StartsWith),
                new KeyValuePair <UriMatchType?, string>(UriMatchType.RegularExpression, AppResources.RegEx),
                new KeyValuePair <UriMatchType?, string>(UriMatchType.Exact, AppResources.Exact),
                new KeyValuePair <UriMatchType?, string>(UriMatchType.Never, AppResources.Never),
            };
        }
 public TwoFactorController(
     UserManager <ApplicationUser> userManager,
     SignInManager <ApplicationUser> signinManager,
     IEventService events,
     IEmailService emailService,
     ITwilioService twilioService,
     ITotpService totpService,
     IIdentityServerInteractionService interaction
     )
 {
     _userManager   = userManager;
     _signInManager = signinManager;
     _events        = events;
     _emailService  = emailService;
     _twilioService = twilioService;
     _totpService   = totpService;
     _interaction   = interaction;
 }
 public HmrcAuthTokenBroker(
     [RequiredPolicy(HmrcExecutionPolicy.Name)] ExecutionPolicy executionPolicy,
     ILogger logger,
     IOAuthTokenService tokenService,
     ISecretRepository secretRepository,
     ITotpService totpService,
     ITokenRefresher tokenRefresher,
     IHmrcAuthTokenBrokerConfig hmrcAuthTokenBrokerConfig)
 {
     _secretRepository          = secretRepository;
     _totpService               = totpService;
     _tokenService              = tokenService;
     _logger                    = logger;
     _executionPolicy           = executionPolicy;
     _tokenRefresher            = tokenRefresher;
     _hmrcAuthTokenBrokerConfig = hmrcAuthTokenBrokerConfig;
     _initialiseTask            = InitialiseToken();
 }
        public AccountAppService(
            ITotpService totpService,
            IdentityUserStore userStore,
            IdentityUserManager userManager,
            IWeChatOpenIdFinder weChatOpenIdFinder,
            IIdentityUserRepository userRepository,
            IUserSecurityCodeSender securityCodeSender,
            IDistributedCache <SmsSecurityTokenCacheItem> securityTokenCache)
        {
            TotpService        = totpService;
            UserStore          = userStore;
            UserManager        = userManager;
            UserRepository     = userRepository;
            WeChatOpenIdFinder = weChatOpenIdFinder;
            SecurityCodeSender = securityCodeSender;
            SecurityTokenCache = securityTokenCache;

            LocalizationResource = typeof(AccountResource);
        }
Example #15
0
        public OptionsPageViewModel()
        {
            _deviceActionService  = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService");
            _platformUtilsService = ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService");
            _storageService       = ServiceContainer.Resolve <IStorageService>("storageService");
            _totpService          = ServiceContainer.Resolve <ITotpService>("totpService");
            _stateService         = ServiceContainer.Resolve <IStateService>("stateService");
            _messagingService     = ServiceContainer.Resolve <IMessagingService>("messagingService");

            PageTitle = AppResources.Options;

            ClearClipboardOptions = new List <KeyValuePair <int?, string> >
            {
                new KeyValuePair <int?, string>(null, AppResources.Never),
                new KeyValuePair <int?, string>(10, AppResources.TenSeconds),
                new KeyValuePair <int?, string>(20, AppResources.TwentySeconds),
                new KeyValuePair <int?, string>(30, AppResources.ThirtySeconds),
                new KeyValuePair <int?, string>(60, AppResources.OneMinute),
                new KeyValuePair <int?, string>(120, AppResources.TwoMinutes),
                new KeyValuePair <int?, string>(300, AppResources.FiveMinutes),
            };
            ThemeOptions = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>(null, AppResources.Default),
                new KeyValuePair <string, string>("light", AppResources.Light),
                new KeyValuePair <string, string>("dark", AppResources.Dark),
            };
            if (Device.RuntimePlatform == Device.Android)
            {
                ThemeOptions.Add(new KeyValuePair <string, string>("black", AppResources.Black));
            }
            ThemeOptions.Add(new KeyValuePair <string, string>("nord", "Nord"));
            UriMatchOptions = new List <KeyValuePair <UriMatchType?, string> >
            {
                new KeyValuePair <UriMatchType?, string>(UriMatchType.Domain, AppResources.BaseDomain),
                new KeyValuePair <UriMatchType?, string>(UriMatchType.Host, AppResources.Host),
                new KeyValuePair <UriMatchType?, string>(UriMatchType.StartsWith, AppResources.StartsWith),
                new KeyValuePair <UriMatchType?, string>(UriMatchType.RegularExpression, AppResources.RegEx),
                new KeyValuePair <UriMatchType?, string>(UriMatchType.Exact, AppResources.Exact),
                new KeyValuePair <UriMatchType?, string>(UriMatchType.Never, AppResources.Never),
            };
        }
Example #16
0
        public AccountAppService(
            ITotpService totpService,
            IdentityUserStore userStore,
            IdentityUserManager userManager,
            IWeChatOpenIdFinder weChatOpenIdFinder,
            IIdentityUserRepository userRepository,
            IUserSecurityCodeSender securityCodeSender,
            IDistributedCache <SmsSecurityTokenCacheItem> securityTokenCache,
            AbpWeChatMiniProgramOptionsFactory miniProgramOptionsFactory,
            IOptions <IdentityOptions> identityOptions)
        {
            TotpService               = totpService;
            UserStore                 = userStore;
            UserManager               = userManager;
            UserRepository            = userRepository;
            WeChatOpenIdFinder        = weChatOpenIdFinder;
            SecurityCodeSender        = securityCodeSender;
            SecurityTokenCache        = securityTokenCache;
            MiniProgramOptionsFactory = miniProgramOptionsFactory;
            IdentityOptions           = identityOptions;

            LocalizationResource = typeof(AccountResource);
        }
Example #17
0
 /// <summary>
 /// Sends a new code via the selected channel for the given user id.
 /// </summary>
 /// <param name="service">The service to use.</param>
 /// <param name="userId">The user id.</param>
 /// <param name="message">The message to be sent in the SMS. It's important for the message to contain the {0} placeholder in the position where the OTP should be placed.</param>
 /// <param name="channel">Delivery channel.</param>
 /// <param name="reason">Optionaly pass the reason to generate the TOTP.</param>
 /// <exception cref="TotpServiceException">used to pass errors between service and the caller.</exception>
 public static Task <TotpResult> Send(this ITotpService service, string userId, string message, TotpDeliveryChannel channel = TotpDeliveryChannel.Sms, string reason = null) =>
 service.Send(new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(BasicClaimTypes.Subject, userId) })), message, channel, reason);
Example #18
0
 public InitRegistrationEndpoint(BearerTokenUsageValidator tokenUsageValidator, ILogger <InitRegistrationEndpoint> logger, InitRegistrationRequestValidator requestValidator,
                                 InitRegistrationResponseGenerator responseGenerator, IProfileService profileService, IResourceStore resourceStore, ITotpService totpService, IUserDeviceStore userDeviceStore,
                                 IdentityMessageDescriber identityMessageDescriber
                                 )
 {
     Logger                   = logger ?? throw new ArgumentNullException(nameof(logger));
     ProfileService           = profileService ?? throw new ArgumentNullException(nameof(profileService));
     Request                  = requestValidator ?? throw new ArgumentNullException(nameof(requestValidator));
     ResourceStore            = resourceStore;
     Response                 = responseGenerator ?? throw new ArgumentNullException(nameof(responseGenerator));
     Token                    = tokenUsageValidator ?? throw new ArgumentNullException(nameof(tokenUsageValidator));
     TotpService              = totpService ?? throw new ArgumentNullException(nameof(totpService));
     UserDeviceStore          = userDeviceStore ?? throw new ArgumentNullException(nameof(userDeviceStore));
     IdentityMessageDescriber = identityMessageDescriber ?? throw new ArgumentNullException(nameof(identityMessageDescriber));
 }
Example #19
0
 /// <summary>
 /// Creates a new instance of <see cref="TotpGrantValidator"/>.
 /// </summary>
 /// <param name="validator">Interface for the token validator.</param>
 /// <param name="totpService">Used to generate, send and verify time based one time passwords.</param>
 public TotpGrantValidator(ITokenValidator validator, ITotpService totpService)
 {
     _validator   = validator ?? throw new ArgumentNullException(nameof(validator));
     _totpService = totpService ?? throw new ArgumentNullException(nameof(totpService));
 }
Example #20
0
 /// <summary>
 /// Verify the code received for the given user id.
 /// </summary>
 /// <param name="service">The service to use.</param>
 /// <param name="userId">The user id.</param>
 /// <param name="code">The TOTP code.</param>
 /// <param name="provider">Optionaly pass the provider to use to verify. Defaults to DefaultPhoneProvider</param>
 /// <param name="reason">Optionaly pass the reason used to generate the TOTP.</param>
 public static Task <TotpResult> Verify(this ITotpService service, string userId, string code, TotpProviderType?provider = null, string reason = null) =>
 service.Verify(new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(BasicClaimTypes.Subject, userId) })), code, provider, reason);
Example #21
0
 /// <summary>
 /// Gets list of available providers for the given claims principal.
 /// </summary>
 /// <param name="service">The service to use.</param>
 /// <param name="userId">The user id.</param>
 public static Task <Dictionary <string, TotpProviderMetadata> > GetProviders(this ITotpService service, string userId) =>
 service.GetProviders(new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(BasicClaimTypes.Subject, userId) })));