Sha256: abe912d6d6f72b415bdfffff12d416da8b55427a28d2d1ba36227236c8c06b28
Contents?: true
Size: 1.48 KB
Versions: 1
Compression:
Stored size: 1.48 KB
Contents
module RackAttackAdmin class ApplicationController < ::ApplicationController skip_authorization_check if respond_to? :skip_authorization_check before_action :require_admin, except: [:current_request] if method_defined?(:require_admin) before_action :toggle_flags #═════════════════════════════════════════════════════════════════════════════════════════════════ # Helpers def toggle_flags cookies[:skip_safelist] = params[:skip_safelist] if params[:skip_safelist] end helper_method \ def is_redis? Rack::Attack.cache.respond.store.to_s.match?(/Redis/) end helper_method \ def redis return unless is_redis? store = Rack::Attack.cache.store store = store.redis if store.respond_to?(:redis) store = store.data if store.respond_to?(:data) store end helper_method \ def has_ttl? !!redis end helper_method \ def current_request_rack_attack_stats req = Rack::Attack::Request.new(request.env) { blocklisted?: Rack::Attack.blocklisted?(req), throttled?: Rack::Attack.throttled?(req), safelisted?: Rack::Attack.safelisted?(req), is_tracked?: Rack::Attack.is_tracked?(req), skip_safelist?: req.skip_safelist?, } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rack_attack_admin-0.1.2 | app/controllers/rack_attack_admin/application_controller.rb |