Sha256: 121bcb079d9854e2537a3c754aed75014d9f7256fcf5f2a3c2d705a35e9eb35b
Contents?: true
Size: 847 Bytes
Versions: 10
Compression:
Stored size: 847 Bytes
Contents
module Opro::Controllers::Concerns::RateLimits extend ActiveSupport::Concern included do before_filter :oauth_record_rate_limit!, :if => :valid_oauth? before_filter :oauth_fail_request!, :if => :oauth_client_over_rate_limit? end def oauth_client_record_access!(client_id, params) # implement your access counting mechanism here end def oauth_client_rate_limited?(client_id, params) end # override to implement custom rate limits def oauth_client_over_rate_limit? return oauth_client_rate_limited?(oauth_client_app.id, params) unless oauth_client_app.blank? false end def oauth_record_rate_limit! return false if oauth_client_app.blank? oauth_client_record_access!(oauth_client_app.id, params) end def oauth_client_under_rate_limit? !oauth_client_over_rate_limit? end end
Version data entries
10 entries across 10 versions & 1 rubygems