Skip to content
Snippets Groups Projects
Commit 02349b32 authored by Eugen Rochko's avatar Eugen Rochko
Browse files

Obfuscate filenames better, double rate limits

parent 952bce30
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,10 @@ module ObfuscateFilename
file = params.dig(*path)
return if file.nil?
file.original_filename = 'media' + File.extname(file.original_filename)
file.original_filename = secure_token + File.extname(file.original_filename)
end
def secure_token(length = 16)
SecureRandom.hex(length / 2)
end
end
class Rack::Attack
# Rate limits for the API
throttle('api', limit: 150, period: 5.minutes) do |req|
throttle('api', limit: 300, period: 5.minutes) do |req|
req.ip if req.path.match(/\A\/api\/v/)
end
......@@ -11,7 +11,7 @@ class Rack::Attack
headers = {
'X-RateLimit-Limit' => match_data[:limit].to_s,
'X-RateLimit-Remaining' => '0',
'X-RateLimit-Reset' => (now + (match_data[:period] - now.to_i % match_data[:period])).iso8601(6)
'X-RateLimit-Reset' => (now + (match_data[:period] - now.to_i % match_data[:period])).iso8601(6),
}
[429, headers, [{ error: 'Throttled' }.to_json]]
......
Push notifications
==================
**Note: This push notification design turned out to not be fully operational on the side of Firebase. A different approach is in consideration**
See <https://github.com/Gargron/tusky-api> for an example of how to create push notifications for a mobile app. It involves using the Mastodon streaming API on behalf of the app's users, as a sort of proxy.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment