rack-ssl-enforcer 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -26,6 +26,10 @@ You might need the :redirect_to option if the requested URL can't be determined
26
26
  (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
27
27
  * Send me a pull request. Bonus points for topic branches.
28
28
 
29
+ == Thanks!
30
+
31
+ * To {Dan Mayer}[http://github.com/danmayer] for making proxied ssl setups work
32
+
29
33
  == Copyright
30
34
 
31
35
  Copyright (c) 2010 Tobias Matthies. See LICENSE for details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -18,8 +18,8 @@ module Rack
18
18
  private
19
19
 
20
20
  def ssl_request?(env)
21
- env['rack.url_scheme'] == 'https'
21
+ (env['HTTP_X_FORWARDED_PROTO'] || env['rack.url_scheme']) == 'https'
22
22
  end
23
23
 
24
24
  end
25
- end
25
+ end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rack-ssl-enforcer}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Tobias Matthies"]
12
- s.date = %q{2010-03-18}
12
+ s.date = %q{2010-07-30}
13
13
  s.email = %q{tm@mit2m.de}
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE",
@@ -30,7 +30,7 @@ Gem::Specification.new do |s|
30
30
  s.homepage = %q{http://github.com/tobmatth/rack-ssl-enforcer}
31
31
  s.rdoc_options = ["--charset=UTF-8"]
32
32
  s.require_paths = ["lib"]
33
- s.rubygems_version = %q{1.3.6}
33
+ s.rubygems_version = %q{1.3.7}
34
34
  s.summary = %q{A simple Rack middleware to enforce SSL}
35
35
  s.test_files = [
36
36
  "test/helper.rb",
@@ -41,7 +41,7 @@ Gem::Specification.new do |s|
41
41
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
42
42
  s.specification_version = 3
43
43
 
44
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
44
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
45
45
  s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
46
46
  else
47
47
  s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
@@ -21,12 +21,31 @@ class TestRackSslEnforcer < Test::Unit::TestCase
21
21
  assert_equal 301, response.status
22
22
  assert_equal response.location, 'https://www.example.org/'
23
23
  end
24
+
25
+ #heroku / etc do proxied SSL
26
+ #http://github.com/pivotal/refraction/issues/issue/2
27
+ should 'respect X-Forwarded-Proto header for proxied SSL' do
28
+ response = @request.get('http://www.example.org/',
29
+ {'HTTP_X_FORWARDED_PROTO' => 'http',
30
+ 'rack.url_scheme' => 'http'})
31
+ assert_equal 301, response.status
32
+ assert_equal response.location, 'https://www.example.org/'
33
+ end
24
34
 
25
35
  should 'respond not redirect ssl requests' do
26
36
  response = @request.get('https://www.example.org/', {})
27
37
  assert_equal 200, response.status
28
38
  assert_equal response.body, 'Hello world!'
29
39
  end
40
+
41
+ should 'respond not redirect ssl requests and respect X-Forwarded-Proto header for proxied SSL' do
42
+ response = @request.get('http://www.example.org/',
43
+ {'HTTP_X_FORWARDED_PROTO' => 'https',
44
+ 'rack.url_scheme' => 'http'})
45
+ assert_equal 200, response.status
46
+ assert_equal response.body, 'Hello world!'
47
+ end
48
+
30
49
  end
31
50
 
32
51
  context 'that has :redirect_to set' do
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-ssl-enforcer
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 31
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 1
8
- - 1
9
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
10
11
  platform: ruby
11
12
  authors:
12
13
  - Tobias Matthies
@@ -14,16 +15,18 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-03-18 00:00:00 +01:00
18
+ date: 2010-07-30 00:00:00 +02:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: thoughtbot-shoulda
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 3
27
30
  segments:
28
31
  - 0
29
32
  version: "0"
@@ -59,23 +62,27 @@ rdoc_options:
59
62
  require_paths:
60
63
  - lib
61
64
  required_ruby_version: !ruby/object:Gem::Requirement
65
+ none: false
62
66
  requirements:
63
67
  - - ">="
64
68
  - !ruby/object:Gem::Version
69
+ hash: 3
65
70
  segments:
66
71
  - 0
67
72
  version: "0"
68
73
  required_rubygems_version: !ruby/object:Gem::Requirement
74
+ none: false
69
75
  requirements:
70
76
  - - ">="
71
77
  - !ruby/object:Gem::Version
78
+ hash: 3
72
79
  segments:
73
80
  - 0
74
81
  version: "0"
75
82
  requirements: []
76
83
 
77
84
  rubyforge_project:
78
- rubygems_version: 1.3.6
85
+ rubygems_version: 1.3.7
79
86
  signing_key:
80
87
  specification_version: 3
81
88
  summary: A simple Rack middleware to enforce SSL