<commit_before>FirewallConstraint
========

Easy whitelist firewalling for Rails 3 route constraints

    gem 'firewall_constraint'

Or:

    gem install firewall_constraint

-----

config/routes.rb:

    get 'dummy/index' => 'dummy#index'
    get 'dummy/blocked_by_inline' => 'dummy#blocked_by_inline', :constraints => FirewallConstraint::Constraint.new
  
    constraints FirewallConstraint::Constraint.new do
      get 'dummy/blocked_by_block' => 'dummy#blocked_by_block'
    end
  
    constraints FirewallConstraint::Constraint.new(['127.0.0.1']) do
      get 'dummy/blocked_by_dynamic' => 'dummy#blocked_by_dynamic'
    end

    constraints FirewallConstraint::Constraint.new(Proc.new{['127.0.0.1']}) do
      get 'dummy/blocked_by_proc'
    end

----

Uses a config file if ips not present in routes

config/firewall_constraint.yml:

    test:
      - 10.0.0.0/8

----

You should be able to do DB-based whitelisting using the Proc whitelisting and an activerecord lookup or something similar to:

constraints FirewallConstraint::Constraint.new(Proc.new{ValidIps.all.map{|x| x.ip}})<commit_msg>doc fix<commit_after>FirewallConstraint
========

Easy whitelist firewalling for Rails 3 route constraints

    gem 'firewall_constraint'

Or:

    gem install firewall_constraint

-----

config/routes.rb:

    get 'dummy/index' => 'dummy#index'
    get 'dummy/blocked_by_inline' => 'dummy#blocked_by_inline', :constraints => FirewallConstraint::Constraint.new
  
    constraints FirewallConstraint::Constraint.new do
      get 'dummy/blocked_by_block' => 'dummy#blocked_by_block'
    end
  
    constraints FirewallConstraint::Constraint.new(['127.0.0.1']) do
      get 'dummy/blocked_by_dynamic' => 'dummy#blocked_by_dynamic'
    end

    constraints FirewallConstraint::Constraint.new(Proc.new{['127.0.0.1']}) do
      get 'dummy/blocked_by_proc'
    end

----

Uses a config file if ips not present in routes

config/firewall_constraint.yml:

    test:
      - 10.0.0.0/8

----

You should be able to do DB-based whitelisting using the Proc whitelisting and an activerecord lookup or something similar to:

    constraints FirewallConstraint::Constraint.new(Proc.new{ValidIps.all.map{|x| x.ip}})
{'fraction_non_alphanumeric': 0.11636363636363636, 'fraction_numerical': 0.017272727272727273, 'mean_word_length': 3.891111111111111, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 6, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1389444', 'n_tokens_mistral': 732, 'n_tokens_neox': 695, 'n_words': 160}