Merge commit from fork
* Add rate-limit on `/auth/setup` * Remove useless test
This commit is contained in:
		
							parent
							
								
									f5c4022a20
								
							
						
					
					
						commit
						06f879ce9b
					
				@ -122,7 +122,7 @@ class Rack::Attack
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  throttle('throttle_email_confirmations/ip', limit: 25, period: 5.minutes) do |req|
 | 
			
		||||
    req.throttleable_remote_ip if req.post? && (req.path_matches?('/auth/confirmation') || req.path == '/api/v1/emails/confirmations')
 | 
			
		||||
    req.throttleable_remote_ip if (req.post? && (req.path_matches?('/auth/confirmation') || req.path == '/api/v1/emails/confirmations')) || ((req.put? || req.patch?) && req.path_matches?('/auth/setup'))
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  throttle('throttle_email_confirmations/email', limit: 5, period: 30.minutes) do |req|
 | 
			
		||||
@ -133,6 +133,14 @@ class Rack::Attack
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  throttle('throttle_auth_setup/email', limit: 5, period: 10.minutes) do |req|
 | 
			
		||||
    req.params.dig('user', 'email').presence if (req.put? || req.patch?) && req.path_matches?('/auth/setup')
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  throttle('throttle_auth_setup/account', limit: 5, period: 10.minutes) do |req|
 | 
			
		||||
    req.warden_user_id if (req.put? || req.patch?) && req.path_matches?('/auth/setup')
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  throttle('throttle_login_attempts/ip', limit: 25, period: 5.minutes) do |req|
 | 
			
		||||
    req.throttleable_remote_ip if req.post? && req.path_matches?('/auth/sign_in')
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
@ -24,15 +24,4 @@ RSpec.describe 'Auth Setup' do
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  describe 'PUT /auth/setup' do
 | 
			
		||||
    before { sign_in Fabricate(:user, confirmed_at: nil) }
 | 
			
		||||
 | 
			
		||||
    it 'gracefully handles invalid nested params' do
 | 
			
		||||
      put '/auth/setup?user=invalid'
 | 
			
		||||
 | 
			
		||||
      expect(response)
 | 
			
		||||
        .to have_http_status(400)
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user