hassox-warden 0.2.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/lib/warden/manager.rb +10 -6
- data/lib/warden/proxy.rb +13 -0
- data/spec/warden/manager_spec.rb +23 -1
- data/spec/warden/proxy_spec.rb +2 -0
- data/spec/warden/strategies/failz.rb +1 -1
- data/warden.gemspec +3 -2
- metadata +3 -3
data/Rakefile
CHANGED
@@ -17,6 +17,7 @@ begin
|
|
17
17
|
gem.email = EMAIL
|
18
18
|
gem.homepage = HOMEPAGE
|
19
19
|
gem.authors = AUTHORS
|
20
|
+
gem.rubyforge_project = "warden"
|
20
21
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
21
22
|
|
22
23
|
gem.add_dependency "rack", ">= 1.0.0"
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/lib/warden/manager.rb
CHANGED
@@ -47,7 +47,7 @@ module Warden
|
|
47
47
|
if result.first != 401
|
48
48
|
return result
|
49
49
|
else
|
50
|
-
call_failure_app(env)
|
50
|
+
call_failure_app(env, :original_response => result)
|
51
51
|
end
|
52
52
|
when Hash
|
53
53
|
if (result[:action] ||= :unauthenticated) == :unauthenticated
|
@@ -122,13 +122,17 @@ module Warden
|
|
122
122
|
# The before_failure hooks are run on each failure
|
123
123
|
# :api: private
|
124
124
|
def call_failure_app(env, opts = {})
|
125
|
-
env[
|
126
|
-
|
125
|
+
if env['warden'].custom_failure?
|
126
|
+
opts[:original_response]
|
127
|
+
else
|
128
|
+
env["PATH_INFO"] = "/#{opts[:action]}"
|
129
|
+
env["warden.options"] = opts
|
127
130
|
|
128
|
-
|
129
|
-
|
131
|
+
# Call the before failure callbacks
|
132
|
+
Warden::Manager._before_failure.each{|hook| hook.call(env,opts)}
|
130
133
|
|
131
|
-
|
134
|
+
@failure_app.call(env).to_a
|
135
|
+
end
|
132
136
|
end # call_failure_app
|
133
137
|
end
|
134
138
|
end # Warden
|
data/lib/warden/proxy.rb
CHANGED
@@ -155,6 +155,19 @@ module Warden
|
|
155
155
|
winning_strategy.nil? ? nil : winning_strategy.result
|
156
156
|
end
|
157
157
|
|
158
|
+
# Provides a way to return a 401 without warden defering to the failure app
|
159
|
+
# The result is a direct passthrough of your own response
|
160
|
+
# :api: public
|
161
|
+
def custom_failure!
|
162
|
+
@custom_failure = true
|
163
|
+
end
|
164
|
+
|
165
|
+
# Check to see if the custom failur flag has been set
|
166
|
+
# :api: public
|
167
|
+
def custom_failure?
|
168
|
+
!!@custom_failure
|
169
|
+
end
|
170
|
+
|
158
171
|
private
|
159
172
|
# :api: private
|
160
173
|
def _perform_authentication(*args)
|
data/spec/warden/manager_spec.rb
CHANGED
@@ -23,7 +23,7 @@ describe Warden::Manager do
|
|
23
23
|
if e['warden'].authenticated?
|
24
24
|
[200,{'Content-Type' => 'text/plain'},"OK"]
|
25
25
|
else
|
26
|
-
[401,{'Content-Type' => 'text/plain'},"
|
26
|
+
[401,{'Content-Type' => 'text/plain'},"Fail From The App"]
|
27
27
|
end
|
28
28
|
end
|
29
29
|
@env = Rack::MockRequest.
|
@@ -125,6 +125,27 @@ describe Warden::Manager do
|
|
125
125
|
result[2].should == ["You Fail!"]
|
126
126
|
env['PATH_INFO'].should == "/unauthenticated"
|
127
127
|
end
|
128
|
+
|
129
|
+
it "should allow you to customize the response" do
|
130
|
+
app = lambda do |e|
|
131
|
+
e['warden'].custom_failure!
|
132
|
+
[401,{'Content-Type' => 'text/plain'},["Fail From The App"]]
|
133
|
+
end
|
134
|
+
env = env_with_params
|
135
|
+
result = setup_rack(app).call(env)
|
136
|
+
result[0].should == 401
|
137
|
+
result[2].should == ["Fail From The App"]
|
138
|
+
end
|
139
|
+
|
140
|
+
it "should render the failure application for a 401 if no custom_failure flag is set" do
|
141
|
+
app = lambda do |e|
|
142
|
+
[401,{'Content-Type' => 'text/plain'},["Fail From The App"]]
|
143
|
+
end
|
144
|
+
result = setup_rack(app).call(env_with_params)
|
145
|
+
result[0].should == 401
|
146
|
+
result[2].should == ["You Fail!"]
|
147
|
+
end
|
148
|
+
|
128
149
|
end # failing
|
129
150
|
|
130
151
|
describe "custom rack response" do
|
@@ -155,4 +176,5 @@ describe Warden::Manager do
|
|
155
176
|
end
|
156
177
|
end
|
157
178
|
end # integrated strategies
|
179
|
+
|
158
180
|
end
|
data/spec/warden/proxy_spec.rb
CHANGED
data/warden.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{warden}
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.3.0"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Daniel Neighman"]
|
9
|
-
s.date = %q{2009-07-
|
9
|
+
s.date = %q{2009-07-12}
|
10
10
|
s.email = %q{has.sox@gmail.com}
|
11
11
|
s.extra_rdoc_files = [
|
12
12
|
"LICENSE",
|
@@ -49,6 +49,7 @@ Gem::Specification.new do |s|
|
|
49
49
|
s.homepage = %q{http://github.com/hassox/warden}
|
50
50
|
s.rdoc_options = ["--charset=UTF-8"]
|
51
51
|
s.require_paths = ["lib"]
|
52
|
+
s.rubyforge_project = %q{warden}
|
52
53
|
s.rubygems_version = %q{1.3.3}
|
53
54
|
s.summary = %q{Rack middleware that provides authentication for rack applications}
|
54
55
|
s.test_files = [
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hassox-warden
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Neighman
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-07-
|
12
|
+
date: 2009-07-12 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -85,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
85
|
version:
|
86
86
|
requirements: []
|
87
87
|
|
88
|
-
rubyforge_project:
|
88
|
+
rubyforge_project: warden
|
89
89
|
rubygems_version: 1.2.0
|
90
90
|
signing_key:
|
91
91
|
specification_version: 3
|