warden 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +3 -0
- data/Rakefile +4 -5
- data/lib/warden/config.rb +2 -1
- data/lib/warden/manager.rb +6 -2
- data/lib/warden/version.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/warden/manager_spec.rb +10 -0
- data/warden.gemspec +3 -7
- metadata +4 -8
- data/script/destroy +0 -14
- data/script/generate +0 -14
- data/spec/warden_spec.rb +0 -5
data/History.rdoc
CHANGED
data/Rakefile
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'rubygems'
|
2
|
-
|
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
|
-
|
30
|
-
t.
|
31
|
-
t.
|
28
|
+
RSpec::Core::RakeTask.new do |t|
|
29
|
+
t.pattern = 'spec/**/*_spec.rb'
|
30
|
+
t.rspec_opts = %w(-fs --color --backtrace)
|
32
31
|
end
|
data/lib/warden/config.rb
CHANGED
@@ -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)
|
data/lib/warden/manager.rb
CHANGED
@@ -38,13 +38,13 @@ module Warden
|
|
38
38
|
result ||= {}
|
39
39
|
case result
|
40
40
|
when Array
|
41
|
-
if result.first == 401 &&
|
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
|
data/lib/warden/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
data/spec/warden/manager_spec.rb
CHANGED
@@ -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"]]
|
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 = "1.0.
|
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-
|
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:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
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-
|
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
|
data/script/destroy
DELETED
@@ -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)
|
data/script/generate
DELETED
@@ -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)
|