warden 0.10.7 → 1.0.0

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/History.rdoc CHANGED
@@ -1,3 +1,26 @@
1
+ == Version 1.0.0
2
+ * Bump!
3
+ * Allow strategies to configure if user should be stored or not
4
+ * Force session id renewal when user is set
5
+
6
+ == Version 0.10.7
7
+ * Performance boost. config object to use raw accessors
8
+ * Add per strategy storage option
9
+
10
+ == Version 0.10.6 / 0.10.7 / 2010-05-22
11
+ * Bugfix set_user was not respecting logouts in hooks
12
+
13
+ == Version 0.10.4 / 0.10.5 / 2010-05-20
14
+ * Add action specifying in scope_defaults
15
+
16
+ == Version 0.10.3 / 2010-03-01
17
+ * Bugfix prevent halted winning strategy from being skipped in subsequent runs
18
+
19
+ == Version 0.10.2 / 2010-03-26
20
+ * Halt on fail!. Add fail to allow cascading
21
+ * cache the winning strategy
22
+ * Make the config object Dupable
23
+
1
24
  == Version 0.10.1 / 2010-03-23
2
25
  * Merge previous from master
3
26
  * tag
data/Rakefile CHANGED
@@ -15,7 +15,7 @@ begin
15
15
  gem.authors = ["Daniel Neighman"]
16
16
  gem.rubyforge_project = "warden"
17
17
  gem.add_dependency "rack", ">= 1.0.0"
18
- gem.add_development_dependency "rspec", ">= 1.0.0"
18
+ gem.add_development_dependency "rspec", "~>1"
19
19
  end
20
20
 
21
21
  Jeweler::GemcutterTasks.new
data/TODO.textile CHANGED
@@ -1,4 +1,2 @@
1
1
  * Allow a spec / test mode where a _spec_authenticate! method is called on a strategy instead if present
2
- * Implement back urls
3
- * Move all configuration to Warden::Config
4
- * Allow serializers to be chosen on storing/fetching/deleting
2
+ * Implement back urls
data/lib/warden/config.rb CHANGED
@@ -47,7 +47,7 @@ module Warden
47
47
  deep_dup(:default_strategies, other)
48
48
  end
49
49
 
50
- # Do not raise an error if a missing strategy is given by default.
50
+ # Do not raise an error if a missing strategy is given.
51
51
  # :api: plugin
52
52
  def silence_missing_strategies!
53
53
  self[:silence_missing_strategies] = true
data/lib/warden/errors.rb CHANGED
@@ -1,11 +1,6 @@
1
1
  # encoding: utf-8
2
2
  module Warden
3
3
  class Proxy
4
- # :api: public
5
- def errors
6
- @env['warden.errors'] ||= Errors.new
7
- end
8
-
9
4
  # Lifted from DataMapper's dm-validations plugin :)
10
5
  # @author Guy van den Berg
11
6
  # @since DM 0.9
data/lib/warden/hooks.rb CHANGED
@@ -170,7 +170,6 @@ module Warden
170
170
  @_on_request ||= []
171
171
  end
172
172
 
173
-
174
173
  # Add prepend filters version
175
174
  %w(after_set_user after_authentication after_fetch on_request
176
175
  before_failure before_logout).each do |filter|
data/lib/warden/proxy.rb CHANGED
@@ -15,6 +15,9 @@ module Warden
15
15
  extend ::Forwardable
16
16
  include ::Warden::Mixins::Common
17
17
 
18
+ ENV_WARDEN_ERRORS = 'warden.errors'.freeze
19
+ ENV_SESSION_OPTIONS = 'rack.session.options'.freeze
20
+
18
21
  # :api: private
19
22
  def_delegators :winning_strategy, :headers, :status, :custom_response
20
23
 
@@ -25,10 +28,15 @@ module Warden
25
28
  @env, @users, @winning_strategies = env, {}, {}
26
29
  @manager, @config = manager, manager.config.dup
27
30
  @strategies = Hash.new { |h,k| h[k] = {} }
28
- errors # setup the error object in the session
29
31
  manager._run_callbacks(:on_request, self)
30
32
  end
31
33
 
34
+ # Lazily initiate errors object in session.
35
+ # :api: public
36
+ def errors
37
+ @env[ENV_WARDEN_ERRORS] ||= Errors.new
38
+ end
39
+
32
40
  # Points to a SessionSerializer instance responsible for handling
33
41
  # everything related with storing, fetching and removing the user
34
42
  # session.
@@ -140,14 +148,17 @@ module Warden
140
148
  #
141
149
  # :api: public
142
150
  def set_user(user, opts = {})
143
- return unless user
144
151
  scope = (opts[:scope] ||= @config.default_scope)
145
152
 
146
153
  # Get the default options from the master configuration for the given scope
147
- opts = @config.scope_defaults(scope).merge(opts)
148
-
154
+ opts = (@config[:scope_defaults][scope] || {}).merge(opts)
149
155
  @users[scope] = user
150
- session_serializer.store(user, scope) unless opts[:store] == false
156
+
157
+ unless opts[:store] == false
158
+ options = env[ENV_SESSION_OPTIONS]
159
+ options[:renew] = true if options
160
+ session_serializer.store(user, scope)
161
+ end
151
162
 
152
163
  opts[:event] ||= :set_user
153
164
  manager._run_callbacks(:after_set_user, user, self, opts)
@@ -167,8 +178,10 @@ module Warden
167
178
  #
168
179
  # :api: public
169
180
  def user(scope = @config.default_scope)
170
- @users[scope] ||= set_user(session_serializer.fetch(scope),
171
- :scope => scope, :event => :fetch)
181
+ @users[scope] ||= begin
182
+ user = session_serializer.fetch(scope)
183
+ set_user(user, :scope => scope, :event => :fetch) if user
184
+ end
172
185
  end
173
186
 
174
187
  # Provides a scoped session data for authenticated users.
@@ -258,6 +271,7 @@ module Warden
258
271
  _run_strategies_for(scope, args)
259
272
 
260
273
  if winning_strategy && winning_strategy.user
274
+ opts[:store] = opts.fetch(:store, winning_strategy.store?)
261
275
  set_user(winning_strategy.user, opts.merge!(:event => :authentication))
262
276
  end
263
277
 
@@ -267,7 +281,7 @@ module Warden
267
281
  def _retrieve_scope_and_opts(args) #:nodoc:
268
282
  opts = args.last.is_a?(Hash) ? args.pop : {}
269
283
  scope = opts[:scope] || @config.default_scope
270
- opts = (config[:scope_defaults][scope] || {}).merge(opts)
284
+ opts = (@config[:scope_defaults][scope] || {}).merge(opts)
271
285
  [scope, opts]
272
286
  end
273
287
 
@@ -276,9 +290,12 @@ module Warden
276
290
  self.winning_strategy = @winning_strategies[scope]
277
291
  return if winning_strategy && winning_strategy.halted?
278
292
 
279
- strategies = args.empty? ? default_strategies(:scope => scope) : args
293
+ if args.empty?
294
+ defaults = @config[:default_strategies]
295
+ strategies = defaults[scope] || defaults[:_all]
296
+ end
280
297
 
281
- strategies.each do |name|
298
+ (strategies || args).each do |name|
282
299
  strategy = _fetch_strategy(name, scope)
283
300
  next unless strategy && !strategy.performed? && strategy.valid?
284
301
 
@@ -290,9 +307,7 @@ module Warden
290
307
 
291
308
  # Fetchs strategies and keep them in a hash cache.
292
309
  def _fetch_strategy(name, scope)
293
- return @strategies[scope][name] if @strategies[scope].key?(name)
294
-
295
- @strategies[scope][name] = if klass = Warden::Strategies[name]
310
+ @strategies[scope][name] ||= if klass = Warden::Strategies[name]
296
311
  klass.new(@env, scope)
297
312
  elsif @config.silence_missing_strategies?
298
313
  nil
@@ -98,6 +98,12 @@ module Warden
98
98
  !!@halted
99
99
  end
100
100
 
101
+ # Checks to see if a strategy should result in a permanent login
102
+ # :api: public
103
+ def store?
104
+ true
105
+ end
106
+
101
107
  # A simple method to return from authenticate! if you want to ignore this strategy
102
108
  # :api: public
103
109
  def pass; end
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module Warden
3
- VERSION = "0.10.7".freeze
3
+ VERSION = "1.0.0".freeze
4
4
  end
@@ -1,14 +1,12 @@
1
1
  # encoding: utf-8
2
2
  module Warden::Spec
3
3
  module Helpers
4
-
5
4
  FAILURE_APP = lambda{|e|[401, {"Content-Type" => "text/plain"}, ["You Fail!"]] }
6
5
 
7
- def env_with_params(path = "/", params = {})
8
- method = params.fetch(:method, "GET")
9
- Rack::MockRequest.env_for(path, :input => Rack::Utils.build_query(params),
10
- 'HTTP_VERSION' => '1.1',
11
- 'REQUEST_METHOD' => "#{method}")
6
+ def env_with_params(path = "/", params = {}, env = {})
7
+ method = params.delete(:method) || "GET"
8
+ env = { 'HTTP_VERSION' => '1.1', 'REQUEST_METHOD' => "#{method}" }.merge(env)
9
+ Rack::MockRequest.env_for("#{path}?#{Rack::Utils.build_query(params)}", env)
12
10
  end
13
11
 
14
12
  def setup_rack(app = nil, opts = {}, &block)
@@ -19,7 +17,7 @@ module Warden::Spec
19
17
  opts[:default_serializers] ||= [:session]
20
18
 
21
19
  Rack::Builder.new do
22
- use Warden::Spec::Helpers::Session
20
+ use opts[:session] || Warden::Spec::Helpers::Session
23
21
  use Warden::Manager, opts
24
22
  run app
25
23
  end
@@ -0,0 +1,12 @@
1
+ # encoding: utf-8
2
+ Warden::Strategies.add(:single) do
3
+ def authenticate!
4
+ request.env['warden.spec.strategies'] ||= []
5
+ request.env['warden.spec.strategies'] << :single
6
+ success!("Valid User")
7
+ end
8
+
9
+ def store?
10
+ false
11
+ end
12
+ end
@@ -17,8 +17,7 @@ describe Warden::Proxy do
17
17
  [401,{'Content-Type' => 'text/plain'},"You Fail"]
18
18
  end
19
19
  end
20
- @env = Rack::MockRequest.
21
- env_for('/', 'HTTP_VERSION' => '1.1', 'REQUEST_METHOD' => 'GET')
20
+ @env = env_with_params("/")
22
21
  end # before(:each)
23
22
 
24
23
  describe "authentication" do
@@ -70,39 +69,35 @@ describe Warden::Proxy do
70
69
  end
71
70
 
72
71
  it "should raise error on missing strategies" do
73
- env = env_with_params('/')
74
72
  app = lambda do |env|
75
73
  env['warden'].authenticate(:unknown)
76
74
  end
77
75
  lambda {
78
- setup_rack(app).call(env)
76
+ setup_rack(app).call(@env)
79
77
  }.should raise_error(RuntimeError, "Invalid strategy unknown")
80
78
  end
81
79
 
82
80
  it "should not raise error on missing strategies if silencing" do
83
- env = env_with_params('/')
84
81
  app = lambda do |env|
85
82
  env['warden'].authenticate
86
83
  valid_response
87
84
  end
88
85
  lambda {
89
- setup_rack(app, :silence_missing_strategies => true, :default_strategies => [:unknown]).call(env)
86
+ setup_rack(app, :silence_missing_strategies => true, :default_strategies => [:unknown]).call(@env)
90
87
  }.should_not raise_error
91
88
  end
92
89
 
93
90
  it "should allow me to get access to the user at warden.user." do
94
- env = env_with_params("/")
95
91
  app = lambda do |env|
96
92
  env['warden'].authenticate(:pass)
97
93
  env['warden'].should be_authenticated
98
94
  env['warden.spec.strategies'].should == [:pass]
99
95
  valid_response
100
96
  end
101
- setup_rack(app).call(env)
97
+ setup_rack(app).call(@env)
102
98
  end
103
99
 
104
100
  it "should run strategies when authenticate? is asked" do
105
- env = env_with_params("/")
106
101
  app = lambda do |env|
107
102
  env['warden'].should_not be_authenticated
108
103
  env['warden'].authenticate?(:pass)
@@ -110,29 +105,27 @@ describe Warden::Proxy do
110
105
  env['warden.spec.strategies'].should == [:pass]
111
106
  valid_response
112
107
  end
113
- setup_rack(app).call(env)
108
+ setup_rack(app).call(@env)
114
109
  end
115
110
 
116
111
  it "should properly send the scope to the strategy" do
117
- env = env_with_params("/")
118
112
  app = lambda do |env|
119
113
  env['warden'].authenticate(:pass, :scope => :failz)
120
114
  env['warden'].should_not be_authenticated
121
115
  env['warden.spec.strategies'].should == [:pass]
122
116
  valid_response
123
117
  end
124
- setup_rack(app).call(env)
118
+ setup_rack(app).call(@env)
125
119
  end
126
120
 
127
121
  it "should try multiple authentication strategies" do
128
- env = env_with_params("/")
129
122
  app = lambda do |env|
130
123
  env['warden'].authenticate(:password,:pass)
131
124
  env['warden'].should be_authenticated
132
125
  env['warden.spec.strategies'].should == [:password, :pass]
133
126
  valid_response
134
127
  end
135
- setup_rack(app).call(env)
128
+ setup_rack(app).call(@env)
136
129
  end
137
130
 
138
131
  it "should look for an active user in the session with authenticate" do
@@ -141,9 +134,8 @@ describe Warden::Proxy do
141
134
  env['warden'].authenticate(:pass)
142
135
  valid_response
143
136
  end
144
- env = env_with_params
145
- setup_rack(app).call(env)
146
- env['warden'].user.should == "foo as a user"
137
+ setup_rack(app).call(@env)
138
+ @env['warden'].user.should == "foo as a user"
147
139
  end
148
140
 
149
141
  it "should look for an active user in the session with authenticate?" do
@@ -152,9 +144,8 @@ describe Warden::Proxy do
152
144
  env['warden'].authenticate?(:pass, :scope => :foo_scope)
153
145
  valid_response
154
146
  end
155
- env = env_with_params
156
- setup_rack(app).call(env)
157
- env['warden'].user(:foo_scope).should == "a foo user"
147
+ setup_rack(app).call(@env)
148
+ @env['warden'].user(:foo_scope).should == "a foo user"
158
149
  end
159
150
 
160
151
  it "should look for an active user in the session with authenticate!" do
@@ -163,9 +154,8 @@ describe Warden::Proxy do
163
154
  env['warden'].authenticate!(:pass, :scope => :foo_scope)
164
155
  valid_response
165
156
  end
166
- env = env_with_params
167
- setup_rack(app).call(env)
168
- env['warden'].user(:foo_scope).should == "a foo user"
157
+ setup_rack(app).call(@env)
158
+ @env['warden'].user(:foo_scope).should == "a foo user"
169
159
  end
170
160
 
171
161
  it "should throw an error when authenticate!" do
@@ -173,8 +163,7 @@ describe Warden::Proxy do
173
163
  env['warden'].authenticate!(:pass, :scope => :failz)
174
164
  raise "OMG"
175
165
  end
176
- env = env_with_params
177
- setup_rack(app).call(env)
166
+ setup_rack(app).call(@env)
178
167
  end
179
168
 
180
169
  it "should login 2 different users from the session" do
@@ -186,11 +175,10 @@ describe Warden::Proxy do
186
175
  env['warden'].should_not be_authenticated # default scope
187
176
  valid_response
188
177
  end
189
- env = env_with_params
190
- setup_rack(app).call(env)
191
- env['warden'].user(:foo).should == 'foo user'
192
- env['warden'].user(:bar).should == 'bar user'
193
- env['warden'].user.should be_nil
178
+ setup_rack(app).call(@env)
179
+ @env['warden'].user(:foo).should == 'foo user'
180
+ @env['warden'].user(:bar).should == 'bar user'
181
+ @env['warden'].user.should be_nil
194
182
  end
195
183
 
196
184
  it "should not authenticate other scopes just because the first is authenticated" do
@@ -201,14 +189,66 @@ describe Warden::Proxy do
201
189
  env['warden'].should_not be_authenticated(:bar)
202
190
  valid_response
203
191
  end
204
- env = env_with_params
205
- setup_rack(app).call(env)
192
+ setup_rack(app).call(@env)
193
+ end
194
+
195
+ SID_REGEXP = /rack\.session=([^;]*);/
196
+
197
+ it "should renew session" do
198
+ app = lambda do |env|
199
+ env["rack.session"]["counter"] ||= 0
200
+ env["rack.session"]["counter"] += 1
201
+ if env["warden.on"]
202
+ env["warden"].authenticate!(:pass)
203
+ env['warden'].should be_authenticated
204
+ end
205
+ valid_response
206
+ end
207
+
208
+ # Setup a rack app with Pool session.
209
+ app = setup_rack(app, :session => Rack::Session::Pool).to_app
210
+ response = app.call(@env)
211
+ @env["rack.session"]["counter"].should == 1
212
+
213
+ # Ensure a cookie was given back
214
+ cookie = response[1]["Set-Cookie"]
215
+ cookie.should_not be_nil
216
+
217
+ # Ensure a session id was given
218
+ sid = cookie.match(SID_REGEXP)[1]
219
+ sid.should_not be_nil
220
+
221
+ # Do another request, but now passing the session id cookie
222
+ env = env_with_params("/", {}, "HTTP_COOKIE" => cookie)
223
+ response = app.call(env)
224
+ env["rack.session"]["counter"].should == 2
225
+
226
+ # Depending on rack version, a cookie will be returned with the
227
+ # same session id or no cookie is given back (becase it did not change).
228
+ # If we don't get any of these two behaviors, raise an error.
229
+ new_cookie = response[1]["Set-Cookie"]
230
+ if new_cookie && new_cookie.match(SID_REGEXP)[1] != sid
231
+ raise "Expected a cookie to not be sent or session id to match"
232
+ end
233
+
234
+ # Do another request, giving a cookie but turning on warden authentication
235
+ env = env_with_params("/", {}, "HTTP_COOKIE" => cookie, "warden.on" => true)
236
+ response = app.call(env)
237
+ @env["rack.session"]["counter"].should == 3
238
+
239
+ # Regardless of rack version, a cookie should be sent back
240
+ new_cookie = response[1]["Set-Cookie"]
241
+ new_cookie.should_not be_nil
242
+
243
+ # And the session id in this cookie should not be the same as the previous one
244
+ new_sid = new_cookie.match(SID_REGEXP)[1]
245
+ new_sid.should_not be_nil
246
+ new_sid.should_not == sid
206
247
  end
207
248
  end
208
249
 
209
250
  describe "authentication cache" do
210
251
  it "should run strategies just once for a given scope" do
211
- env = env_with_params("/")
212
252
  app = lambda do |env|
213
253
  env['warden'].authenticate(:password, :pass, :scope => :failz)
214
254
  env['warden'].should_not be_authenticated(:failz)
@@ -217,11 +257,10 @@ describe Warden::Proxy do
217
257
  env['warden.spec.strategies'].should == [:password, :pass]
218
258
  valid_response
219
259
  end
220
- setup_rack(app).call(env)
260
+ setup_rack(app).call(@env)
221
261
  end
222
262
 
223
263
  it "should run strategies for a given scope several times if cache is cleaned" do
224
- env = env_with_params("/")
225
264
  app = lambda do |env|
226
265
  env['warden'].authenticate(:password, :pass, :scope => :failz)
227
266
  env['warden'].clear_strategies_cache!(:scope => :failz)
@@ -229,11 +268,10 @@ describe Warden::Proxy do
229
268
  env['warden.spec.strategies'].should == [:password, :pass, :password, :pass]
230
269
  valid_response
231
270
  end
232
- setup_rack(app).call(env)
271
+ setup_rack(app).call(@env)
233
272
  end
234
273
 
235
274
  it "should clear the cache for a specified strategy" do
236
- env = env_with_params("/")
237
275
  app = lambda do |env|
238
276
  env['warden'].authenticate(:password, :pass, :scope => :failz)
239
277
  env['warden'].clear_strategies_cache!(:password, :scope => :failz)
@@ -241,11 +279,10 @@ describe Warden::Proxy do
241
279
  env['warden.spec.strategies'].should == [:password, :pass, :password]
242
280
  valid_response
243
281
  end
244
- setup_rack(app).call(env)
282
+ setup_rack(app).call(@env)
245
283
  end
246
284
 
247
285
  it "should run the strategies several times for different scopes" do
248
- env = env_with_params("/")
249
286
  app = lambda do |env|
250
287
  env['warden'].authenticate(:password, :pass, :scope => :failz)
251
288
  env['warden'].should_not be_authenticated(:failz)
@@ -254,11 +291,10 @@ describe Warden::Proxy do
254
291
  env['warden.spec.strategies'].should == [:password, :pass, :password, :pass]
255
292
  valid_response
256
293
  end
257
- setup_rack(app).call(env)
294
+ setup_rack(app).call(@env)
258
295
  end
259
296
 
260
297
  it "should not run strategies until cache is cleaned if latest winning strategy halted" do
261
- env = env_with_params("/")
262
298
  app = lambda do |env|
263
299
  env['warden'].authenticate(:failz)
264
300
  env['warden'].should_not be_authenticated
@@ -266,14 +302,25 @@ describe Warden::Proxy do
266
302
  env['warden'].winning_strategy.message.should == "The Fails Strategy Has Failed You"
267
303
  valid_response
268
304
  end
269
- setup_rack(app).call(env)
305
+ setup_rack(app).call(@env)
306
+ end
307
+
308
+ it "should not store user if strategy isn't meant for permanent login" do
309
+ session = Warden::SessionSerializer.new(@env)
310
+ app = lambda do |env|
311
+ env['warden'].authenticate(:single)
312
+ env['warden'].should be_authenticated
313
+ env['warden'].user.should == "Valid User"
314
+ session.should_not be_stored(:default)
315
+ valid_response
316
+ end
317
+ setup_rack(app).call(@env)
270
318
  end
271
319
 
272
320
  end
273
321
 
274
322
  describe "set user" do
275
323
  it "should store the user into the session" do
276
- env = env_with_params("/")
277
324
  app = lambda do |env|
278
325
  env['warden'].authenticate(:pass)
279
326
  env['warden'].should be_authenticated
@@ -281,19 +328,18 @@ describe Warden::Proxy do
281
328
  env['rack.session']["warden.user.default.key"].should == "Valid User"
282
329
  valid_response
283
330
  end
284
- setup_rack(app).call(env)
331
+ setup_rack(app).call(@env)
285
332
  end
286
333
 
287
334
  it "should not store the user if the :store option is set to false" do
288
- env = env_with_params("/")
289
- app = lambda do |e|
335
+ app = lambda do |env|
290
336
  env['warden'].authenticate(:pass, :store => false)
291
337
  env['warden'].should be_authenticated
292
338
  env['warden'].user.should == "Valid User"
293
339
  env['rack.session']['warden.user.default.key'].should be_nil
294
340
  valid_response
295
341
  end
296
- setup_rack(app).call(env)
342
+ setup_rack(app).call(@env)
297
343
  end
298
344
  end
299
345
 
@@ -348,10 +394,9 @@ describe Warden::Proxy do
348
394
  describe "logout" do
349
395
 
350
396
  before(:each) do
351
- @env = env = env_with_params
352
397
  @env['rack.session'] = {"warden.user.default.key" => "default key", "warden.user.foo.key" => "foo key", :foo => "bar"}
353
398
  @app = lambda do |e|
354
- e['warden'].logout(env['warden.spec.which_logout'])
399
+ e['warden'].logout(e['warden.spec.which_logout'])
355
400
  valid_response
356
401
  end
357
402
  end
@@ -428,7 +473,7 @@ describe Warden::Proxy do
428
473
  app = lambda do |e|
429
474
  e['warden'].authenticate! :failz
430
475
  end
431
- result = setup_rack(app, :failure_app => failure).call(env_with_params)
476
+ result = setup_rack(app, :failure_app => failure).call(@env)
432
477
  result.last.should == ["The Fails Strategy Has Failed You"]
433
478
  end
434
479
 
@@ -440,7 +485,7 @@ describe Warden::Proxy do
440
485
  e['warden'].authenticate! :pass_with_message
441
486
  success.call(e)
442
487
  end
443
- result = setup_rack(app).call(env_with_params)
488
+ result = setup_rack(app).call(@env)
444
489
  result.last.should == ["The Success Strategy Has Accepted You"]
445
490
  end
446
491
 
@@ -448,7 +493,7 @@ describe Warden::Proxy do
448
493
  app = lambda do |e|
449
494
  [200, {"Content-Type" => "text/plain"}, [e['warden'].message]]
450
495
  end
451
- result = setup_rack(app).call(env_with_params)
496
+ result = setup_rack(app).call(@env)
452
497
  result[2].should == [nil]
453
498
  end
454
499
  end
@@ -546,9 +591,8 @@ describe Warden::Proxy do
546
591
  env['warden'].authenticated?(:foo_scope)
547
592
  valid_response
548
593
  end
549
- env = env_with_params
550
- setup_rack(app).call(env)
551
- env['warden'].user(:foo_scope).should be_nil
594
+ setup_rack(app).call(@env)
595
+ @env['warden'].user(:foo_scope).should be_nil
552
596
  ensure
553
597
  Warden::Manager.serialize_from_session { |k| k }
554
598
  end
@@ -686,6 +730,7 @@ describe "dynamic default_strategies" do
686
730
 
687
731
  before(:each) do
688
732
  @app = lambda{|e| e['warden'].authenticate! }
733
+ @env = env_with_params("/")
689
734
  $captures = []
690
735
  end
691
736
 
@@ -705,7 +750,7 @@ describe "dynamic default_strategies" do
705
750
  e['warden'].authenticate!
706
751
  Rack::Response.new("OK").finish
707
752
  end
708
- setup_rack(app).call(env_with_params)
753
+ setup_rack(app).call(@env)
709
754
 
710
755
  $captures.should == [:one]
711
756
  end
@@ -717,7 +762,7 @@ describe "dynamic default_strategies" do
717
762
  e['warden'].authenticate!
718
763
  Rack::Response.new("OK").finish
719
764
  end
720
- setup_rack(app).call(env_with_params)
765
+ setup_rack(app).call(@env)
721
766
 
722
767
  $captures.should == [:one]
723
768
  end
@@ -734,7 +779,7 @@ describe "dynamic default_strategies" do
734
779
  w.authenticate
735
780
  $captures.should == [:two]
736
781
  end
737
- setup_rack(app).call(env_with_params)
782
+ setup_rack(app).call(@env)
738
783
  $captures.should == [:two]
739
784
  end
740
785
 
@@ -756,7 +801,7 @@ describe "dynamic default_strategies" do
756
801
  $captures << :complete
757
802
  end)
758
803
  end
759
- builder.to_app.call(env_with_params)
804
+ builder.to_app.call(@env)
760
805
  $captures.should include(:complete)
761
806
  end
762
807
 
@@ -768,7 +813,7 @@ describe "dynamic default_strategies" do
768
813
  e['warden'].authenticate!
769
814
  Rack::Response.new("OK").finish
770
815
  end
771
- setup_rack(app).call(env_with_params)
816
+ setup_rack(app).call(@env)
772
817
 
773
818
  $captures.should == [:one]
774
819
  end
@@ -821,9 +866,8 @@ describe "dynamic default_strategies" do
821
866
  Rack::Response.new("OK").finish
822
867
  end)
823
868
  end
824
- env = env_with_params
825
- session = env["rack.session"] = {}
826
- builder.to_app.call(env)
869
+ session = @env["rack.session"] = {}
870
+ builder.to_app.call(@env)
827
871
  $captures.should include(:complete)
828
872
  session['warden.user.default.key'].should == "User"
829
873
  session['warden.user.foo.key'].should == "User"
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.7"
8
+ s.version = "1.0.0"
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-05-31}
12
+ s.date = %q{2010-09-24}
13
13
  s.email = %q{has.sox@gmail.com}
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE",
@@ -43,6 +43,7 @@ Gem::Specification.new do |s|
43
43
  "spec/helpers/strategies/pass.rb",
44
44
  "spec/helpers/strategies/pass_with_message.rb",
45
45
  "spec/helpers/strategies/password.rb",
46
+ "spec/helpers/strategies/single.rb",
46
47
  "spec/spec_helper.rb",
47
48
  "spec/warden/authenticated_data_store_spec.rb",
48
49
  "spec/warden/config_spec.rb",
@@ -71,6 +72,7 @@ Gem::Specification.new do |s|
71
72
  "spec/helpers/strategies/pass.rb",
72
73
  "spec/helpers/strategies/pass_with_message.rb",
73
74
  "spec/helpers/strategies/password.rb",
75
+ "spec/helpers/strategies/single.rb",
74
76
  "spec/spec_helper.rb",
75
77
  "spec/warden/authenticated_data_store_spec.rb",
76
78
  "spec/warden/config_spec.rb",
@@ -92,14 +94,14 @@ Gem::Specification.new do |s|
92
94
 
93
95
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
94
96
  s.add_runtime_dependency(%q<rack>, [">= 1.0.0"])
95
- s.add_development_dependency(%q<rspec>, [">= 1.0.0"])
97
+ s.add_development_dependency(%q<rspec>, ["~> 1"])
96
98
  else
97
99
  s.add_dependency(%q<rack>, [">= 1.0.0"])
98
- s.add_dependency(%q<rspec>, [">= 1.0.0"])
100
+ s.add_dependency(%q<rspec>, ["~> 1"])
99
101
  end
100
102
  else
101
103
  s.add_dependency(%q<rack>, [">= 1.0.0"])
102
- s.add_dependency(%q<rspec>, [">= 1.0.0"])
104
+ s.add_dependency(%q<rspec>, ["~> 1"])
103
105
  end
104
106
  end
105
107
 
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: 57
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
+ - 1
7
8
  - 0
8
- - 10
9
- - 7
10
- version: 0.10.7
9
+ - 0
10
+ version: 1.0.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Daniel Neighman
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-05-31 00:00:00 +10:00
18
+ date: 2010-09-24 00:00:00 +10:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -40,14 +40,12 @@ dependencies:
40
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
- - - ">="
43
+ - - ~>
44
44
  - !ruby/object:Gem::Version
45
- hash: 23
45
+ hash: 1
46
46
  segments:
47
47
  - 1
48
- - 0
49
- - 0
50
- version: 1.0.0
48
+ version: "1"
51
49
  type: :development
52
50
  version_requirements: *id002
53
51
  description:
@@ -87,6 +85,7 @@ files:
87
85
  - spec/helpers/strategies/pass.rb
88
86
  - spec/helpers/strategies/pass_with_message.rb
89
87
  - spec/helpers/strategies/password.rb
88
+ - spec/helpers/strategies/single.rb
90
89
  - spec/spec_helper.rb
91
90
  - spec/warden/authenticated_data_store_spec.rb
92
91
  - spec/warden/config_spec.rb
@@ -142,6 +141,7 @@ test_files:
142
141
  - spec/helpers/strategies/pass.rb
143
142
  - spec/helpers/strategies/pass_with_message.rb
144
143
  - spec/helpers/strategies/password.rb
144
+ - spec/helpers/strategies/single.rb
145
145
  - spec/spec_helper.rb
146
146
  - spec/warden/authenticated_data_store_spec.rb
147
147
  - spec/warden/config_spec.rb