private TimeSpan DefaultTimeout { get; } = new TimeSpan(0, 0, 0, 0, 500); // FUTURE use configuration value public LoginAttemptController( LoginAttemptClient loginAttemptClient, UserAccountClient userAccountClient, MemoryUsageLimiter memoryUsageLimiter, BlockingAlgorithmOptions blockingOptions, IStableStore stableStore) { _options = blockingOptions;//optionsAccessor.Options; _stableStore = stableStore; _passwordPopularityTracker = new PasswordPopularityTracker("FIXME-uniquekeyfromconfig" //FIXME -- use configuration to get options here"FIXME-uniquekeyfromconfig", thresholdRequiredToTrackPreciseOccurrences: 10); ); _loginAttemptCache = new FixedSizeLruCache<string, LoginAttempt>(80000); // FIXME -- use configuration file for size _loginAttemptsInProgress = new Dictionary<string, Task<LoginAttempt>>(); _ipHistoryCache = new SelfLoadingCache<IPAddress, IpHistory>( (id, cancellationToken) => { return Task.Run(() => new IpHistory(id), cancellationToken); // FUTURE -- option to load from stable store }); _loginAttemptClient = loginAttemptClient; _loginAttemptClient.SetLocalLoginAttemptController(this); SetUserAccountClient(userAccountClient); memoryUsageLimiter.OnReduceMemoryUsageEventHandler += ReduceMemoryUsage; }
public UserAccountController( UserAccountClient userAccountClient, LoginAttemptClient loginAttemptClient, MemoryUsageLimiter memoryUsageLimiter, BlockingAlgorithmOptions options, IStableStore stableStore, LimitPerTimePeriod[] creditLimits) { // _options = optionsAccessor.Options; _options = options; _stableStore = stableStore; _userAccountClient = userAccountClient; CreditLimits = creditLimits; _userAccountCache = new SelfLoadingCache<string, UserAccount>(_stableStore.ReadAccountAsync); SetLoginAttemptClient(loginAttemptClient); userAccountClient.SetLocalUserAccountController(this); memoryUsageLimiter.OnReduceMemoryUsageEventHandler += ReduceMemoryUsage; }