warden 1.2.1 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
@@ -1,3 +1,10 @@
1
+ == Version 1.2.3 / 2013-07-14
2
+ * Fix an issue with lazy loaded sessions
3
+
4
+ == Version 1.2.2 / 2013-07-12
5
+ * Support nil session stores on logout
6
+ * Fix strategies blowing up with undefined method base
7
+
1
8
  == Version 1.2.1 / 2012-06-16
2
9
  * Minor caching and speed improvements
3
10
  * Add support to #lock in the proxy
@@ -4,5 +4,6 @@ h2. Maintainers
4
4
 
5
5
  * Daniel Neighman (hassox)
6
6
  * José Valim (josevalim)
7
+ * Justin Smestad (jsmestad)
7
8
 
8
- "A list of all contributors is available on Github.":https://github.com/hassox/warden/contributors
9
+ "A list of all contributors is available on Github.":https://github.com/hassox/warden/contributors
@@ -24,7 +24,7 @@ module Warden
24
24
  def warden_cookies
25
25
  warn "warden_cookies was never functional and is going to be removed in next versions"
26
26
  env['warden.cookies'] ||= {}
27
- end # response
27
+ end # warden_cookies
28
28
 
29
29
  # Convenience method to access the rack request params
30
30
  # :api: public
@@ -37,7 +37,8 @@ module Warden
37
37
  # @api overwritable
38
38
  def reset_session!
39
39
  raw_session.clear
40
- end
40
+ end # reset_session!
41
+
41
42
  end # Common
42
43
  end # Mixins
43
44
  end # Warden
@@ -261,7 +261,7 @@ module Warden
261
261
  user = @users.delete(scope)
262
262
  manager._run_callbacks(:before_logout, user, self, :scope => scope)
263
263
 
264
- raw_session.delete("warden.user.#{scope}.session")
264
+ raw_session.delete("warden.user.#{scope}.session") unless raw_session.nil?
265
265
  session_serializer.delete(scope, user)
266
266
  end
267
267
 
@@ -2,7 +2,6 @@
2
2
  module Warden
3
3
  class SessionSerializer
4
4
  attr_reader :env
5
- include ::Warden::Mixins::Common
6
5
 
7
6
  def initialize(env)
8
7
  @env = env
@@ -44,5 +43,10 @@ module Warden
44
43
  def delete(scope, user=nil)
45
44
  session.delete(key_for(scope))
46
45
  end
46
+
47
+ # We can't cache this result because the session can be lazy loaded
48
+ def session
49
+ env["rack.session"] || {}
50
+ end
47
51
  end # SessionSerializer
48
52
  end # Warden
@@ -11,7 +11,8 @@ module Warden
11
11
  raise NoMethodError, "authenticate! is not declared in the #{label.inspect} strategy"
12
12
  end
13
13
 
14
- unless strategy.ancestors.include?(Warden::Strategies::Base)
14
+ base = Warden::Strategies::Base
15
+ unless strategy.ancestors.include?(base)
15
16
  raise "#{label.inspect} is not a #{base}"
16
17
  end
17
18
 
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module Warden
3
- VERSION = "1.2.1".freeze
3
+ VERSION = "1.2.3".freeze
4
4
  end
@@ -18,7 +18,7 @@ module Warden::Spec
18
18
  blk = opts[:configurator] || proc{}
19
19
 
20
20
  Rack::Builder.new do
21
- use opts[:session] || Warden::Spec::Helpers::Session
21
+ use opts[:session] || Warden::Spec::Helpers::Session unless opts[:nil_session]
22
22
  use Warden::Manager, opts, &blk
23
23
  run app
24
24
  end
@@ -2,7 +2,6 @@
2
2
  require 'spec_helper'
3
3
 
4
4
  describe Warden::Proxy do
5
-
6
5
  before(:all) do
7
6
  load_strategies
8
7
  end
@@ -340,7 +339,6 @@ describe Warden::Proxy do
340
339
  end
341
340
  setup_rack(app).call(@env)
342
341
  end
343
-
344
342
  end
345
343
 
346
344
  describe "set user" do
@@ -366,6 +364,17 @@ describe Warden::Proxy do
366
364
  setup_rack(app).call(@env)
367
365
  end
368
366
 
367
+ it "should not throw error when no session is configured and store is false" do
368
+ app = lambda do |env|
369
+ env['rack.session'] = nil
370
+ env['warden'].authenticate(:pass, :store => false)
371
+ env['warden'].should be_authenticated
372
+ env['warden'].user.should == "Valid User"
373
+ valid_response
374
+ end
375
+ setup_rack(app).call(@env)
376
+ end
377
+
369
378
  it "should not run the callbacks when :run_callbacks is false" do
370
379
  app = lambda do |env|
371
380
  env['warden'].manager.should_not_receive(:_run_callbacks)
@@ -512,7 +521,6 @@ describe Warden::Proxy do
512
521
  end
513
522
 
514
523
  describe "logout" do
515
-
516
524
  before(:each) do
517
525
  @env['rack.session'] = {"warden.user.default.key" => "default key", "warden.user.foo.key" => "foo key", :foo => "bar"}
518
526
  @app = lambda do |e|
@@ -549,6 +557,13 @@ describe Warden::Proxy do
549
557
  @env['rack.session'].should be_empty
550
558
  end
551
559
 
560
+ it "should not raise exception if raw_session is nil" do
561
+ @app = setup_rack(@app, { nil_session: true })
562
+ @env['rack.session'] = nil
563
+ @env['warden.spec.which_logout'] = :foo
564
+ expect { @app.call(@env) }.to_not raise_error(NoMethodError)
565
+ end
566
+
552
567
  it "should clear the user when logging out" do
553
568
  @env['rack.session'].should_not be_nil
554
569
  app = lambda do |e|
@@ -665,7 +680,7 @@ describe Warden::Proxy do
665
680
  app = lambda do |e|
666
681
  e['warden'].should be_authenticated
667
682
  end
668
- result = setup_rack(app).call(@env)
683
+ setup_rack(app).call(@env)
669
684
  end
670
685
 
671
686
  it "should yield to a block when the block is passed and authenticated" do
@@ -700,7 +715,7 @@ describe Warden::Proxy do
700
715
  app = lambda do |e|
701
716
  e['warden'].should_not be_authenticated
702
717
  end
703
- result = setup_rack(app).call(@env)
718
+ setup_rack(app).call(@env)
704
719
  end
705
720
 
706
721
  it "should return false if scope cannot be retrieved from session" do
@@ -786,7 +801,7 @@ describe Warden::Proxy do
786
801
  app = lambda do |e|
787
802
  e['warden'].should be_unauthenticated
788
803
  end
789
- result = setup_rack(app).call(@env)
804
+ setup_rack(app).call(@env)
790
805
  end
791
806
 
792
807
  it "should yield to a block when the block is passed and authenticated" do
@@ -828,6 +843,8 @@ end
828
843
 
829
844
  describe "dynamic default_strategies" do
830
845
  before(:all) do
846
+ load_strategies
847
+
831
848
  class ::DynamicDefaultStrategies
832
849
  def initialize(app, &blk)
833
850
  @app, @blk = app, blk
@@ -45,4 +45,9 @@ describe Warden::SessionSerializer do
45
45
  @session.fetch(:default)
46
46
  @env['rack.session'].should_not have_key("warden.user.default.key")
47
47
  end
48
+
49
+ it "should support a nil session store" do
50
+ @env['rack.session'] = nil
51
+ @session.fetch(:default).should be_nil
52
+ end
48
53
  end
@@ -11,13 +11,23 @@ describe Warden::Strategies do
11
11
  Warden::Strategies[:strategy1].ancestors.should include(Warden::Strategies::Base)
12
12
  end
13
13
 
14
- it "should raise an error if I add a strategy via a block, that does not have an autheniticate! method" do
14
+ it "should raise an error if I add a strategy via a block, that does not have an authenticate! method" do
15
15
  lambda do
16
16
  Warden::Strategies.add(:strategy2) do
17
17
  end
18
18
  end.should raise_error
19
19
  end
20
20
 
21
+ it "should raise an error if I add a strategy that does not extend Warden::Strategies::Base" do
22
+ non_base = Class.new do
23
+ def authenticate!
24
+ end
25
+ end
26
+ expect do
27
+ Warden::Strategies.add(:strategy_non_base, non_base)
28
+ end.to raise_error(/is not a Warden::Strategies::Base/)
29
+ end
30
+
21
31
  it "should allow me to get access to a particular strategy" do
22
32
  Warden::Strategies.add(:strategy3) do
23
33
  def authenticate!; end
@@ -7,6 +7,7 @@ Gem::Specification.new do |s|
7
7
  s.version = Warden::VERSION.dup
8
8
  s.authors = ["Daniel Neighman"]
9
9
  s.email = %q{has.sox@gmail.com}
10
+ s.license = "MIT"
10
11
  s.extra_rdoc_files = [
11
12
  "LICENSE",
12
13
  "README.textile"
metadata CHANGED
@@ -1,48 +1,40 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: warden
3
- version: !ruby/object:Gem::Version
4
- hash: 29
3
+ version: !ruby/object:Gem::Version
5
4
  prerelease:
6
- segments:
7
- - 1
8
- - 2
9
- - 1
10
- version: 1.2.1
5
+ version: 1.2.3
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Daniel Neighman
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-06-16 00:00:00 +02:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2013-07-14 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ version_requirements: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ none: false
22
21
  name: rack
22
+ type: :runtime
23
23
  prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirement: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ! '>='
27
+ - !ruby/object:Gem::Version
28
+ version: '1.0'
25
29
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 15
30
- segments:
31
- - 1
32
- - 0
33
- version: "1.0"
34
- type: :runtime
35
- version_requirements: *id001
36
30
  description:
37
31
  email: has.sox@gmail.com
38
32
  executables: []
39
-
40
33
  extensions: []
41
-
42
- extra_rdoc_files:
34
+ extra_rdoc_files:
43
35
  - LICENSE
44
36
  - README.textile
45
- files:
37
+ files:
46
38
  - Gemfile
47
39
  - History.rdoc
48
40
  - lib/warden/config.rb
@@ -82,39 +74,31 @@ files:
82
74
  - spec/warden/test/helpers_spec.rb
83
75
  - spec/warden/test/test_mode_spec.rb
84
76
  - warden.gemspec
85
- has_rdoc: true
86
77
  homepage: http://github.com/hassox/warden
87
- licenses: []
88
-
78
+ licenses:
79
+ - MIT
89
80
  post_install_message:
90
- rdoc_options:
81
+ rdoc_options:
91
82
  - --charset=UTF-8
92
- require_paths:
83
+ require_paths:
93
84
  - lib
94
- required_ruby_version: !ruby/object:Gem::Requirement
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
95
90
  none: false
96
- requirements:
97
- - - ">="
98
- - !ruby/object:Gem::Version
99
- hash: 3
100
- segments:
101
- - 0
102
- version: "0"
103
- required_rubygems_version: !ruby/object:Gem::Requirement
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ! '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
104
96
  none: false
105
- requirements:
106
- - - ">="
107
- - !ruby/object:Gem::Version
108
- hash: 3
109
- segments:
110
- - 0
111
- version: "0"
112
97
  requirements: []
113
-
114
98
  rubyforge_project: warden
115
- rubygems_version: 1.5.3
99
+ rubygems_version: 1.8.23
116
100
  signing_key:
117
101
  specification_version: 3
118
102
  summary: Rack middleware that provides authentication for rack applications
119
103
  test_files: []
120
-
104
+ has_rdoc: