rack-auth-ip 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +39 -2
- data/README +4 -4
- data/Rakefile +1 -1
- data/doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-block_rb.html +1 -1
- data/doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-callbacks_rb.html +1 -1
- data/doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-change_rb.html +1 -1
- data/doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-hunk_rb.html +1 -1
- data/doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs_rb.html +1 -1
- data/doc/output/coverage/-Library-Ruby-Gems-gems-rcov-0_8_1_2_0-lib-rcov_rb.html +1 -1
- data/doc/output/coverage/-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-drb-drb_rb.html +1 -1
- data/doc/output/coverage/-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-drb-eq_rb.html +1 -1
- data/doc/output/coverage/-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-drb-invokemethod_rb.html +1 -1
- data/doc/output/coverage/-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-ipaddr_rb.html +1 -1
- data/doc/output/coverage/-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-pp_rb.html +1 -1
- data/doc/output/coverage/-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-prettyprint_rb.html +1 -1
- data/doc/output/coverage/-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-timeout_rb.html +1 -1
- data/doc/output/coverage/index.html +18 -45
- data/doc/output/coverage/lib-rack-auth-ip_rb.html +59 -47
- data/lib/rack/auth/ip.rb +14 -2
- data/spec/rack-auth-ip_spec.rb +3 -8
- metadata +2 -3
- data/doc/output/coverage/-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-forwardable_rb.html +0 -828
data/ChangeLog
CHANGED
@@ -1,4 +1,41 @@
|
|
1
|
-
|
1
|
+
commit dfd279f9ab5f5ec3c028765350dd0b7dcc986338
|
2
|
+
Author: Keiji, Yoshimi <walf443@gmail.com>
|
3
|
+
Date: Sat Jun 28 12:53:47 2008 +0900
|
2
4
|
|
3
|
-
|
5
|
+
release 0.0.3
|
4
6
|
|
7
|
+
commit b6a7d890b8ac9dd9edccc669b34a9f860943fcf5
|
8
|
+
Author: Keiji, Yoshimi <walf443@gmail.com>
|
9
|
+
Date: Sat Jun 28 12:49:59 2008 +0900
|
10
|
+
|
11
|
+
fixed bug: using block was not worked.
|
12
|
+
|
13
|
+
commit b5f1366e9f39aa0a37eb2996e8d35e58df05c920
|
14
|
+
Author: Keiji, Yoshimi <walf443@gmail.com>
|
15
|
+
Date: Tue May 27 01:49:33 2008 +0900
|
16
|
+
|
17
|
+
Tweaked README.
|
18
|
+
|
19
|
+
commit ddc24760138294f349003f683dc972f9a1f74539
|
20
|
+
Author: Keiji, Yoshimi <walf443@gmail dot com>
|
21
|
+
Date: Sat May 24 15:23:06 2008 +0900
|
22
|
+
|
23
|
+
release 0.0.2
|
24
|
+
|
25
|
+
commit 0fd1c34d64ff9df4b34da2c5c29c8ec2dc596b6c
|
26
|
+
Author: Keiji, Yoshimi <walf443@gmail dot com>
|
27
|
+
Date: Sat May 24 15:21:04 2008 +0900
|
28
|
+
|
29
|
+
added content-type header.
|
30
|
+
|
31
|
+
commit 7b8880ca5d3079aa3d87fafa0ab5316bc58f7a2b
|
32
|
+
Author: Keiji, Yoshimi <walf443@gmail dot com>
|
33
|
+
Date: Sat May 24 14:17:36 2008 +0900
|
34
|
+
|
35
|
+
fixed dependency
|
36
|
+
|
37
|
+
commit bdd84d2ef7eb015397d0d663399be6c4186730fc
|
38
|
+
Author: Keiji, Yoshimi <walf443@gmail dot com>
|
39
|
+
Date: Sat May 24 14:05:50 2008 +0900
|
40
|
+
|
41
|
+
initial commit
|
data/README
CHANGED
@@ -7,13 +7,13 @@ middleware to restrict ip address
|
|
7
7
|
in your_app.ru
|
8
8
|
require 'rack/auth/ip'
|
9
9
|
# allow access only local network
|
10
|
-
use Rack::Auth::IP,
|
10
|
+
use Rack::Auth::IP, %w( 192.168.0.0/24 )
|
11
11
|
|
12
12
|
# you can use block
|
13
13
|
# ip is IPAddr instance.
|
14
|
-
use Rack::Auth::IP
|
14
|
+
use Rack::Auth::IP do |ip|
|
15
15
|
Your::Model::IP.count({ :ip => ip.to_s }) != 0
|
16
|
-
|
16
|
+
end
|
17
17
|
|
18
18
|
== Description
|
19
19
|
middleware to restrict ip address
|
@@ -26,7 +26,7 @@ middleware to restrict ip address
|
|
26
26
|
|
27
27
|
=== Gem Installation
|
28
28
|
|
29
|
-
gem install
|
29
|
+
gem install rack-auth-ip
|
30
30
|
|
31
31
|
== Features/Problems
|
32
32
|
|
data/Rakefile
CHANGED
@@ -553,7 +553,7 @@ span.run100 {
|
|
553
553
|
</style>
|
554
554
|
</head>
|
555
555
|
<body><h3>C0 code coverage information</h3>
|
556
|
-
<p>Generated on Sat
|
556
|
+
<p>Generated on Sat Jun 28 12:48:54 +0900 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
|
557
557
|
</p>
|
558
558
|
<hr/>
|
559
559
|
<pre><span class='marked0'>Code reported as executed by Ruby looks like this...
|
data/doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-callbacks_rb.html
CHANGED
@@ -553,7 +553,7 @@ span.run100 {
|
|
553
553
|
</style>
|
554
554
|
</head>
|
555
555
|
<body><h3>C0 code coverage information</h3>
|
556
|
-
<p>Generated on Sat
|
556
|
+
<p>Generated on Sat Jun 28 12:48:54 +0900 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
|
557
557
|
</p>
|
558
558
|
<hr/>
|
559
559
|
<pre><span class='marked0'>Code reported as executed by Ruby looks like this...
|
@@ -553,7 +553,7 @@ span.run100 {
|
|
553
553
|
</style>
|
554
554
|
</head>
|
555
555
|
<body><h3>C0 code coverage information</h3>
|
556
|
-
<p>Generated on Sat
|
556
|
+
<p>Generated on Sat Jun 28 12:48:54 +0900 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
|
557
557
|
</p>
|
558
558
|
<hr/>
|
559
559
|
<pre><span class='marked0'>Code reported as executed by Ruby looks like this...
|
@@ -553,7 +553,7 @@ span.run100 {
|
|
553
553
|
</style>
|
554
554
|
</head>
|
555
555
|
<body><h3>C0 code coverage information</h3>
|
556
|
-
<p>Generated on Sat
|
556
|
+
<p>Generated on Sat Jun 28 12:48:55 +0900 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
|
557
557
|
</p>
|
558
558
|
<hr/>
|
559
559
|
<pre><span class='marked0'>Code reported as executed by Ruby looks like this...
|
@@ -553,7 +553,7 @@ span.run100 {
|
|
553
553
|
</style>
|
554
554
|
</head>
|
555
555
|
<body><h3>C0 code coverage information</h3>
|
556
|
-
<p>Generated on Sat
|
556
|
+
<p>Generated on Sat Jun 28 12:48:54 +0900 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
|
557
557
|
</p>
|
558
558
|
<hr/>
|
559
559
|
<pre><span class='marked0'>Code reported as executed by Ruby looks like this...
|
@@ -553,7 +553,7 @@ span.run100 {
|
|
553
553
|
</style>
|
554
554
|
</head>
|
555
555
|
<body><h3>C0 code coverage information</h3>
|
556
|
-
<p>Generated on Sat
|
556
|
+
<p>Generated on Sat Jun 28 12:48:55 +0900 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
|
557
557
|
</p>
|
558
558
|
<hr/>
|
559
559
|
<pre><span class='marked0'>Code reported as executed by Ruby looks like this...
|
@@ -553,7 +553,7 @@ span.run100 {
|
|
553
553
|
</style>
|
554
554
|
</head>
|
555
555
|
<body><h3>C0 code coverage information</h3>
|
556
|
-
<p>Generated on Sat
|
556
|
+
<p>Generated on Sat Jun 28 12:48:57 +0900 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
|
557
557
|
</p>
|
558
558
|
<hr/>
|
559
559
|
<pre><span class='marked0'>Code reported as executed by Ruby looks like this...
|
@@ -553,7 +553,7 @@ span.run100 {
|
|
553
553
|
</style>
|
554
554
|
</head>
|
555
555
|
<body><h3>C0 code coverage information</h3>
|
556
|
-
<p>Generated on Sat
|
556
|
+
<p>Generated on Sat Jun 28 12:48:57 +0900 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
|
557
557
|
</p>
|
558
558
|
<hr/>
|
559
559
|
<pre><span class='marked0'>Code reported as executed by Ruby looks like this...
|
@@ -553,7 +553,7 @@ span.run100 {
|
|
553
553
|
</style>
|
554
554
|
</head>
|
555
555
|
<body><h3>C0 code coverage information</h3>
|
556
|
-
<p>Generated on Sat
|
556
|
+
<p>Generated on Sat Jun 28 12:48:57 +0900 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
|
557
557
|
</p>
|
558
558
|
<hr/>
|
559
559
|
<pre><span class='marked0'>Code reported as executed by Ruby looks like this...
|
@@ -553,7 +553,7 @@ span.run100 {
|
|
553
553
|
</style>
|
554
554
|
</head>
|
555
555
|
<body><h3>C0 code coverage information</h3>
|
556
|
-
<p>Generated on Sat
|
556
|
+
<p>Generated on Sat Jun 28 12:48:57 +0900 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
|
557
557
|
</p>
|
558
558
|
<hr/>
|
559
559
|
<pre><span class='marked0'>Code reported as executed by Ruby looks like this...
|
@@ -553,7 +553,7 @@ span.run100 {
|
|
553
553
|
</style>
|
554
554
|
</head>
|
555
555
|
<body><h3>C0 code coverage information</h3>
|
556
|
-
<p>Generated on Sat
|
556
|
+
<p>Generated on Sat Jun 28 12:48:57 +0900 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
|
557
557
|
</p>
|
558
558
|
<hr/>
|
559
559
|
<pre><span class='marked0'>Code reported as executed by Ruby looks like this...
|
@@ -553,7 +553,7 @@ span.run100 {
|
|
553
553
|
</style>
|
554
554
|
</head>
|
555
555
|
<body><h3>C0 code coverage information</h3>
|
556
|
-
<p>Generated on Sat
|
556
|
+
<p>Generated on Sat Jun 28 12:48:58 +0900 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
|
557
557
|
</p>
|
558
558
|
<hr/>
|
559
559
|
<pre><span class='marked0'>Code reported as executed by Ruby looks like this...
|
@@ -553,7 +553,7 @@ span.run100 {
|
|
553
553
|
</style>
|
554
554
|
</head>
|
555
555
|
<body><h3>C0 code coverage information</h3>
|
556
|
-
<p>Generated on Sat
|
556
|
+
<p>Generated on Sat Jun 28 12:48:58 +0900 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
|
557
557
|
</p>
|
558
558
|
<hr/>
|
559
559
|
<pre><span class='marked0'>Code reported as executed by Ruby looks like this...
|
@@ -148,7 +148,7 @@ table.report tr.dark {
|
|
148
148
|
</script>
|
149
149
|
</head>
|
150
150
|
<body><h3>C0 code coverage information</h3>
|
151
|
-
<p>Generated on Sat
|
151
|
+
<p>Generated on Sat Jun 28 12:48:53 +0900 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
|
152
152
|
</p>
|
153
153
|
<hr/>
|
154
154
|
<table class='report'><thead><tr><td class='heading'>Name</td>
|
@@ -159,21 +159,21 @@ table.report tr.dark {
|
|
159
159
|
</tr>
|
160
160
|
</thead>
|
161
161
|
<tbody><tr class='light'><td>TOTAL</td>
|
162
|
-
<td class='lines_total'><tt>
|
162
|
+
<td class='lines_total'><tt>6940</tt>
|
163
163
|
</td>
|
164
|
-
<td class='lines_code'><tt>
|
164
|
+
<td class='lines_code'><tt>4082</tt>
|
165
165
|
</td>
|
166
|
-
<td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_total'>
|
166
|
+
<td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_total'>41.8%</tt>
|
167
167
|
</td>
|
168
|
-
<td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='
|
169
|
-
<td class='uncovered' width='
|
168
|
+
<td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='42'/>
|
169
|
+
<td class='uncovered' width='58'/>
|
170
170
|
</tr>
|
171
171
|
</table>
|
172
172
|
</td>
|
173
173
|
</tr>
|
174
174
|
</table>
|
175
175
|
</td>
|
176
|
-
<td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_code'>15.
|
176
|
+
<td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_code'>15.7%</tt>
|
177
177
|
</td>
|
178
178
|
<td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='16'/>
|
179
179
|
<td class='uncovered' width='84'/>
|
@@ -427,34 +427,7 @@ table.report tr.dark {
|
|
427
427
|
</table>
|
428
428
|
</td>
|
429
429
|
</tr>
|
430
|
-
<tr class='light'><td><a href='-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-
|
431
|
-
</td>
|
432
|
-
<td class='lines_total'><tt>218</tt>
|
433
|
-
</td>
|
434
|
-
<td class='lines_code'><tt>50</tt>
|
435
|
-
</td>
|
436
|
-
<td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_total'>82.6%</tt>
|
437
|
-
</td>
|
438
|
-
<td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='83'/>
|
439
|
-
<td class='uncovered' width='17'/>
|
440
|
-
</tr>
|
441
|
-
</table>
|
442
|
-
</td>
|
443
|
-
</tr>
|
444
|
-
</table>
|
445
|
-
</td>
|
446
|
-
<td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_code'>32.0%</tt>
|
447
|
-
</td>
|
448
|
-
<td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='32'/>
|
449
|
-
<td class='uncovered' width='68'/>
|
450
|
-
</tr>
|
451
|
-
</table>
|
452
|
-
</td>
|
453
|
-
</tr>
|
454
|
-
</table>
|
455
|
-
</td>
|
456
|
-
</tr>
|
457
|
-
<tr class='dark'><td><a href='-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-ipaddr_rb.html'>/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/ipaddr.rb</a>
|
430
|
+
<tr class='light'><td><a href='-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-ipaddr_rb.html'>/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/ipaddr.rb</a>
|
458
431
|
</td>
|
459
432
|
<td class='lines_total'><tt>529</tt>
|
460
433
|
</td>
|
@@ -481,7 +454,7 @@ table.report tr.dark {
|
|
481
454
|
</table>
|
482
455
|
</td>
|
483
456
|
</tr>
|
484
|
-
<tr class='
|
457
|
+
<tr class='dark'><td><a href='-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-pp_rb.html'>/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/pp.rb</a>
|
485
458
|
</td>
|
486
459
|
<td class='lines_total'><tt>647</tt>
|
487
460
|
</td>
|
@@ -508,7 +481,7 @@ table.report tr.dark {
|
|
508
481
|
</table>
|
509
482
|
</td>
|
510
483
|
</tr>
|
511
|
-
<tr class='
|
484
|
+
<tr class='light'><td><a href='-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-prettyprint_rb.html'>/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/prettyprint.rb</a>
|
512
485
|
</td>
|
513
486
|
<td class='lines_total'><tt>896</tt>
|
514
487
|
</td>
|
@@ -535,7 +508,7 @@ table.report tr.dark {
|
|
535
508
|
</table>
|
536
509
|
</td>
|
537
510
|
</tr>
|
538
|
-
<tr class='
|
511
|
+
<tr class='dark'><td><a href='-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-timeout_rb.html'>/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/timeout.rb</a>
|
539
512
|
</td>
|
540
513
|
<td class='lines_total'><tt>105</tt>
|
541
514
|
</td>
|
@@ -562,23 +535,23 @@ table.report tr.dark {
|
|
562
535
|
</table>
|
563
536
|
</td>
|
564
537
|
</tr>
|
565
|
-
<tr class='
|
538
|
+
<tr class='light'><td><a href='lib-rack-auth-ip_rb.html'>lib/rack/auth/ip.rb</a>
|
566
539
|
</td>
|
567
|
-
<td class='lines_total'><tt>
|
540
|
+
<td class='lines_total'><tt>56</tt>
|
568
541
|
</td>
|
569
|
-
<td class='lines_code'><tt>
|
542
|
+
<td class='lines_code'><tt>39</tt>
|
570
543
|
</td>
|
571
|
-
<td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_total'>
|
544
|
+
<td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_total'>94.6%</tt>
|
572
545
|
</td>
|
573
|
-
<td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='
|
574
|
-
<td class='uncovered' width='
|
546
|
+
<td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='95'/>
|
547
|
+
<td class='uncovered' width='5'/>
|
575
548
|
</tr>
|
576
549
|
</table>
|
577
550
|
</td>
|
578
551
|
</tr>
|
579
552
|
</table>
|
580
553
|
</td>
|
581
|
-
<td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_code'>92.
|
554
|
+
<td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_code'>92.3%</tt>
|
582
555
|
</td>
|
583
556
|
<td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='92'/>
|
584
557
|
<td class='uncovered' width='8'/>
|
@@ -553,7 +553,7 @@ span.run100 {
|
|
553
553
|
</style>
|
554
554
|
</head>
|
555
555
|
<body><h3>C0 code coverage information</h3>
|
556
|
-
<p>Generated on Sat
|
556
|
+
<p>Generated on Sat Jun 28 12:48:58 +0900 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
|
557
557
|
</p>
|
558
558
|
<hr/>
|
559
559
|
<pre><span class='marked0'>Code reported as executed by Ruby looks like this...
|
@@ -571,21 +571,21 @@ span.run100 {
|
|
571
571
|
</thead>
|
572
572
|
<tbody><tr class='light'><td><a href='lib-rack-auth-ip_rb.html'>lib/rack/auth/ip.rb</a>
|
573
573
|
</td>
|
574
|
-
<td class='lines_total'><tt>
|
574
|
+
<td class='lines_total'><tt>56</tt>
|
575
575
|
</td>
|
576
|
-
<td class='lines_code'><tt>
|
576
|
+
<td class='lines_code'><tt>39</tt>
|
577
577
|
</td>
|
578
|
-
<td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_total'>
|
578
|
+
<td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_total'>94.6%</tt>
|
579
579
|
</td>
|
580
|
-
<td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='
|
581
|
-
<td class='uncovered' width='
|
580
|
+
<td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='95'/>
|
581
|
+
<td class='uncovered' width='5'/>
|
582
582
|
</tr>
|
583
583
|
</table>
|
584
584
|
</td>
|
585
585
|
</tr>
|
586
586
|
</table>
|
587
587
|
</td>
|
588
|
-
<td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_code'>92.
|
588
|
+
<td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_code'>92.3%</tt>
|
589
589
|
</td>
|
590
590
|
<td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='92'/>
|
591
591
|
<td class='uncovered' width='8'/>
|
@@ -601,47 +601,59 @@ span.run100 {
|
|
601
601
|
<pre><span class="marked1"><a name="line1"></a> 1 require 'ipaddr'
|
602
602
|
</span><span class="marked0"><a name="line2"></a> 2 module Rack
|
603
603
|
</span><span class="marked1"><a name="line3"></a> 3 module Auth
|
604
|
-
</span><span class="
|
605
|
-
</span><span class="
|
606
|
-
</span><span class="inferred0"><a name="line6"></a> 6
|
607
|
-
</span><span class="
|
608
|
-
</span><span class="
|
609
|
-
</span><span class="
|
610
|
-
</span><span class="inferred0"><a name="line10"></a>10
|
611
|
-
</span><span class="
|
612
|
-
</span><span class="inferred0"><a name="line12"></a>12
|
613
|
-
</span><span class="
|
614
|
-
</span><span class="
|
615
|
-
</span><span class="marked1"><a name="line15"></a>15
|
616
|
-
</span><span class="inferred0"><a name="line16"></a>16
|
617
|
-
</span><span class="marked1"><a name="line17"></a>17
|
618
|
-
</span><span class="
|
619
|
-
</span><span class="marked1"><a name="line19"></a>19
|
620
|
-
</span><span class="
|
621
|
-
</span><span class="marked1"><a name="line21"></a>21
|
622
|
-
</span><span class="inferred0"><a name="line22"></a>22
|
623
|
-
</span><span class="marked1"><a name="line23"></a>23
|
624
|
-
</span><span class="
|
625
|
-
</span><span class="
|
604
|
+
</span><span class="inferred0"><a name="line4"></a> 4 # in your_app.ru
|
605
|
+
</span><span class="inferred1"><a name="line5"></a> 5 # require 'rack/auth/ip'
|
606
|
+
</span><span class="inferred0"><a name="line6"></a> 6 # # allow access only local network
|
607
|
+
</span><span class="inferred1"><a name="line7"></a> 7 # use Rack::Auth::IP, %w( 192.168.0.0/24 )
|
608
|
+
</span><span class="inferred0"><a name="line8"></a> 8
|
609
|
+
</span><span class="inferred1"><a name="line9"></a> 9 # # you can use block
|
610
|
+
</span><span class="inferred0"><a name="line10"></a>10 # # ip is IPAddr instance.
|
611
|
+
</span><span class="inferred1"><a name="line11"></a>11 # use Rack::Auth::IP do |ip|
|
612
|
+
</span><span class="inferred0"><a name="line12"></a>12 # Your::Model::IP.count({ :ip => ip.to_s }) != 0
|
613
|
+
</span><span class="inferred1"><a name="line13"></a>13 # end
|
614
|
+
</span><span class="marked0"><a name="line14"></a>14 class IP
|
615
|
+
</span><span class="marked1"><a name="line15"></a>15 module Util
|
616
|
+
</span><span class="inferred0"><a name="line16"></a>16 # consider using reverse proxy
|
617
|
+
</span><span class="marked1"><a name="line17"></a>17 def detect_ip env
|
618
|
+
</span><span class="marked0"><a name="line18"></a>18 if env['HTTP_X_FORWARDED_FOR']
|
619
|
+
</span><span class="marked1"><a name="line19"></a>19 env['HTTP_X_FORWARDED_FOR'].split(',').pop
|
620
|
+
</span><span class="inferred0"><a name="line20"></a>20 else
|
621
|
+
</span><span class="marked1"><a name="line21"></a>21 env["REMOTE_ADDR"]
|
622
|
+
</span><span class="inferred0"><a name="line22"></a>22 end
|
623
|
+
</span><span class="marked1"><a name="line23"></a>23 end
|
624
|
+
</span><span class="inferred0"><a name="line24"></a>24
|
625
|
+
</span><span class="marked1"><a name="line25"></a>25 module_function :detect_ip
|
626
626
|
</span><span class="inferred0"><a name="line26"></a>26 end
|
627
|
-
</span><span class="
|
628
|
-
</span><span class="
|
629
|
-
</span><span class="marked1"><a name="line29"></a>29
|
630
|
-
</span><span class="
|
631
|
-
</span><span class="marked1"><a name="line31"></a>31
|
632
|
-
</span><span class="
|
633
|
-
</span><span class="marked1"><a name="line33"></a>33
|
634
|
-
</span><span class="
|
635
|
-
</span><span class="inferred1"><a name="line35"></a>35
|
636
|
-
</span><span class="
|
637
|
-
</span><span class="
|
638
|
-
</span><span class="
|
639
|
-
</span><span class="
|
640
|
-
</span><span class="marked0"><a name="line40"></a>40
|
641
|
-
</span><span class="
|
642
|
-
</span><span class="inferred0"><a name="line42"></a>42
|
643
|
-
</span><span class="
|
644
|
-
</span><span class="
|
627
|
+
</span><span class="marked1"><a name="line27"></a>27 include Util
|
628
|
+
</span><span class="inferred0"><a name="line28"></a>28
|
629
|
+
</span><span class="marked1"><a name="line29"></a>29 def initialize app, ip_list=nil, &block
|
630
|
+
</span><span class="marked0"><a name="line30"></a>30 @app = app
|
631
|
+
</span><span class="marked1"><a name="line31"></a>31 @ip_list = ip_list
|
632
|
+
</span><span class="inferred0"><a name="line32"></a>32
|
633
|
+
</span><span class="marked1"><a name="line33"></a>33 if @ip_list
|
634
|
+
</span><span class="marked0"><a name="line34"></a>34 @ip_list = @ip_list.map {|ip| IPAddr.new(ip) }
|
635
|
+
</span><span class="inferred1"><a name="line35"></a>35 end
|
636
|
+
</span><span class="inferred0"><a name="line36"></a>36
|
637
|
+
</span><span class="marked1"><a name="line37"></a>37 @cond = block
|
638
|
+
</span><span class="inferred0"><a name="line38"></a>38 end
|
639
|
+
</span><span class="inferred1"><a name="line39"></a>39
|
640
|
+
</span><span class="marked0"><a name="line40"></a>40 def call env
|
641
|
+
</span><span class="marked1"><a name="line41"></a>41 req_ip = IPAddr.new(detect_ip(env))
|
642
|
+
</span><span class="inferred0"><a name="line42"></a>42
|
643
|
+
</span><span class="marked1"><a name="line43"></a>43 if @ip_list
|
644
|
+
</span><span class="marked0"><a name="line44"></a>44 if @ip_list.find {|ip| ip.include? req_ip }
|
645
|
+
</span><span class="marked1"><a name="line45"></a>45 return @app.call(env)
|
646
|
+
</span><span class="inferred0"><a name="line46"></a>46 end
|
647
|
+
</span><span class="inferred1"><a name="line47"></a>47 else
|
648
|
+
</span><span class="marked0"><a name="line48"></a>48 if @cond && @cond.call(req_ip)
|
649
|
+
</span><span class="uncovered1"><a name="line49"></a>49 return @app.call(env)
|
650
|
+
</span><span class="uncovered0"><a name="line50"></a>50 end
|
651
|
+
</span><span class="uncovered1"><a name="line51"></a>51 end
|
652
|
+
</span><span class="marked0"><a name="line52"></a>52 return [403, {'Content-Type' => 'text/plain' }, 'Forbidden' ]
|
653
|
+
</span><span class="inferred1"><a name="line53"></a>53 end
|
654
|
+
</span><span class="inferred0"><a name="line54"></a>54 end
|
655
|
+
</span><span class="inferred1"><a name="line55"></a>55 end
|
656
|
+
</span><span class="inferred0"><a name="line56"></a>56 end
|
645
657
|
</span></pre><hr/>
|
646
658
|
<p>Generated using the <a href='http://eigenclass.org/hiki.rb?rcov'>rcov code coverage analysis tool for Ruby</a>
|
647
659
|
version 0.8.1.2.</p>
|
data/lib/rack/auth/ip.rb
CHANGED
@@ -1,6 +1,16 @@
|
|
1
1
|
require 'ipaddr'
|
2
2
|
module Rack
|
3
3
|
module Auth
|
4
|
+
# in your_app.ru
|
5
|
+
# require 'rack/auth/ip'
|
6
|
+
# # allow access only local network
|
7
|
+
# use Rack::Auth::IP, %w( 192.168.0.0/24 )
|
8
|
+
|
9
|
+
# # you can use block
|
10
|
+
# # ip is IPAddr instance.
|
11
|
+
# use Rack::Auth::IP do |ip|
|
12
|
+
# Your::Model::IP.count({ :ip => ip.to_s }) != 0
|
13
|
+
# end
|
4
14
|
class IP
|
5
15
|
module Util
|
6
16
|
# consider using reverse proxy
|
@@ -16,13 +26,15 @@ module Rack
|
|
16
26
|
end
|
17
27
|
include Util
|
18
28
|
|
19
|
-
def initialize app, ip_list=nil
|
29
|
+
def initialize app, ip_list=nil, &block
|
20
30
|
@app = app
|
21
31
|
@ip_list = ip_list
|
22
32
|
|
23
33
|
if @ip_list
|
24
34
|
@ip_list = @ip_list.map {|ip| IPAddr.new(ip) }
|
25
35
|
end
|
36
|
+
|
37
|
+
@cond = block
|
26
38
|
end
|
27
39
|
|
28
40
|
def call env
|
@@ -33,7 +45,7 @@ module Rack
|
|
33
45
|
return @app.call(env)
|
34
46
|
end
|
35
47
|
else
|
36
|
-
if
|
48
|
+
if @cond && @cond.call(req_ip)
|
37
49
|
return @app.call(env)
|
38
50
|
end
|
39
51
|
end
|
data/spec/rack-auth-ip_spec.rb
CHANGED
@@ -34,21 +34,16 @@ describe Rack::Auth::IP do
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
describe 'when
|
37
|
+
describe 'when with block' do
|
38
38
|
before do
|
39
39
|
@env = { "REMOTE_ADDR" => '127.0.0.1' }
|
40
40
|
@app = proc {|env| env }
|
41
|
-
@auth_ip = Rack::Auth::IP.new(@app)
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'should raise LocalJumpError without block' do
|
45
|
-
lambda { @auth_ip.call(@env) }.should raise_error(LocalJumpError)
|
46
41
|
end
|
47
42
|
|
48
43
|
it 'should recieve IPAddr instance in block' do
|
49
|
-
|
44
|
+
Rack::Auth::IP.new(@app) {|ip|
|
50
45
|
ip.should == IPAddr.new(@env["REMOTE_ADDR"])
|
51
|
-
|
46
|
+
}.call(@env)
|
52
47
|
end
|
53
48
|
end
|
54
49
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-auth-ip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keiji, Yoshimi
|
@@ -9,7 +9,7 @@ autorequire: ""
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-06-28 00:00:00 +09:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -51,7 +51,6 @@ files:
|
|
51
51
|
- doc/output/coverage/-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-drb-drb_rb.html
|
52
52
|
- doc/output/coverage/-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-drb-eq_rb.html
|
53
53
|
- doc/output/coverage/-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-drb-invokemethod_rb.html
|
54
|
-
- doc/output/coverage/-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-forwardable_rb.html
|
55
54
|
- doc/output/coverage/-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-ipaddr_rb.html
|
56
55
|
- doc/output/coverage/-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-pp_rb.html
|
57
56
|
- doc/output/coverage/-System-Library-Frameworks-Ruby_framework-Versions-1_8-usr-lib-ruby-1_8-prettyprint_rb.html
|