warden 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/History.rdoc +5 -0
- data/lib/warden/proxy.rb +20 -5
- data/lib/warden/version.rb +1 -1
- data/spec/helpers/request_helper.rb +1 -1
- data/spec/warden/proxy_spec.rb +57 -1
- data/warden.gemspec +1 -1
- metadata +7 -5
data/Gemfile.lock
CHANGED
data/History.rdoc
CHANGED
@@ -1,7 +1,12 @@
|
|
1
|
+
== Version 1.1.1 / 2012-02-16
|
2
|
+
* Allow run_callbacks as an option to set_user and user
|
3
|
+
|
1
4
|
== Version 1.1.0 / 2011-11-02
|
2
5
|
* Use the default scopes action when using a bare throw(:warden)
|
6
|
+
|
3
7
|
== Version 1.0.6
|
4
8
|
* Remove gem files from the packaged gem
|
9
|
+
|
5
10
|
== Version 1.0.3
|
6
11
|
* Do not renew session on user fetch
|
7
12
|
|
data/lib/warden/proxy.rb
CHANGED
@@ -144,7 +144,7 @@ module Warden
|
|
144
144
|
#
|
145
145
|
# Parameters:
|
146
146
|
# user - An object that has been setup to serialize into and out of the session.
|
147
|
-
# opts - An options hash. Use the :scope option to set the scope of the user, set the :store option to false to skip serializing into the session.
|
147
|
+
# opts - An options hash. Use the :scope option to set the scope of the user, set the :store option to false to skip serializing into the session, set the :run_callbacks to false to skip running the callbacks (the default is true).
|
148
148
|
#
|
149
149
|
# :api: public
|
150
150
|
def set_user(user, opts = {})
|
@@ -161,7 +161,9 @@ module Warden
|
|
161
161
|
session_serializer.store(user, scope)
|
162
162
|
end
|
163
163
|
|
164
|
-
|
164
|
+
run_callbacks = opts.fetch(:run_callbacks, true)
|
165
|
+
manager._run_callbacks(:after_set_user, user, self, opts) if run_callbacks
|
166
|
+
|
165
167
|
@users[scope]
|
166
168
|
end
|
167
169
|
|
@@ -176,11 +178,24 @@ module Warden
|
|
176
178
|
# # with scope
|
177
179
|
# env['warden'].user(:admin)
|
178
180
|
#
|
181
|
+
# # as a Hash
|
182
|
+
# env['warden'].user(:scope => :admin)
|
183
|
+
#
|
184
|
+
# # with default scope and run_callbacks option
|
185
|
+
# env['warden'].user(:run_callbacks => false)
|
186
|
+
#
|
187
|
+
# # with a scope and run_callbacks option
|
188
|
+
# env['warden'].user(:scope => :admin, :run_callbacks => true)
|
189
|
+
#
|
179
190
|
# :api: public
|
180
|
-
def user(
|
191
|
+
def user(argument = {})
|
192
|
+
opts = argument.is_a?(Hash) ? argument : { :scope => argument }
|
193
|
+
scope = (opts[:scope] ||= @config.default_scope)
|
194
|
+
|
181
195
|
@users[scope] ||= begin
|
182
196
|
user = session_serializer.fetch(scope)
|
183
|
-
|
197
|
+
opts[:event] = :fetch
|
198
|
+
set_user(user, opts) if user
|
184
199
|
end
|
185
200
|
end
|
186
201
|
|
@@ -323,6 +338,6 @@ module Warden
|
|
323
338
|
raise "Invalid strategy #{name}"
|
324
339
|
end
|
325
340
|
end
|
326
|
-
|
327
341
|
end # Proxy
|
342
|
+
|
328
343
|
end # Warden
|
data/lib/warden/version.rb
CHANGED
@@ -15,7 +15,7 @@ module Warden::Spec
|
|
15
15
|
opts[:failure_app] ||= failure_app
|
16
16
|
opts[:default_strategies] ||= [:password]
|
17
17
|
opts[:default_serializers] ||= [:session]
|
18
|
-
blk = opts[:configurator] ||
|
18
|
+
blk = opts[:configurator] || proc{}
|
19
19
|
|
20
20
|
Rack::Builder.new do
|
21
21
|
use opts[:session] || Warden::Spec::Helpers::Session
|
data/spec/warden/proxy_spec.rb
CHANGED
@@ -365,6 +365,33 @@ describe Warden::Proxy do
|
|
365
365
|
end
|
366
366
|
setup_rack(app).call(@env)
|
367
367
|
end
|
368
|
+
|
369
|
+
it "should not run the callbacks when :run_callbacks is false" do
|
370
|
+
app = lambda do |env|
|
371
|
+
env['warden'].manager.should_not_receive(:_run_callbacks)
|
372
|
+
env['warden'].authenticate(:run_callbacks => false, :scope => :pass)
|
373
|
+
valid_response
|
374
|
+
end
|
375
|
+
setup_rack(app).call(@env)
|
376
|
+
end
|
377
|
+
|
378
|
+
it "should run the callbacks when :run_callbacks is true" do
|
379
|
+
app = lambda do |env|
|
380
|
+
env['warden'].manager.should_receive(:_run_callbacks)
|
381
|
+
env['warden'].authenticate(:pass)
|
382
|
+
valid_response
|
383
|
+
end
|
384
|
+
setup_rack(app).call(@env)
|
385
|
+
end
|
386
|
+
|
387
|
+
it "should run the callbacks by default" do
|
388
|
+
app = lambda do |env|
|
389
|
+
env['warden'].manager.should_receive(:_run_callbacks)
|
390
|
+
env['warden'].authenticate(:pass)
|
391
|
+
valid_response
|
392
|
+
end
|
393
|
+
setup_rack(app).call(@env)
|
394
|
+
end
|
368
395
|
end
|
369
396
|
|
370
397
|
describe "get user" do
|
@@ -412,6 +439,35 @@ describe Warden::Proxy do
|
|
412
439
|
setup_rack(app).call(@env)
|
413
440
|
@env['warden.spec.strategies'].should_not include(:pass)
|
414
441
|
end
|
442
|
+
|
443
|
+
describe "run callback option" do
|
444
|
+
it "should not call run_callbacks when we pass a :run_callback => false" do
|
445
|
+
app = lambda do |env|
|
446
|
+
env['warden'].manager.should_not_receive(:_run_callbacks)
|
447
|
+
env['warden'].user(:run_callbacks => false)
|
448
|
+
valid_response
|
449
|
+
end
|
450
|
+
setup_rack(app).call(@env)
|
451
|
+
end
|
452
|
+
|
453
|
+
it "should call run_callbacks when we pass a :run_callback => true" do
|
454
|
+
app = lambda do |env|
|
455
|
+
env['warden'].manager.should_receive(:_run_callbacks)
|
456
|
+
env['warden'].user(:run_callbacks => true)
|
457
|
+
valid_response
|
458
|
+
end
|
459
|
+
setup_rack(app).call(@env)
|
460
|
+
end
|
461
|
+
|
462
|
+
it "should call run_callbacks by default" do
|
463
|
+
app = lambda do |env|
|
464
|
+
env['warden'].manager.should_receive(:_run_callbacks)
|
465
|
+
env['warden'].user
|
466
|
+
valid_response
|
467
|
+
end
|
468
|
+
setup_rack(app).call(@env)
|
469
|
+
end
|
470
|
+
end
|
415
471
|
end
|
416
472
|
end
|
417
473
|
|
@@ -900,4 +956,4 @@ describe "dynamic default_strategies" do
|
|
900
956
|
session['warden.user.baz.key'].should == "User"
|
901
957
|
end
|
902
958
|
end
|
903
|
-
end
|
959
|
+
end
|
data/warden.gemspec
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: warden
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 1.1.
|
9
|
+
- 1
|
10
|
+
version: 1.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Daniel Neighman
|
@@ -15,7 +15,8 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-07-27 00:00:00
|
18
|
+
date: 2011-07-27 00:00:00 +02:00
|
19
|
+
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
name: rack
|
@@ -82,6 +83,7 @@ files:
|
|
82
83
|
- spec/warden/test/test_mode_spec.rb
|
83
84
|
- TODO.textile
|
84
85
|
- warden.gemspec
|
86
|
+
has_rdoc: true
|
85
87
|
homepage: http://github.com/hassox/warden
|
86
88
|
licenses: []
|
87
89
|
|
@@ -111,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
113
|
requirements: []
|
112
114
|
|
113
115
|
rubyforge_project: warden
|
114
|
-
rubygems_version: 1.
|
116
|
+
rubygems_version: 1.5.3
|
115
117
|
signing_key:
|
116
118
|
specification_version: 3
|
117
119
|
summary: Rack middleware that provides authentication for rack applications
|