Skip to content

Adding new throttle blocks outside of config file #241

Closed

Description

@aishbuilds

Hi,

I want to dynamically throttle specific users in runtime, from a custom dashboard.
In this case, I cannot define the throttle blocks in the rack-attack.rb config file.

When I define the throttle list from the controller, it does not seem to work.
I am unable to find a workaround for this, any idea on how I can get this working?

Thanks!

Activity

  1. grzuy commented on Jan 18, 2018

    @grzuy
    Collaborator

    The only thing i can think of right now that might help with your use case would be storing/keeping some value in the cookies or session hashes that differentiate users.

    Then in your config/initializers/rack_attack.rb you can have something like

    Rack::Attack.throttle("dashboard", limit: ..., period: ...) do |request|
      request.cookies[:user_id]
    end

    for example.

  2. grzuy commented on Mar 8, 2018

    @grzuy
    Collaborator

    I hope the above helps :-)
    If not, let me know and we reopen.

  3. alexsmartens commented on May 22, 2024

    @alexsmartens
    Contributor

    @grzuy, any way you've figured this one out?

  4. locked and limited conversation to collaborators on May 23, 2024
  5. converted this issue into a discussion #661 on May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions