public static IServiceCollection AddRateLimits(this IServiceCollection services) { var instance = new RateLimitService(); services.TryAddSingleton(instance); return(services); }
public UsersController(UserManager <ApplicationUser> userManager, BTCPayServerOptions btcPayServerOptions, RoleManager <IdentityRole> roleManager, SettingsRepository settingsRepository, EventAggregator eventAggregator, IPasswordValidator <ApplicationUser> passwordValidator, NicolasDorier.RateLimits.RateLimitService throttleService, Configuration.BTCPayServerOptions options, IAuthorizationService authorizationService) { _userManager = userManager; _btcPayServerOptions = btcPayServerOptions; _roleManager = roleManager; _settingsRepository = settingsRepository; _eventAggregator = eventAggregator; _passwordValidator = passwordValidator; _throttleService = throttleService; _options = options; _authorizationService = authorizationService; }
private async Task <bool> Throttle(RateLimitService rateLimitService, ActionExecutingContext context) { return(await rateLimitService.Throttle(ZoneName, GetScope(context), context.HttpContext.RequestAborted)); }