warden 0.10.0 → 0.10.1
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/lib/warden/manager.rb +24 -22
- data/lib/warden/version.rb +1 -1
- data/spec/warden/manager_spec.rb +11 -0
- data/warden.gemspec +2 -2
- metadata +3 -3
data/lib/warden/manager.rb
CHANGED
@@ -40,14 +40,13 @@ module Warden
|
|
40
40
|
result ||= {}
|
41
41
|
case result
|
42
42
|
when Array
|
43
|
-
if result.first == 401
|
44
|
-
process_unauthenticated(
|
43
|
+
if result.first == 401 && !env['warden'].custom_failure?
|
44
|
+
process_unauthenticated(env)
|
45
45
|
else
|
46
46
|
result
|
47
47
|
end
|
48
48
|
when Hash
|
49
|
-
result
|
50
|
-
process_unauthenticated(result, env)
|
49
|
+
process_unauthenticated(env, result || {})
|
51
50
|
end
|
52
51
|
end
|
53
52
|
|
@@ -87,30 +86,33 @@ module Warden
|
|
87
86
|
# When a request is unauthentiated, here's where the processing occurs.
|
88
87
|
# It looks at the result of the proxy to see if it's been executed and what action to take.
|
89
88
|
# :api: private
|
90
|
-
def process_unauthenticated(
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
89
|
+
def process_unauthenticated(env, options={})
|
90
|
+
options[:action] ||= :unauthenticated
|
91
|
+
|
92
|
+
proxy = env['warden']
|
93
|
+
result = options[:result] || proxy.result
|
94
|
+
|
95
|
+
case result
|
96
|
+
when :redirect
|
97
|
+
body = proxy.message || "You are being redirected to #{proxy.headers['Location']}"
|
98
|
+
[proxy.status, proxy.headers, [body]]
|
99
|
+
when :custom
|
100
|
+
proxy.custom_response
|
101
|
+
else
|
102
|
+
call_failure_app(env, options)
|
100
103
|
end
|
101
104
|
end
|
102
105
|
|
103
106
|
# Calls the failure app.
|
104
107
|
# The before_failure hooks are run on each failure
|
105
108
|
# :api: private
|
106
|
-
def call_failure_app(env,
|
107
|
-
if
|
108
|
-
|
109
|
-
|
110
|
-
env["
|
111
|
-
|
112
|
-
|
113
|
-
_run_callbacks(:before_failure, env, opts)
|
109
|
+
def call_failure_app(env, options = {})
|
110
|
+
if config.failure_app
|
111
|
+
options.merge!(:attempted_path => ::Rack::Request.new(env).fullpath)
|
112
|
+
env["PATH_INFO"] = "/#{options[:action]}"
|
113
|
+
env["warden.options"] = options
|
114
|
+
|
115
|
+
_run_callbacks(:before_failure, env, options)
|
114
116
|
config.failure_app.call(env).to_a
|
115
117
|
else
|
116
118
|
raise "No Failure App provided"
|
data/lib/warden/version.rb
CHANGED
data/spec/warden/manager_spec.rb
CHANGED
@@ -69,6 +69,17 @@ describe Warden::Manager do
|
|
69
69
|
result.first.should == 401
|
70
70
|
result.last.should == ["You Fail!"]
|
71
71
|
end
|
72
|
+
|
73
|
+
it "should set the attempted url in warden.options hash" do
|
74
|
+
env = env_with_params("/access/path", {})
|
75
|
+
app = lambda do |env|
|
76
|
+
env['warden'].authenticate(:pass)
|
77
|
+
throw(:warden)
|
78
|
+
end
|
79
|
+
result = setup_rack(app, :failure_app => @fail_app).call(env)
|
80
|
+
result.first.should == 401
|
81
|
+
env["warden.options"][:attempted_path].should == "/access/path"
|
82
|
+
end
|
72
83
|
end # failure
|
73
84
|
|
74
85
|
end
|
data/warden.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{warden}
|
8
|
-
s.version = "0.10.
|
8
|
+
s.version = "0.10.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Daniel Neighman"]
|
12
|
-
s.date = %q{2010-03-
|
12
|
+
s.date = %q{2010-03-23}
|
13
13
|
s.email = %q{has.sox@gmail.com}
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"LICENSE",
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 10
|
8
|
-
-
|
9
|
-
version: 0.10.
|
8
|
+
- 1
|
9
|
+
version: 0.10.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Daniel Neighman
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-03-
|
17
|
+
date: 2010-03-23 00:00:00 +11:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|