rack-private 0.1.7 → 0.1.8
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.markdown +18 -2
- data/lib/rack/private.rb +7 -1
- data/lib/rack/private/version.rb +1 -1
- metadata +3 -5
data/README.markdown
CHANGED
@@ -28,7 +28,23 @@ And provide your own template.
|
|
28
28
|
use Rack::Private :code => 'secret', :template_path => Rails.root.join("app/templates/private.html")
|
29
29
|
```
|
30
30
|
|
31
|
-
|
31
|
+
You can specify exceptions, using strings or regular expressions
|
32
|
+
|
33
|
+
``` ruby
|
34
|
+
use Rack::Private :code => 'secret', :except => ["public"]
|
35
|
+
```
|
36
|
+
|
37
|
+
This will allow access to *any* URL containing 'public'. If you want more control, use a regular expression:
|
38
|
+
|
39
|
+
``` ruby
|
40
|
+
use Rack::Private :code => 'secret', :except => [/public$/]
|
41
|
+
```
|
42
|
+
|
43
|
+
This will only allow access to URLs that *end* in 'public'. You can use any expressions you want.
|
44
|
+
|
45
|
+
|
46
|
+
Note on Patches/Pull Requests
|
47
|
+
-----------------------------
|
32
48
|
|
33
49
|
* Fork the project.
|
34
50
|
* Make your feature addition or bug fix.
|
@@ -39,4 +55,4 @@ use Rack::Private :code => 'secret', :template_path => Rails.root.join("app/temp
|
|
39
55
|
Author
|
40
56
|
------
|
41
57
|
|
42
|
-
*
|
58
|
+
* [Thibaud Guillaume-Gentil](http://github.com/thibaudgg)
|
data/lib/rack/private.rb
CHANGED
@@ -10,7 +10,7 @@ module Rack
|
|
10
10
|
request = Rack::Request.new(env)
|
11
11
|
|
12
12
|
# Check code in session and return Rails call if is valid
|
13
|
-
return @app.call(env) if already_auth?(request)
|
13
|
+
return @app.call(env) if (already_auth?(request) || public_page?(request))
|
14
14
|
|
15
15
|
# If post method check :code_param value
|
16
16
|
if request.post? && code_valid?(request.params["private_code"])
|
@@ -42,6 +42,12 @@ module Rack
|
|
42
42
|
def already_auth?(request)
|
43
43
|
code_valid?(request.session[:private_code])
|
44
44
|
end
|
45
|
+
|
46
|
+
# Checks if the url matches one of our exception strings or regexs
|
47
|
+
def public_page?(request)
|
48
|
+
@options[:except] && @options[:except].find {|x| request.url.match(x)}
|
49
|
+
end
|
50
|
+
|
45
51
|
end
|
46
52
|
end
|
47
53
|
|
data/lib/rack/private/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: rack-private
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.8
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Thibaud Guillaume-Gentil
|
@@ -10,8 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
14
|
-
default_executable:
|
13
|
+
date: 2011-05-06 00:00:00 Z
|
15
14
|
dependencies:
|
16
15
|
- !ruby/object:Gem::Dependency
|
17
16
|
name: bundler
|
@@ -73,7 +72,6 @@ files:
|
|
73
72
|
- lib/rack-private.rb
|
74
73
|
- LICENSE
|
75
74
|
- README.markdown
|
76
|
-
has_rdoc: true
|
77
75
|
homepage: http://github.com/thibaudgg/rack-private
|
78
76
|
licenses: []
|
79
77
|
|
@@ -97,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
95
|
requirements: []
|
98
96
|
|
99
97
|
rubyforge_project: rack-private
|
100
|
-
rubygems_version: 1.
|
98
|
+
rubygems_version: 1.8.1
|
101
99
|
signing_key:
|
102
100
|
specification_version: 3
|
103
101
|
summary: Protect your Rack application from anonymous.
|