warden 0.6.0 → 0.6.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/proxy.rb +5 -4
- data/lib/warden/strategies/base.rb +4 -4
- data/lib/warden/version.rb +1 -1
- data/spec/warden/hooks_spec.rb +6 -1
- data/spec/warden/proxy_spec.rb +1 -2
- data/spec/warden/serializers_spec.rb +14 -8
- data/warden.gemspec +11 -11
- metadata +10 -10
data/lib/warden/proxy.rb
CHANGED
@@ -111,10 +111,11 @@ module Warden
|
|
111
111
|
def set_user(user, opts = {})
|
112
112
|
scope = (opts[:scope] ||= :default)
|
113
113
|
_store_user(user, scope) unless opts[:store] == false
|
114
|
+
@users[scope] = user
|
114
115
|
|
115
116
|
# Run the after hooks for setting the user
|
116
117
|
Warden::Manager._after_set_user.each{ |hook| hook.call(user, self, opts) }
|
117
|
-
|
118
|
+
user
|
118
119
|
end
|
119
120
|
|
120
121
|
# Provides acccess to the user object in a given scope for a request.
|
@@ -185,13 +186,13 @@ module Warden
|
|
185
186
|
# proxy methods through to the winning strategy
|
186
187
|
# :api: private
|
187
188
|
def result # :nodoc:
|
188
|
-
winning_strategy
|
189
|
+
winning_strategy && winning_strategy.result
|
189
190
|
end
|
190
191
|
|
191
192
|
# Proxy through to the authentication strategy to find out the message that was generated.
|
192
193
|
# :api: public
|
193
194
|
def message
|
194
|
-
winning_strategy
|
195
|
+
winning_strategy && winning_strategy.message
|
195
196
|
end
|
196
197
|
|
197
198
|
# Provides a way to return a 401 without warden defering to the failure app
|
@@ -243,7 +244,7 @@ module Warden
|
|
243
244
|
next
|
244
245
|
end
|
245
246
|
|
246
|
-
strategy = Warden::Strategies[s].new(@env, scope
|
247
|
+
strategy = Warden::Strategies[s].new(@env, scope)
|
247
248
|
self.winning_strategy = strategy
|
248
249
|
next unless strategy.valid?
|
249
250
|
|
@@ -44,9 +44,9 @@ module Warden
|
|
44
44
|
include ::Warden::Mixins::Common
|
45
45
|
|
46
46
|
# :api: private
|
47
|
-
def initialize(env, scope=nil
|
48
|
-
@
|
49
|
-
@
|
47
|
+
def initialize(env, scope=nil) # :nodoc:
|
48
|
+
@env, @scope = env, scope
|
49
|
+
@_status, @headers = nil, {}
|
50
50
|
@halted = false
|
51
51
|
end
|
52
52
|
|
@@ -132,7 +132,7 @@ module Warden
|
|
132
132
|
headers["Location"] << "?" << Rack::Utils.build_query(params) unless params.empty?
|
133
133
|
headers["Content-Type"] = opts[:content_type] || 'text/plain'
|
134
134
|
|
135
|
-
@message = opts[:message]
|
135
|
+
@message = opts[:message] || "You are being redirected to #{headers["Location"]}"
|
136
136
|
@result = :redirect
|
137
137
|
|
138
138
|
headers["Location"]
|
data/lib/warden/version.rb
CHANGED
data/spec/warden/hooks_spec.rb
CHANGED
@@ -32,9 +32,14 @@ describe "standard authentication hooks" do
|
|
32
32
|
it "should run each after_set_user hook after the user is set" do
|
33
33
|
RAM.after_set_user{|u,a,o| a.env['warden.spec.hook.foo'] = "run foo"}
|
34
34
|
RAM.after_set_user{|u,a,o| a.env['warden.spec.hook.bar'] = "run bar"}
|
35
|
-
|
35
|
+
RAM.after_set_user{|u,a,o| a.logout}
|
36
|
+
app = lambda do |e|
|
37
|
+
e['warden'].set_user("foo")
|
38
|
+
valid_response
|
39
|
+
end
|
36
40
|
env = env_with_params
|
37
41
|
setup_rack(app).call(env)
|
42
|
+
env['warden'].user.should be_nil
|
38
43
|
env['warden.spec.hook.foo'].should == "run foo"
|
39
44
|
env['warden.spec.hook.bar'].should == "run bar"
|
40
45
|
end
|
data/spec/warden/proxy_spec.rb
CHANGED
@@ -421,7 +421,6 @@ describe Warden::Proxy do
|
|
421
421
|
end
|
422
422
|
|
423
423
|
describe "messages" do
|
424
|
-
|
425
424
|
it "should allow access to the failure message" do
|
426
425
|
failure = lambda do |e|
|
427
426
|
[401, {"Content-Type" => "text/plain"}, [e['warden'].message]]
|
@@ -438,7 +437,7 @@ describe Warden::Proxy do
|
|
438
437
|
[200, {"Content-Type" => "text/plain"}, [e['warden'].message]]
|
439
438
|
end
|
440
439
|
result = setup_rack(app).call(env_with_params)
|
441
|
-
result[2].should == [
|
440
|
+
result[2].should == [nil]
|
442
441
|
end
|
443
442
|
end
|
444
443
|
|
@@ -83,14 +83,20 @@ describe Warden::Serializers do
|
|
83
83
|
end
|
84
84
|
|
85
85
|
it "should allow me to clear the Serializers" do
|
86
|
-
Warden::Serializers.
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
86
|
+
old_serializers = Warden::Serializers._serializers.dup
|
87
|
+
|
88
|
+
begin
|
89
|
+
Warden::Serializers.add(:foobar) do
|
90
|
+
def fetch; end
|
91
|
+
def store; end
|
92
|
+
def stored?; end
|
93
|
+
def delete; end
|
94
|
+
end
|
95
|
+
Warden::Serializers[:foobar].should_not be_nil
|
96
|
+
Warden::Serializers.clear!
|
97
|
+
Warden::Serializers[:foobar].should be_nil
|
98
|
+
else
|
99
|
+
Warden::Serializers._serializers.replace(old_serializers)
|
91
100
|
end
|
92
|
-
Warden::Serializers[:foobar].should_not be_nil
|
93
|
-
Warden::Serializers.clear!
|
94
|
-
Warden::Serializers[:foobar].should be_nil
|
95
101
|
end
|
96
102
|
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.6.
|
8
|
+
s.version = "0.6.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{2009-11-
|
12
|
+
s.date = %q{2009-11-17}
|
13
13
|
s.email = %q{has.sox@gmail.com}
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"LICENSE",
|
@@ -65,24 +65,24 @@ Gem::Specification.new do |s|
|
|
65
65
|
s.rubygems_version = %q{1.3.5}
|
66
66
|
s.summary = %q{Rack middleware that provides authentication for rack applications}
|
67
67
|
s.test_files = [
|
68
|
-
"spec/
|
69
|
-
"spec/helpers/strategies/failz.rb",
|
68
|
+
"spec/warden_spec.rb",
|
70
69
|
"spec/helpers/strategies/invalid.rb",
|
70
|
+
"spec/helpers/strategies/failz.rb",
|
71
71
|
"spec/helpers/strategies/pass.rb",
|
72
|
-
"spec/helpers/strategies/pass_without_user.rb",
|
73
72
|
"spec/helpers/strategies/password.rb",
|
73
|
+
"spec/helpers/strategies/pass_without_user.rb",
|
74
|
+
"spec/helpers/request_helper.rb",
|
74
75
|
"spec/spec_helper.rb",
|
75
|
-
"spec/warden/
|
76
|
-
"spec/warden/errors_spec.rb",
|
76
|
+
"spec/warden/strategies/base_spec.rb",
|
77
77
|
"spec/warden/hooks_spec.rb",
|
78
78
|
"spec/warden/manager_spec.rb",
|
79
|
-
"spec/warden/
|
79
|
+
"spec/warden/authenticated_data_store_spec.rb",
|
80
|
+
"spec/warden/errors_spec.rb",
|
80
81
|
"spec/warden/serializers/cookie_spec.rb",
|
81
82
|
"spec/warden/serializers/session_spec.rb",
|
82
83
|
"spec/warden/serializers_spec.rb",
|
83
|
-
"spec/warden/
|
84
|
-
"spec/warden/strategies_spec.rb"
|
85
|
-
"spec/warden_spec.rb"
|
84
|
+
"spec/warden/proxy_spec.rb",
|
85
|
+
"spec/warden/strategies_spec.rb"
|
86
86
|
]
|
87
87
|
|
88
88
|
if s.respond_to? :specification_version then
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: warden
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
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-11-
|
12
|
+
date: 2009-11-17 00:00:00 -02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -102,21 +102,21 @@ signing_key:
|
|
102
102
|
specification_version: 3
|
103
103
|
summary: Rack middleware that provides authentication for rack applications
|
104
104
|
test_files:
|
105
|
-
- spec/
|
106
|
-
- spec/helpers/strategies/failz.rb
|
105
|
+
- spec/warden_spec.rb
|
107
106
|
- spec/helpers/strategies/invalid.rb
|
107
|
+
- spec/helpers/strategies/failz.rb
|
108
108
|
- spec/helpers/strategies/pass.rb
|
109
|
-
- spec/helpers/strategies/pass_without_user.rb
|
110
109
|
- spec/helpers/strategies/password.rb
|
110
|
+
- spec/helpers/strategies/pass_without_user.rb
|
111
|
+
- spec/helpers/request_helper.rb
|
111
112
|
- spec/spec_helper.rb
|
112
|
-
- spec/warden/
|
113
|
-
- spec/warden/errors_spec.rb
|
113
|
+
- spec/warden/strategies/base_spec.rb
|
114
114
|
- spec/warden/hooks_spec.rb
|
115
115
|
- spec/warden/manager_spec.rb
|
116
|
-
- spec/warden/
|
116
|
+
- spec/warden/authenticated_data_store_spec.rb
|
117
|
+
- spec/warden/errors_spec.rb
|
117
118
|
- spec/warden/serializers/cookie_spec.rb
|
118
119
|
- spec/warden/serializers/session_spec.rb
|
119
120
|
- spec/warden/serializers_spec.rb
|
120
|
-
- spec/warden/
|
121
|
+
- spec/warden/proxy_spec.rb
|
121
122
|
- spec/warden/strategies_spec.rb
|
122
|
-
- spec/warden_spec.rb
|