warden 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,3 +1,3 @@
1
+ .DS_Store
1
2
  pkg
2
- pkg/*
3
- *.gem
3
+ .*~
@@ -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
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module Warden
2
3
  module ManagerDeprecation
3
4
  class Dummy
@@ -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 = user
115
+ @user = user
116
+ @message = message
116
117
  @result = :success
117
118
  end
118
119
 
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module Warden
2
- VERSION = "0.9.0".freeze
3
+ VERSION = "0.9.1".freeze
3
4
  end
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module Warden::Spec
2
3
  module Helpers
3
4
 
@@ -1,9 +1,8 @@
1
+ # encoding: utf-8
1
2
  Warden::Strategies.add(:failz) do
2
-
3
3
  def authenticate!
4
4
  request.env['warden.spec.strategies'] ||= []
5
5
  request.env['warden.spec.strategies'] << :failz
6
6
  fail!("The Fails Strategy Has Failed You")
7
7
  end
8
-
9
8
  end
@@ -1,7 +1,8 @@
1
+ # encoding: utf-8
1
2
  Warden::Strategies.add(:invalid) do
2
3
  def valid?
3
4
  false
4
- end
5
-
5
+ end
6
+
6
7
  def authenticate!; end
7
8
  end
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  Warden::Strategies.add(:pass) do
2
3
  def authenticate!
3
4
  request.env['warden.spec.strategies'] ||= []
@@ -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
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  Warden::Strategies.add(:password) do
2
3
  def authenticate!
3
4
  request.env['warden.spec.strategies'] ||= []
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  $TESTING=true
2
3
 
3
4
  $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require File.dirname(__FILE__) + '/../spec_helper'
2
3
 
3
4
  describe "authenticated data store" do
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require File.dirname(__FILE__) + '/../spec_helper'
2
3
 
3
4
  describe Warden::Config do
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require File.join(File.dirname(__FILE__), "..", 'spec_helper.rb')
2
3
 
3
4
  describe Warden::Proxy::Errors do
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require File.dirname(__FILE__) + '/../spec_helper'
2
3
 
3
4
  describe "standard authentication hooks" do
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require File.dirname(__FILE__) + '/../spec_helper'
2
3
 
3
4
  describe Warden::Manager do
@@ -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::SessionSerializer do
@@ -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"
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require File.dirname(__FILE__) + '/../spec_helper'
2
3
 
3
4
  describe Warden::Strategies do
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require File.dirname(__FILE__) + '/spec_helper'
2
3
 
3
4
  describe "warden" do
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{warden}
8
- s.version = "0.9.0"
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-01-21}
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.0
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-01-21 00:00:00 +11:00
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