warden 1.0.6 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- warden (1.0.5)
4
+ warden (1.0.7)
5
5
  rack (>= 1.0)
6
6
 
7
7
  GEM
data/History.rdoc CHANGED
@@ -1,3 +1,5 @@
1
+ == Version 1.1.0 / 2011-11-02
2
+ * Use the default scopes action when using a bare throw(:warden)
1
3
  == Version 1.0.6
2
4
  * Remove gem files from the packaged gem
3
5
  == Version 1.0.3
data/lib/warden/errors.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
  module Warden
3
- class Proxy
3
+ class Proxy
4
4
  # Lifted from DataMapper's dm-validations plugin :)
5
5
  # @author Guy van den Berg
6
6
  # @since DM 0.9
@@ -56,7 +56,7 @@ module Warden
56
56
  def errors
57
57
  @errors ||= {}
58
58
  end
59
-
59
+
60
60
  def blank?(thing)
61
61
  thing.nil? || thing == "" || (thing.respond_to?(:empty?) && thing.empty?)
62
62
  end
@@ -89,7 +89,10 @@ module Warden
89
89
  # It looks at the result of the proxy to see if it's been executed and what action to take.
90
90
  # :api: private
91
91
  def process_unauthenticated(env, options={})
92
- options[:action] ||= "unauthenticated"
92
+ options[:action] ||= begin
93
+ opts = config[:scope_defaults][config.default_scope] || {}
94
+ opts[:action] || 'unauthenticated'
95
+ end
93
96
 
94
97
  proxy = env['warden']
95
98
  result = options[:result] || proxy.result
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module Warden
3
- VERSION = "1.0.6".freeze
3
+ VERSION = "1.1.0".freeze
4
4
  end
@@ -15,10 +15,11 @@ 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] || lambda{}
18
19
 
19
20
  Rack::Builder.new do
20
21
  use opts[:session] || Warden::Spec::Helpers::Session
21
- use Warden::Manager, opts
22
+ use Warden::Manager, opts, &blk
22
23
  run app
23
24
  end
24
25
  end
@@ -5,7 +5,7 @@ Warden::Strategies.add(:single) do
5
5
  request.env['warden.spec.strategies'] << :single
6
6
  success!("Valid User")
7
7
  end
8
-
8
+
9
9
  def store?
10
10
  false
11
11
  end
@@ -126,6 +126,27 @@ describe Warden::Manager do
126
126
  result[2].body.should == ["Bad"]
127
127
  $throw_count.should == 2
128
128
  end
129
+
130
+ it "should use the default scopes action when a bare throw is used" do
131
+ env = env_with_params("/", :foo => "bar")
132
+ action = nil
133
+
134
+ failure = lambda do |env|
135
+ action = env['PATH_INFO']
136
+ [401, {}, ['fail']]
137
+ end
138
+
139
+ app = lambda do |env|
140
+ throw(:warden)
141
+ end
142
+ result = setup_rack(app,
143
+ :failure_app => failure,
144
+ :configurator => lambda{ |c| c.scope_defaults(:default, :action => 'my_action', :strategies => [:password]) }
145
+ ).call(env)
146
+
147
+ action.should == "/my_action"
148
+ result.first.should == 401
149
+ end
129
150
  end # failure
130
151
  end
131
152
 
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: 27
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
+ - 1
8
9
  - 0
9
- - 6
10
- version: 1.0.6
10
+ version: 1.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Daniel Neighman