warden 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,6 @@
1
+ == Version 1.0.2
2
+ * Added :intercept_401 to Warden::Config
3
+
1
4
  == Version 1.0.1
2
5
  * Bug fix on strategies errors handler
3
6
 
data/Rakefile CHANGED
@@ -1,6 +1,5 @@
1
1
  require 'rubygems'
2
- gem 'rspec'
3
- require 'spec/rake/spectask'
2
+ require 'rspec/core/rake_task'
4
3
  require File.join(File.dirname(__FILE__), "lib", "warden", "version")
5
4
 
6
5
  begin
@@ -26,7 +25,7 @@ end
26
25
  task :default => :spec
27
26
 
28
27
  desc "Run specs"
29
- Spec::Rake::SpecTask.new do |t|
30
- t.spec_files = FileList['spec/**/*_spec.rb']
31
- t.spec_opts = %w(-fs --color --backtrace)
28
+ RSpec::Core::RakeTask.new do |t|
29
+ t.pattern = 'spec/**/*_spec.rb'
30
+ t.rspec_opts = %w(-fs --color --backtrace)
32
31
  end
@@ -32,13 +32,14 @@ module Warden
32
32
  end
33
33
  end
34
34
 
35
- hash_accessor :failure_app, :default_scope
35
+ hash_accessor :failure_app, :default_scope, :intercept_401
36
36
 
37
37
  def initialize(other={})
38
38
  merge!(other)
39
39
  self[:default_scope] ||= :default
40
40
  self[:scope_defaults] ||= {}
41
41
  self[:default_strategies] ||= {}
42
+ self[:intercept_401] = true unless key?(:intercept_401)
42
43
  end
43
44
 
44
45
  def initialize_copy(other)
@@ -38,13 +38,13 @@ module Warden
38
38
  result ||= {}
39
39
  case result
40
40
  when Array
41
- if result.first == 401 && !env['warden'].custom_failure?
41
+ if result.first == 401 && intercept_401?(env)
42
42
  process_unauthenticated(env)
43
43
  else
44
44
  result
45
45
  end
46
46
  when Hash
47
- process_unauthenticated(env, result || {})
47
+ process_unauthenticated(env, result)
48
48
  end
49
49
  end
50
50
 
@@ -81,6 +81,10 @@ module Warden
81
81
 
82
82
  private
83
83
 
84
+ def intercept_401?(env)
85
+ config[:intercept_401] && !env['warden'].custom_failure?
86
+ end
87
+
84
88
  # When a request is unauthentiated, here's where the processing occurs.
85
89
  # It looks at the result of the proxy to see if it's been executed and what action to take.
86
90
  # :api: private
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module Warden
3
- VERSION = "1.0.1".freeze
3
+ VERSION = "1.0.2".freeze
4
4
  end
@@ -12,7 +12,7 @@ Dir[File.join(File.dirname(__FILE__), "helpers", "**/*.rb")].each do |f|
12
12
  require f
13
13
  end
14
14
 
15
- Spec::Runner.configure do |config|
15
+ RSpec.configure do |config|
16
16
  config.include(Warden::Spec::Helpers)
17
17
 
18
18
  def load_strategies
@@ -225,6 +225,16 @@ describe Warden::Manager do
225
225
  result[2].should == ["Fail From The App"]
226
226
  end
227
227
 
228
+ it "should allow you to customize the response without the explicit call to custom_failure! if not intercepting 401" do
229
+ app = lambda do |e|
230
+ [401,{'Content-Type' => 'text/plain'},["Fail From The App"]]
231
+ end
232
+ env = env_with_params
233
+ result = setup_rack(app, :intercept_401 => false).call(env)
234
+ result[0].should == 401
235
+ result[2].should == ["Fail From The App"]
236
+ end
237
+
228
238
  it "should render the failure application for a 401 if no custom_failure flag is set" do
229
239
  app = lambda do |e|
230
240
  [401,{'Content-Type' => 'text/plain'},["Fail From The App"]]
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{warden}
8
- s.version = "1.0.1"
8
+ s.version = "1.0.2"
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-10-12}
12
+ s.date = %q{2010-11-09}
13
13
  s.email = %q{has.sox@gmail.com}
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE",
@@ -35,8 +35,6 @@ Gem::Specification.new do |s|
35
35
  "lib/warden/test/helpers.rb",
36
36
  "lib/warden/test/warden_helpers.rb",
37
37
  "lib/warden/version.rb",
38
- "script/destroy",
39
- "script/generate",
40
38
  "spec/helpers/request_helper.rb",
41
39
  "spec/helpers/strategies/failz.rb",
42
40
  "spec/helpers/strategies/invalid.rb",
@@ -56,7 +54,6 @@ Gem::Specification.new do |s|
56
54
  "spec/warden/strategies_spec.rb",
57
55
  "spec/warden/test/helpers_spec.rb",
58
56
  "spec/warden/test/test_mode_spec.rb",
59
- "spec/warden_spec.rb",
60
57
  "warden.gemspec"
61
58
  ]
62
59
  s.homepage = %q{http://github.com/hassox/warden}
@@ -84,8 +81,7 @@ Gem::Specification.new do |s|
84
81
  "spec/warden/strategies/base_spec.rb",
85
82
  "spec/warden/strategies_spec.rb",
86
83
  "spec/warden/test/helpers_spec.rb",
87
- "spec/warden/test/test_mode_spec.rb",
88
- "spec/warden_spec.rb"
84
+ "spec/warden/test/test_mode_spec.rb"
89
85
  ]
90
86
 
91
87
  if s.respond_to? :specification_version then
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: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 1
10
- version: 1.0.1
9
+ - 2
10
+ version: 1.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Daniel Neighman
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-12 00:00:00 +11:00
18
+ date: 2010-11-09 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -77,8 +77,6 @@ files:
77
77
  - lib/warden/test/helpers.rb
78
78
  - lib/warden/test/warden_helpers.rb
79
79
  - lib/warden/version.rb
80
- - script/destroy
81
- - script/generate
82
80
  - spec/helpers/request_helper.rb
83
81
  - spec/helpers/strategies/failz.rb
84
82
  - spec/helpers/strategies/invalid.rb
@@ -98,7 +96,6 @@ files:
98
96
  - spec/warden/strategies_spec.rb
99
97
  - spec/warden/test/helpers_spec.rb
100
98
  - spec/warden/test/test_mode_spec.rb
101
- - spec/warden_spec.rb
102
99
  - warden.gemspec
103
100
  has_rdoc: true
104
101
  homepage: http://github.com/hassox/warden
@@ -154,4 +151,3 @@ test_files:
154
151
  - spec/warden/strategies_spec.rb
155
152
  - spec/warden/test/helpers_spec.rb
156
153
  - spec/warden/test/test_mode_spec.rb
157
- - spec/warden_spec.rb
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
- APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '.'))
3
-
4
- begin
5
- require 'rubigen'
6
- rescue LoadError
7
- require 'rubygems'
8
- require 'rubigen'
9
- end
10
- require 'rubigen/scripts/destroy'
11
-
12
- ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
- RubiGen::Base.use_component_sources! [:newgem_simple, :test_unit]
14
- RubiGen::Scripts::Destroy.new.run(ARGV)
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
- APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '.'))
3
-
4
- begin
5
- require 'rubigen'
6
- rescue LoadError
7
- require 'rubygems'
8
- require 'rubigen'
9
- end
10
- require 'rubigen/scripts/generate'
11
-
12
- ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
- RubiGen::Base.use_component_sources! [:newgem_simple, :test_unit]
14
- RubiGen::Scripts::Generate.new.run(ARGV)
@@ -1,5 +0,0 @@
1
- # encoding: utf-8
2
- require File.dirname(__FILE__) + '/spec_helper'
3
-
4
- describe "warden" do
5
- end