示例#1
0
        public static Maybe <AssertionOptions> GenerateAssertionOptionsForUser(this IFido2 fido2, IUser user)
        {
            var existingCredentials =
                user.AuthenticatorDevices.Select(x => new PublicKeyCredentialDescriptor(x.CredentialId));

            try
            {
                var exts = new AuthenticationExtensionsClientInputs
                {
                    SimpleTransactionAuthorization  = "FIDO",
                    GenericTransactionAuthorization = new TxAuthGenericArg
                    {
                        ContentType = "text/plain",
                        Content     = new byte[] { 0x46, 0x49, 0x44, 0x4F },
                    },
                    UserVerificationIndex = true,
                    Location = true,
                    UserVerificationMethod = true,
                };

                var uv      = UserVerificationRequirement.Discouraged;
                var options = fido2.GetAssertionOptions(
                    existingCredentials,
                    uv,
                    exts);

                return(Maybe.From(options));
            }
            catch (Fido2VerificationException)
            {
                return(Maybe <AssertionOptions> .Nothing);
            }
        }
示例#2
0
 public Fido2LinkCommand(IFido2 fido2, ICacheItemRepository cacheItemRepository,
                         IOwnIdCoreConfiguration configuration, IIdentitiesProvider identitiesProvider,
                         IEncodingService encodingService, IAccountLinkHandler linkHandler) : base(fido2, cacheItemRepository,
                                                                                                   configuration, identitiesProvider, encodingService)
 {
     _linkHandler = linkHandler;
 }
示例#3
0
 public Fido2UpgradeConnectionCommand(IFido2 fido2, ICacheItemRepository cacheItemRepository,
                                      IOwnIdCoreConfiguration configuration, IIdentitiesProvider identitiesProvider,
                                      IEncodingService encodingService, IUserHandlerAdapter userHandlerAdapter) : base(fido2, cacheItemRepository,
                                                                                                                       configuration, identitiesProvider, encodingService)
 {
     _userHandlerAdapter = userHandlerAdapter;
 }
示例#4
0
        public UserServiceTests()
        {
            _userRepository             = Substitute.For <IUserRepository>();
            _cipherRepository           = Substitute.For <ICipherRepository>();
            _organizationUserRepository = Substitute.For <IOrganizationUserRepository>();
            _organizationRepository     = Substitute.For <IOrganizationRepository>();
            _mailService             = Substitute.For <IMailService>();
            _pushService             = Substitute.For <IPushNotificationService>();
            _userStore               = Substitute.For <IUserStore <User> >();
            _optionsAccessor         = Substitute.For <IOptions <IdentityOptions> >();
            _passwordHasher          = Substitute.For <IPasswordHasher <User> >();
            _userValidators          = new List <IUserValidator <User> >();
            _passwordValidators      = new List <IPasswordValidator <User> >();
            _keyNormalizer           = Substitute.For <ILookupNormalizer>();
            _errors                  = new IdentityErrorDescriber();
            _services                = Substitute.For <IServiceProvider>();
            _logger                  = Substitute.For <ILogger <UserManager <User> > >();
            _licenseService          = Substitute.For <ILicensingService>();
            _eventService            = Substitute.For <IEventService>();
            _applicationCacheService = Substitute.For <IApplicationCacheService>();
            _dataProtectionProvider  = Substitute.For <IDataProtectionProvider>();
            _paymentService          = Substitute.For <IPaymentService>();
            _policyRepository        = Substitute.For <IPolicyRepository>();
            _referenceEventService   = Substitute.For <IReferenceEventService>();
            _fido2                  = Substitute.For <IFido2>();
            _currentContext         = new CurrentContext(null);
            _globalSettings         = new GlobalSettings();
            _organizationService    = Substitute.For <IOrganizationService>();
            _providerUserRepository = Substitute.For <IProviderUserRepository>();

            _sut = new UserService(
                _userRepository,
                _cipherRepository,
                _organizationUserRepository,
                _organizationRepository,
                _mailService,
                _pushService,
                _userStore,
                _optionsAccessor,
                _passwordHasher,
                _userValidators,
                _passwordValidators,
                _keyNormalizer,
                _errors,
                _services,
                _logger,
                _licenseService,
                _eventService,
                _applicationCacheService,
                _dataProtectionProvider,
                _paymentService,
                _policyRepository,
                _referenceEventService,
                _fido2,
                _currentContext,
                _globalSettings,
                _organizationService,
                _providerUserRepository
                );
        }
 public Fido2RecoveryCommand(IFido2 fido2, ICacheItemRepository cacheItemRepository,
                             IOwnIdCoreConfiguration configuration, IIdentitiesProvider identitiesProvider,
                             IEncodingService encodingService, IAccountRecoveryHandler recoveryHandler) : base(fido2,
                                                                                                               cacheItemRepository, configuration, identitiesProvider, encodingService)
 {
     _recoveryHandler = recoveryHandler;
 }
 public InitiateAuthenticatorDeviceEnrollmentCommandHandler(
     ICurrentAuthenticatedUserProvider currentAuthenticatedUserProvider, IUserRepository userRepository,
     IFido2 fido2)
 {
     this._currentAuthenticatedUserProvider = currentAuthenticatedUserProvider;
     this._userRepository = userRepository;
     this._fido2          = fido2;
 }
 public Fido2LoginCommand(IFido2 fido2, ICacheItemRepository cacheItemRepository,
                          IUserHandlerAdapter userHandlerAdapter, IOwnIdCoreConfiguration configuration)
 {
     _fido2 = fido2;
     _cacheItemRepository = cacheItemRepository;
     _userHandlerAdapter  = userHandlerAdapter;
     _configuration       = configuration;
 }
 public EnrollAuthenticatorDeviceCommandHandler(IUserRepository userRepository, IClock clock,
                                                ICurrentAuthenticatedUserProvider currentAuthenticatedUserProvider, IFido2 fido2)
 {
     this._userRepository = userRepository;
     this._clock          = clock;
     this._currentAuthenticatedUserProvider = currentAuthenticatedUserProvider;
     this._fido2 = fido2;
 }
示例#9
0
 public ValidateDeviceMfaAgainstCurrentUserCommandHandler(IUserRepository userRepository, IFido2 fido2,
                                                          ICurrentAuthenticatedUserProvider currentAuthenticatedUserProvider, IClock clock)
 {
     this._userRepository = userRepository;
     this._fido2          = fido2;
     this._currentAuthenticatedUserProvider = currentAuthenticatedUserProvider;
     this._clock = clock;
 }
示例#10
0
 public AuthDeviceController([NotNull] IMediator mediator, [NotNull] IUserQueries userQueries, IFido2 fido2,
                             ICurrentUserService currentUserService, IAuthenticationService authenticationService)
 {
     this._mediator              = mediator ?? throw new ArgumentNullException(nameof(mediator));
     this._userQueries           = userQueries ?? throw new ArgumentNullException(nameof(userQueries));
     this._fido2                 = fido2;
     this._currentUserService    = currentUserService;
     this._authenticationService = authenticationService;
 }
示例#11
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="dataContext"></param>
 /// <param name="configFileService"></param>
 public FIDO2Service(DataContext dataContext, IDistributedCache distributedCache, ConfigFileService configFileService, IFido2 fido2, IDistributedIdGenerator IdGenerator)
 {
     this.IdGenerator      = IdGenerator;
     this.dataContext      = dataContext;
     this.distributedCache = distributedCache;
     this.config           = configFileService.WebConfig;
     this.fido2Config      = config.SecurityConfig.FIDO2Config;
     this._fido2           = fido2;
 }
 public EnrollDeviceCommandHandler(IUserRepository userRepository, IClock clock,
                                   ICurrentUserService currentUserService, IOptions <SiteSettings> siteSettings, IFido2 fido2)
 {
     this._userRepository     = userRepository;
     this._clock              = clock;
     this._currentUserService = currentUserService;
     this._fido2              = fido2;
     this._siteSettings       = siteSettings.Value;
 }
 public WebAuthnService(ILogger <WebAuthnService> logger, IMemoryCache cache, IFido2 fido2, IOptions <AppSettings> options, TurnContext db, IMapper mapper, IUserService userService)
 {
     _logger      = logger;
     _cache       = cache;
     _fido2       = fido2;
     _options     = options;
     _db          = db;
     _mapper      = mapper;
     _userService = userService;
 }
示例#14
0
        public AccountController(IConfiguration configuration, IFido2 fido2)
        {
            this.fido2 = fido2;

            oktaClient = new OktaClient(new OktaClientConfiguration
            {
                OktaDomain = configuration["Okta:Domain"],
                Token      = configuration["Okta:ApiToken"]
            });
        }
 public Fido2RegisterCommand(IFido2 fido2, ICacheItemRepository cacheItemRepository,
                             IOwnIdCoreConfiguration configuration, IIdentitiesProvider identitiesProvider,
                             IEncodingService encodingService)
 {
     _fido2 = fido2;
     CacheItemRepository = cacheItemRepository;
     _configuration      = configuration;
     _identitiesProvider = identitiesProvider;
     _encodingService    = encodingService;
 }
示例#16
0
        public TestController(IConfiguration config)
        {
            _origin = config["fido2:origin"];

            _fido2 = new Fido2(new Fido2Configuration
            {
                ServerDomain = config["fido2:serverDomain"],
                ServerName   = "Fido2 test",
                Origin       = _origin
            }, ConformanceTesting.MetadataServiceInstance(System.IO.Path.Combine(config["fido2:MDSCacheDirPath"], @"Conformance"), _origin));
        }
示例#17
0
 public Fido2Controller(
     UserManager <ApplicationUser> userManager,
     SignInManager <ApplicationUser> signInManager,
     IFido2 fido2,
     IFido2CredentialService fido2CredentialService
     )
 {
     _fido2 = fido2;
     _fido2CredentialService = fido2CredentialService;
     _userManager            = userManager;
     _signInManager          = signInManager;
 }
        public TestController(IOptions <Fido2Configuration> fido2Configuration)
        {
            _origin = fido2Configuration.Value.ServerDomain;

            _fido2 = new Fido2(new Fido2Configuration
            {
                ServerDomain = fido2Configuration.Value.ServerDomain,
                ServerName   = fido2Configuration.Value.ServerName,
            },
                               ConformanceTesting.MetadataServiceInstance(
                                   System.IO.Path.Combine(fido2Configuration.Value.MDSCacheDirPath, @"Conformance"), _origin)
                               );
        }
示例#19
0
        public AuthenticateUserCommandHandler(IUserRepository userRepository, IClock clock,
                                              IOptions <SecuritySettings> securitySettings, IFido2 fido2)
        {
            if (securitySettings == null)
            {
                throw new ArgumentNullException(nameof(securitySettings));
            }

            this._userRepository   = userRepository ?? throw new ArgumentNullException(nameof(userRepository));
            this._clock            = clock ?? throw new ArgumentNullException(nameof(clock));
            this._fido2            = fido2 ?? throw new ArgumentNullException(nameof(fido2));
            this._securitySettings = securitySettings.Value;
        }
示例#20
0
 public AccountController(
     ILogger <AccountController> logger,
     IWebHostEnvironment environment,
     UserManager <UserProfileModel> userManager,
     SignInManager <UserProfileModel> signInManager,
     IPostService posts, IUserProfileService localProfiles, IPublicProfileService publicProfiles,
     IReactionService reactions, ITagService tags,
     INotificationService notifications,
     IPeerService peers,
     IAuthService auth,
     ISettingsService settings,
     IFido2 fido2,
     IInvitationService invitationService,
     IActivityStreamRepository activityStreams,
     IRateLimitService rateLimitService
     ) :
     base(environment, signInManager, userManager, posts, localProfiles, publicProfiles, reactions, tags, notifications, peers, auth, settings, activityStreams)
 {
     _logger            = logger;
     _fido2             = fido2;
     _invitationService = invitationService;
     _rateLimitService  = rateLimitService;
 }
示例#21
0
 public AccountController(
     UserManager <ApplicationUser> userManager,
     RoleManager <IdentityRole> roleManager,
     SignInManager <ApplicationUser> signInManager,
     SettingsRepository settingsRepository,
     Configuration.BTCPayServerOptions options,
     BTCPayServerEnvironment btcPayServerEnvironment,
     U2FService u2FService,
     Fido2Service fido2Service,
     EventAggregator eventAggregator,
     IFido2 fido)
 {
     _userManager             = userManager;
     _signInManager           = signInManager;
     _RoleManager             = roleManager;
     _SettingsRepository      = settingsRepository;
     _Options                 = options;
     _btcPayServerEnvironment = btcPayServerEnvironment;
     _u2FService              = u2FService;
     _fido2Service            = fido2Service;
     _eventAggregator         = eventAggregator;
     _fido   = fido;
     _logger = Logs.PayServer;
 }
示例#22
0
 public FidoController(IFido2 fido2, DevelopmentInMemoryStore fidoStore)
 {
     this.fido2     = fido2;
     this.fidoStore = fidoStore;
 }
示例#23
0
 public Fido2Service(ApplicationDbContextFactory contextFactory, IFido2 fido2, Fido2Configuration fido2Configuration)
 {
     _contextFactory     = contextFactory;
     _fido2              = fido2;
     _fido2Configuration = fido2Configuration;
 }
示例#24
0
 public WebAuthnTokenProvider(IServiceProvider serviceProvider, IFido2 fido2, GlobalSettings globalSettings)
 {
     _serviceProvider = serviceProvider;
     _fido2           = fido2;
     _globalSettings  = globalSettings;
 }
示例#25
0
 public UserService(
     IUserRepository userRepository,
     ICipherRepository cipherRepository,
     IOrganizationUserRepository organizationUserRepository,
     IOrganizationRepository organizationRepository,
     IMailService mailService,
     IPushNotificationService pushService,
     IUserStore <User> store,
     IOptions <IdentityOptions> optionsAccessor,
     IPasswordHasher <User> passwordHasher,
     IEnumerable <IUserValidator <User> > userValidators,
     IEnumerable <IPasswordValidator <User> > passwordValidators,
     ILookupNormalizer keyNormalizer,
     IdentityErrorDescriber errors,
     IServiceProvider services,
     ILogger <UserManager <User> > logger,
     ILicensingService licenseService,
     IEventService eventService,
     IApplicationCacheService applicationCacheService,
     IDataProtectionProvider dataProtectionProvider,
     IPaymentService paymentService,
     IPolicyRepository policyRepository,
     IReferenceEventService referenceEventService,
     IFido2 fido2,
     ICurrentContext currentContext,
     GlobalSettings globalSettings,
     IOrganizationService organizationService)
     : base(
         store,
         optionsAccessor,
         passwordHasher,
         userValidators,
         passwordValidators,
         keyNormalizer,
         errors,
         services,
         logger)
 {
     _userRepository             = userRepository;
     _cipherRepository           = cipherRepository;
     _organizationUserRepository = organizationUserRepository;
     _organizationRepository     = organizationRepository;
     _mailService                      = mailService;
     _pushService                      = pushService;
     _identityOptions                  = optionsAccessor?.Value ?? new IdentityOptions();
     _identityErrorDescriber           = errors;
     _passwordHasher                   = passwordHasher;
     _passwordValidators               = passwordValidators;
     _licenseService                   = licenseService;
     _eventService                     = eventService;
     _applicationCacheService          = applicationCacheService;
     _paymentService                   = paymentService;
     _policyRepository                 = policyRepository;
     _organizationServiceDataProtector = dataProtectionProvider.CreateProtector(
         "OrganizationServiceDataProtector");
     _referenceEventService = referenceEventService;
     _fido2               = fido2;
     _currentContext      = currentContext;
     _globalSettings      = globalSettings;
     _organizationService = organizationService;
 }
示例#26
0
 public MyController(IFido2 fido2)
 {
     _fido2 = fido2;
 }
 public ValidateAuthenticatorDeviceCommandHandler(IUserRepository userRepository, IFido2 fido2, ICurrentUserService currentUserService)
 {
     this._userRepository     = userRepository;
     this._fido2              = fido2;
     this._currentUserService = currentUserService;
 }
 public AuthController(IFido2 fido2, WebAuthnDbConext context)
 {
     _fido2       = fido2;
     this.context = context;
 }
示例#29
0
 public Fido2Service(ApplicationDbContextFactory contextFactory, IFido2 fido2)
 {
     _contextFactory = contextFactory;
     _fido2          = fido2;
 }
示例#30
0
 public PasswordlessController(IFido2 fido2, TestUserStore users, IEventService events, IIdentityServerInteractionService interaction)
 {
     _fido2  = fido2;
     _events = events;
     _users  = users ?? new TestUserStore(TestUsers.Users);;
 }