Skip to content

Commit

Permalink
Fix: remove broken OAuth Application vacuuming & throttle OAuth Appli…
Browse files Browse the repository at this point in the history
…cation registrations (mastodon#30316)

Co-authored-by: Claire <claire.github-309c@sitedethib.com>
  • Loading branch information
ThisIsMissEm and ClearlyClaire committed May 29, 2024
1 parent 6eea832 commit d20a5c3
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 63 deletions.
10 changes: 0 additions & 10 deletions app/lib/vacuum/applications_vacuum.rb

This file was deleted.

5 changes: 0 additions & 5 deletions app/workers/scheduler/vacuum_scheduler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def vacuum_operations
preview_cards_vacuum,
backups_vacuum,
access_tokens_vacuum,
applications_vacuum,
feeds_vacuum,
imports_vacuum,
]
Expand Down Expand Up @@ -56,10 +55,6 @@ def imports_vacuum
Vacuum::ImportsVacuum.new
end

def applications_vacuum
Vacuum::ApplicationsVacuum.new
end

def content_retention_policy
ContentRetentionPolicy.current
end
Expand Down
4 changes: 4 additions & 0 deletions config/initializers/rack_attack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ def paging_request?
req.authenticated_user_id if (req.post? && req.path.match?(API_DELETE_REBLOG_REGEX)) || (req.delete? && req.path.match?(API_DELETE_STATUS_REGEX))
end

throttle('throttle_oauth_application_registrations/ip', limit: 5, period: 10.minutes) do |req|
req.throttleable_remote_ip if req.post? && req.path == '/api/v1/apps'
end

throttle('throttle_sign_up_attempts/ip', limit: 25, period: 5.minutes) do |req|
req.throttleable_remote_ip if req.post? && req.path_matches?('/auth')
end
Expand Down
18 changes: 18 additions & 0 deletions spec/config/initializers/rack/attack_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,22 @@ def increment_counter
it_behaves_like 'throttled endpoint'
end
end

describe 'throttle excessive oauth application registration requests by IP address' do
let(:throttle) { 'throttle_oauth_application_registrations/ip' }
let(:limit) { 5 }
let(:period) { 10.minutes }
let(:path) { '/api/v1/apps' }
let(:params) do
{
client_name: 'Throttle Test',
redirect_uris: 'urn:ietf:wg:oauth:2.0:oob',
scopes: 'read',
}
end

let(:request) { -> { post path, params: params, headers: { 'REMOTE_ADDR' => remote_ip } } }

it_behaves_like 'throttled endpoint'
end
end
48 changes: 0 additions & 48 deletions spec/lib/vacuum/applications_vacuum_spec.rb

This file was deleted.

0 comments on commit d20a5c3

Please sign in to comment.