コード例 #1
0
        public static IServiceCollection AddRateLimits(this IServiceCollection services)
        {
            var instance = new RateLimitService();

            services.TryAddSingleton(instance);
            return(services);
        }
コード例 #2
0
 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;
 }
コード例 #3
0
 private async Task <bool> Throttle(RateLimitService rateLimitService, ActionExecutingContext context)
 {
     return(await rateLimitService.Throttle(ZoneName, GetScope(context), context.HttpContext.RequestAborted));
 }