Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

578 B
Raw Blame
module OpenProject
  module RateLimiting
    class APIV3 < Base
      def self.enabled_by_default?
        false
      end

      def default_limit
        6 # requests
      end

      def default_period
        3 # seconds
      end

      protected

      def discriminator(req)
        if req.post? && req.path.start_with?("/api/v3/") && req.path.end_with?("/form")
          session_id(req.env) || http_auth(req.env)
        end
      end

      def response_body(**)
        API::V3::Errors::ErrorRepresenter.new(ThrottledApiError.new).to_json
      end
    end
  end
end