warden 0.9.0 → 0.9.1
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/.gitignore +2 -2
- data/lib/warden/config.rb +3 -1
- data/lib/warden/manager_deprecation.rb +1 -0
- data/lib/warden/strategies/base.rb +5 -4
- data/lib/warden/version.rb +2 -1
- data/spec/helpers/request_helper.rb +1 -0
- data/spec/helpers/strategies/failz.rb +1 -2
- data/spec/helpers/strategies/invalid.rb +3 -2
- data/spec/helpers/strategies/pass.rb +1 -0
- data/spec/helpers/strategies/pass_with_message.rb +8 -0
- data/spec/helpers/strategies/password.rb +1 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/warden/authenticated_data_store_spec.rb +1 -0
- data/spec/warden/config_spec.rb +1 -0
- data/spec/warden/errors_spec.rb +1 -0
- data/spec/warden/hooks_spec.rb +1 -0
- data/spec/warden/manager_spec.rb +1 -0
- data/spec/warden/proxy_spec.rb +13 -0
- data/spec/warden/session_serializer_spec.rb +1 -0
- data/spec/warden/strategies/base_spec.rb +7 -1
- data/spec/warden/strategies_spec.rb +1 -0
- data/spec/warden_spec.rb +1 -0
- data/warden.gemspec +4 -2
- metadata +4 -2
data/.gitignore
CHANGED
data/lib/warden/config.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
module Warden
|
2
4
|
# This is a class which is yielded on use Warden::Manager. If you have a plugin
|
3
5
|
# and wants to add more configuration to warden, you just need to extend this
|
@@ -15,7 +17,7 @@ module Warden
|
|
15
17
|
#
|
16
18
|
# config[:failure_app] = Bar
|
17
19
|
# config.failure_app #=> Bar
|
18
|
-
#
|
20
|
+
#
|
19
21
|
def self.hash_accessor(*names) #:nodoc:
|
20
22
|
names.each do |name|
|
21
23
|
class_eval <<-METHOD, __FILE__, __LINE__ + 1
|
@@ -8,8 +8,8 @@ module Warden
|
|
8
8
|
# You _must_ declare an @authenticate!@ method.
|
9
9
|
# You _may_ provide a @valid?@ method.
|
10
10
|
# The valid method should return true or false depending on if the strategy is a valid one for the request.
|
11
|
-
#
|
12
|
-
# The parameters for Warden::Strategies.add method is:
|
11
|
+
#
|
12
|
+
# The parameters for Warden::Strategies.add method is:
|
13
13
|
# <label: Symbol> The label is the name given to a strategy. Use the label to refer to the strategy when authenticating
|
14
14
|
# <strategy: Class|nil> The optional stragtegy argument if set _must_ be a class that inherits from Warden::Strategies::Base and _must_
|
15
15
|
# implement an @authenticate!@ method
|
@@ -110,9 +110,10 @@ module Warden
|
|
110
110
|
# user - The user object to login. This object can be anything you have setup to serialize in and out of the session
|
111
111
|
#
|
112
112
|
# :api: public
|
113
|
-
def success!(user)
|
113
|
+
def success!(user, message = nil)
|
114
114
|
halt!
|
115
|
-
@user
|
115
|
+
@user = user
|
116
|
+
@message = message
|
116
117
|
@result = :success
|
117
118
|
end
|
118
119
|
|
data/lib/warden/version.rb
CHANGED
@@ -0,0 +1,8 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
Warden::Strategies.add(:pass_with_message) do
|
3
|
+
def authenticate!
|
4
|
+
request.env['warden.spec.strategies'] ||= []
|
5
|
+
request.env['warden.spec.strategies'] << :pass_with_message
|
6
|
+
success!("Valid User", "The Success Strategy Has Accepted You") unless scope == :failz
|
7
|
+
end
|
8
|
+
end
|
data/spec/spec_helper.rb
CHANGED
data/spec/warden/config_spec.rb
CHANGED
data/spec/warden/errors_spec.rb
CHANGED
data/spec/warden/hooks_spec.rb
CHANGED
data/spec/warden/manager_spec.rb
CHANGED
data/spec/warden/proxy_spec.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# encoding: utf-8
|
1
2
|
require File.dirname(__FILE__) + '/../spec_helper'
|
2
3
|
|
3
4
|
describe Warden::Proxy do
|
@@ -409,6 +410,18 @@ describe Warden::Proxy do
|
|
409
410
|
result.last.should == ["The Fails Strategy Has Failed You"]
|
410
411
|
end
|
411
412
|
|
413
|
+
it "should allow access to the success message" do
|
414
|
+
success = lambda do |e|
|
415
|
+
[200, {"Content-Type" => "text/plain"}, [e['warden'].message]]
|
416
|
+
end
|
417
|
+
app = lambda do |e|
|
418
|
+
e['warden'].authenticate! :pass_with_message
|
419
|
+
success.call(e)
|
420
|
+
end
|
421
|
+
result = setup_rack(app).call(env_with_params)
|
422
|
+
result.last.should == ["The Success Strategy Has Accepted You"]
|
423
|
+
end
|
424
|
+
|
412
425
|
it "should not die when accessing a message from a source where no authentication has occured" do
|
413
426
|
app = lambda do |e|
|
414
427
|
[200, {"Content-Type" => "text/plain"}, [e['warden'].message]]
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# encoding: utf-8
|
1
2
|
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
3
|
|
3
4
|
describe Warden::Strategies::Base do
|
@@ -222,7 +223,7 @@ describe Warden::Strategies::Base do
|
|
222
223
|
before(:each) do
|
223
224
|
RAS.add(:foobar) do
|
224
225
|
def authenticate!
|
225
|
-
success!("Foo User")
|
226
|
+
success!("Foo User", "Welcome to the club!")
|
226
227
|
end
|
227
228
|
end
|
228
229
|
@str = RAS[:foobar].new(env_with_params)
|
@@ -237,6 +238,11 @@ describe Warden::Strategies::Base do
|
|
237
238
|
@str.user.should_not be_nil
|
238
239
|
end
|
239
240
|
|
241
|
+
it "should allow you to set a message when succeeding" do
|
242
|
+
@str._run!
|
243
|
+
@str.message.should == "Welcome to the club!"
|
244
|
+
end
|
245
|
+
|
240
246
|
it "should store the user" do
|
241
247
|
@str._run!
|
242
248
|
@str.user.should == "Foo User"
|
data/spec/warden_spec.rb
CHANGED
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.9.
|
8
|
+
s.version = "0.9.1"
|
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-
|
12
|
+
s.date = %q{2010-02-09}
|
13
13
|
s.email = %q{has.sox@gmail.com}
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"LICENSE",
|
@@ -40,6 +40,7 @@ Gem::Specification.new do |s|
|
|
40
40
|
"spec/helpers/strategies/failz.rb",
|
41
41
|
"spec/helpers/strategies/invalid.rb",
|
42
42
|
"spec/helpers/strategies/pass.rb",
|
43
|
+
"spec/helpers/strategies/pass_with_message.rb",
|
43
44
|
"spec/helpers/strategies/password.rb",
|
44
45
|
"spec/spec_helper.rb",
|
45
46
|
"spec/warden/authenticated_data_store_spec.rb",
|
@@ -65,6 +66,7 @@ Gem::Specification.new do |s|
|
|
65
66
|
"spec/helpers/strategies/failz.rb",
|
66
67
|
"spec/helpers/strategies/invalid.rb",
|
67
68
|
"spec/helpers/strategies/pass.rb",
|
69
|
+
"spec/helpers/strategies/pass_with_message.rb",
|
68
70
|
"spec/helpers/strategies/password.rb",
|
69
71
|
"spec/spec_helper.rb",
|
70
72
|
"spec/warden/authenticated_data_store_spec.rb",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: warden
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Neighman
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
12
|
+
date: 2010-02-09 00:00:00 +11:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -66,6 +66,7 @@ files:
|
|
66
66
|
- spec/helpers/strategies/failz.rb
|
67
67
|
- spec/helpers/strategies/invalid.rb
|
68
68
|
- spec/helpers/strategies/pass.rb
|
69
|
+
- spec/helpers/strategies/pass_with_message.rb
|
69
70
|
- spec/helpers/strategies/password.rb
|
70
71
|
- spec/spec_helper.rb
|
71
72
|
- spec/warden/authenticated_data_store_spec.rb
|
@@ -112,6 +113,7 @@ test_files:
|
|
112
113
|
- spec/helpers/strategies/failz.rb
|
113
114
|
- spec/helpers/strategies/invalid.rb
|
114
115
|
- spec/helpers/strategies/pass.rb
|
116
|
+
- spec/helpers/strategies/pass_with_message.rb
|
115
117
|
- spec/helpers/strategies/password.rb
|
116
118
|
- spec/spec_helper.rb
|
117
119
|
- spec/warden/authenticated_data_store_spec.rb
|