Created
June 17, 2014 12:42
-
-
Save anonymous/3dbe80256f70d7f261b3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ip_address_whitelist: | |
| - 127.0.0.1 | |
| - 1.2.3.4 | |
| - 5.6.7.8 | |
| whitelisted_pages: | |
| - /assets/.* | |
| - / | |
| - /login |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if LOCAL_SETTINGS['ip_address_whitelist'] && LOCAL_SETTINGS['whitelisted_pages'] | |
| class Rack::Attack | |
| #if request.path.includes?(LOCAL_SETTINGS['whitelisted_pages']) | |
| LOCAL_SETTINGS['whitelisted_pages'].map! { |str| Regexp.new(str) } | |
| blacklist('allow whitelisted pages') do |req| | |
| LOCAL_SETTINGS['whitelisted_pages'].none? { |regexp| req.path =~ regexp } | |
| end | |
| #elsif remote.request_ip.includes?(LOCAL_SETTINGS['ip_address_whitelist']) | |
| blacklist('allow from localhost') do |req| | |
| !LOCAL_SETTINGS['ip_address_whitelist'].include?(req.ip) | |
| end | |
| #end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment