firewall_constraint 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +5 -5
- data/lib/firewall_constraint/version.rb +1 -1
- data/lib/firewall_constraint.rb +6 -4
- data/spec/rails_app/config/routes.rb +5 -5
- metadata +4 -4
data/README.md
CHANGED
|
@@ -14,17 +14,17 @@ Or:
|
|
|
14
14
|
config/routes.rb:
|
|
15
15
|
|
|
16
16
|
get 'dummy/index' => 'dummy#index'
|
|
17
|
-
get 'dummy/blocked_by_inline' => 'dummy#blocked_by_inline', :constraints => FirewallConstraint
|
|
17
|
+
get 'dummy/blocked_by_inline' => 'dummy#blocked_by_inline', :constraints => FirewallConstraint.new
|
|
18
18
|
|
|
19
|
-
constraints FirewallConstraint
|
|
19
|
+
constraints FirewallConstraint.new do
|
|
20
20
|
get 'dummy/blocked_by_block' => 'dummy#blocked_by_block'
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
constraints FirewallConstraint
|
|
23
|
+
constraints FirewallConstraint.new(['127.0.0.1']) do
|
|
24
24
|
get 'dummy/blocked_by_dynamic' => 'dummy#blocked_by_dynamic'
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
constraints FirewallConstraint
|
|
27
|
+
constraints FirewallConstraint.new(Proc.new{['127.0.0.1']}) do
|
|
28
28
|
get 'dummy/blocked_by_proc'
|
|
29
29
|
end
|
|
30
30
|
|
|
@@ -41,4 +41,4 @@ config/firewall_constraint.yml:
|
|
|
41
41
|
|
|
42
42
|
You should be able to do DB-based whitelisting using the Proc whitelisting and an activerecord lookup or something similar to:
|
|
43
43
|
|
|
44
|
-
constraints FirewallConstraint
|
|
44
|
+
constraints FirewallConstraint.new(Proc.new{ValidIps.all.map{|x| x.ip}})
|
data/lib/firewall_constraint.rb
CHANGED
|
@@ -6,11 +6,9 @@ module FirewallConstraint
|
|
|
6
6
|
@ips = ips
|
|
7
7
|
else
|
|
8
8
|
ips = [ips].flatten
|
|
9
|
-
|
|
9
|
+
config = !ips.empty? ? ips :
|
|
10
10
|
YAML.load_file(Rails.root.join('config','firewall_constraint.yml'))[Rails.env]
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
@ips = @config
|
|
11
|
+
@ips = config
|
|
14
12
|
end
|
|
15
13
|
end
|
|
16
14
|
|
|
@@ -40,4 +38,8 @@ module FirewallConstraint
|
|
|
40
38
|
@ips.respond_to?(:call) ? @ips.call : @ips
|
|
41
39
|
end
|
|
42
40
|
end
|
|
41
|
+
|
|
42
|
+
def self.new(*args)
|
|
43
|
+
Constraint.new(*args)
|
|
44
|
+
end
|
|
43
45
|
end
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
RailsApp::Application.routes.draw do
|
|
2
2
|
get 'dummy/index' => 'dummy#index'
|
|
3
|
-
get 'dummy/blocked_by_inline' => 'dummy#blocked_by_inline', :constraints => FirewallConstraint
|
|
3
|
+
get 'dummy/blocked_by_inline' => 'dummy#blocked_by_inline', :constraints => FirewallConstraint.new
|
|
4
4
|
|
|
5
|
-
constraints FirewallConstraint
|
|
5
|
+
constraints FirewallConstraint.new do
|
|
6
6
|
get 'dummy/blocked_by_block' => 'dummy#blocked_by_block'
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
-
constraints FirewallConstraint
|
|
9
|
+
constraints FirewallConstraint.new(['127.0.0.1']) do
|
|
10
10
|
get 'dummy/blocked_by_dynamic' => 'dummy#blocked_by_dynamic'
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
root :to => 'dummy#index'
|
|
14
14
|
|
|
15
|
-
constraints FirewallConstraint
|
|
15
|
+
constraints FirewallConstraint.new('fe80::d69a:20ff:fe0d:45fe') do
|
|
16
16
|
get 'dummy/blocked_by_ipv6'
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
-
constraints FirewallConstraint
|
|
19
|
+
constraints FirewallConstraint.new(Proc.new{['127.0.0.1']}) do
|
|
20
20
|
get 'dummy/blocked_by_proc'
|
|
21
21
|
end
|
|
22
22
|
end
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: firewall_constraint
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 19
|
|
5
5
|
prerelease:
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 0
|
|
9
|
-
-
|
|
10
|
-
version: 0.0.
|
|
9
|
+
- 6
|
|
10
|
+
version: 0.0.6
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Mike Auclair
|
|
@@ -15,7 +15,7 @@ autorequire:
|
|
|
15
15
|
bindir: bin
|
|
16
16
|
cert_chain: []
|
|
17
17
|
|
|
18
|
-
date: 2012-03-
|
|
18
|
+
date: 2012-03-26 00:00:00 Z
|
|
19
19
|
dependencies:
|
|
20
20
|
- !ruby/object:Gem::Dependency
|
|
21
21
|
name: rails
|