warden 1.0.6 → 1.1.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/Gemfile.lock +1 -1
- data/History.rdoc +2 -0
- data/lib/warden/errors.rb +2 -2
- data/lib/warden/manager.rb +4 -1
- data/lib/warden/version.rb +1 -1
- data/spec/helpers/request_helper.rb +2 -1
- data/spec/helpers/strategies/single.rb +1 -1
- data/spec/warden/manager_spec.rb +21 -0
- metadata +3 -3
data/Gemfile.lock
CHANGED
data/History.rdoc
CHANGED
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
|
data/lib/warden/manager.rb
CHANGED
@@ -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] ||=
|
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
|
data/lib/warden/version.rb
CHANGED
@@ -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
|
data/spec/warden/manager_spec.rb
CHANGED
@@ -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:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 1.0.6
|
10
|
+
version: 1.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Daniel Neighman
|