warden 0.10.2 → 0.10.3

Sign up to get free protection for your applications and to get access to all the features.
data/lib/warden/config.rb CHANGED
@@ -65,7 +65,7 @@ module Warden
65
65
  scope = opts[:scope] || :_all
66
66
 
67
67
  hash[scope] = strategies.flatten unless strategies.empty?
68
- hash[scope] || hash[:_all]
68
+ hash[scope] || hash[:_all] || []
69
69
  end
70
70
 
71
71
  # A short hand way to set up a particular scope
@@ -1,7 +1,6 @@
1
1
  # encoding: utf-8
2
2
  require 'warden/hooks'
3
3
  require 'warden/config'
4
- require 'warden/manager_deprecation'
5
4
 
6
5
  module Warden
7
6
  # The middleware for Rack Authentication
@@ -10,7 +9,6 @@ module Warden
10
9
  # the rack environment hash
11
10
  class Manager
12
11
  extend Warden::Hooks
13
- extend Warden::ManagerDeprecation
14
12
 
15
13
  attr_accessor :config
16
14
 
@@ -30,7 +28,7 @@ module Warden
30
28
  # If this is downstream from another warden instance, don't do anything.
31
29
  # :api: private
32
30
  def call(env) # :nodoc:
33
- return @app.call(env) unless env['warden'].nil? || env['warden'].manager == self
31
+ return @app.call(env) if env['warden'] && env['warden'].manager != self
34
32
 
35
33
  env['warden'] = Proxy.new(env, self)
36
34
  result = catch(:warden) do
data/lib/warden/proxy.rb CHANGED
@@ -1,11 +1,9 @@
1
1
  # encoding: utf-8
2
- require 'warden/proxy_deprecation'
3
2
 
4
3
  module Warden
5
4
  class UserNotSet < RuntimeError; end
6
5
 
7
6
  class Proxy
8
- include ProxyDeprecation
9
7
  # An accessor to the winning strategy
10
8
  # :api: private
11
9
  attr_accessor :winning_strategy
@@ -275,6 +273,8 @@ module Warden
275
273
  # Run the strategies for a given scope
276
274
  def _run_strategies_for(scope, args) #:nodoc:
277
275
  self.winning_strategy = @winning_strategies[scope]
276
+ return if winning_strategy && winning_strategy.halted?
277
+
278
278
  strategies = args.empty? ? default_strategies(:scope => scope) : args
279
279
 
280
280
  strategies.each do |name|
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module Warden
3
- VERSION = "0.10.2".freeze
3
+ VERSION = "0.10.3".freeze
4
4
  end
@@ -220,18 +220,6 @@ describe Warden::Proxy do
220
220
  setup_rack(app).call(env)
221
221
  end
222
222
 
223
- it "should store the last winning strategy per scope" do
224
- env = env_with_params("/")
225
- app = lambda do |env|
226
- env['warden'].authenticate(:failz)
227
- env['warden'].should_not be_authenticated
228
- env['warden'].authenticate(:failz)
229
- env['warden'].winning_strategy.message.should == "The Fails Strategy Has Failed You"
230
- valid_response
231
- end
232
- setup_rack(app).call(env)
233
- end
234
-
235
223
  it "should run strategies for a given scope several times if cache is cleaned" do
236
224
  env = env_with_params("/")
237
225
  app = lambda do |env|
@@ -268,6 +256,19 @@ describe Warden::Proxy do
268
256
  end
269
257
  setup_rack(app).call(env)
270
258
  end
259
+
260
+ it "should not run strategies until cache is cleaned if latest winning strategy halted" do
261
+ env = env_with_params("/")
262
+ app = lambda do |env|
263
+ env['warden'].authenticate(:failz)
264
+ env['warden'].should_not be_authenticated
265
+ env['warden'].authenticate(:pass)
266
+ env['warden'].winning_strategy.message.should == "The Fails Strategy Has Failed You"
267
+ valid_response
268
+ end
269
+ setup_rack(app).call(env)
270
+ end
271
+
271
272
  end
272
273
 
273
274
  describe "set user" do
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.2"
8
+ s.version = "0.10.3"
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-26}
12
+ s.date = %q{2010-04-01}
13
13
  s.email = %q{has.sox@gmail.com}
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE",
@@ -27,10 +27,8 @@ Gem::Specification.new do |s|
27
27
  "lib/warden/errors.rb",
28
28
  "lib/warden/hooks.rb",
29
29
  "lib/warden/manager.rb",
30
- "lib/warden/manager_deprecation.rb",
31
30
  "lib/warden/mixins/common.rb",
32
31
  "lib/warden/proxy.rb",
33
- "lib/warden/proxy_deprecation.rb",
34
32
  "lib/warden/session_serializer.rb",
35
33
  "lib/warden/strategies.rb",
36
34
  "lib/warden/strategies/base.rb",
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 10
8
- - 2
9
- version: 0.10.2
8
+ - 3
9
+ version: 0.10.3
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-26 00:00:00 +11:00
17
+ date: 2010-04-01 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -66,10 +66,8 @@ files:
66
66
  - lib/warden/errors.rb
67
67
  - lib/warden/hooks.rb
68
68
  - lib/warden/manager.rb
69
- - lib/warden/manager_deprecation.rb
70
69
  - lib/warden/mixins/common.rb
71
70
  - lib/warden/proxy.rb
72
- - lib/warden/proxy_deprecation.rb
73
71
  - lib/warden/session_serializer.rb
74
72
  - lib/warden/strategies.rb
75
73
  - lib/warden/strategies/base.rb
@@ -1,36 +0,0 @@
1
- # encoding: utf-8
2
- module Warden
3
- module ManagerDeprecation
4
- class Dummy
5
- def update(type, &block)
6
- if type == :session
7
- warn "[DEPRECATION] warden.serializers.update(:session) is deprecated. " <<
8
- "Please use Warden::Manager.serialize_from_session and Warden::Manager.serialize_into_session"
9
- Warden::SessionSerializer.class_eval(&block)
10
- else
11
- method_missing(update)
12
- end
13
- end
14
-
15
- def method_missing(method, *args)
16
- warn "[DEPRECATION] warden.serializers.#{method} is deprecated."
17
- nil
18
- end
19
- end
20
-
21
- # Read the default scope from Warden
22
- def default_scope
23
- warn "[DEPRECATION] Warden::Manager.default_scope is deprecated. It's now accessible in the Warden::Manager instance."
24
- end
25
-
26
- # Set the default scope for Warden.
27
- def default_scope=(scope)
28
- warn "[DEPRECATION] Warden::Manager.default_scope= is deprecated. Please set it in the Warden::Manager instance."
29
- end
30
-
31
- def serializers
32
- warn "[DEPRECATION] warden.serializers is deprecated since Warden::Serializers were merged into Warden::Strategies."
33
- Dummy.new
34
- end
35
- end
36
- end
@@ -1,11 +0,0 @@
1
- # encoding: utf-8
2
- module Warden
3
- # Sets up a place for deprecation of methods from the main proxy
4
- module ProxyDeprecation
5
- def default_strategies=(*strategies)
6
- warn "[DEPRECATION] warden.default_strategies= is deprecated. Instead use warden.default_strategies(*strategies) with an optional :scope => :scope)"
7
- strategies.push(:scope => @config.default_scope)
8
- default_strategies(*strategies)
9
- end
10
- end
11
- end