Sha256: fc2a923361beedb67f17f07f49f473ef4f2c9ea0402fe5d81b19f928a724ea7d

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

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}})

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
firewall_constraint-0.0.5 README.md
firewall_constraint-0.0.4 README.md