rack-ssl-enforcer 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.rdoc CHANGED
@@ -26,9 +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!
29
+ == Contributors
30
30
 
31
- * To {Dan Mayer}[http://github.com/danmayer] for making proxied ssl setups work
31
+ * {Dan Mayer}[http://github.com/danmayer]
32
+ * {Rémy Coutable}http://github.com/rymai]
32
33
 
33
34
  == Copyright
34
35
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
@@ -1,25 +1,28 @@
1
1
  module Rack
2
-
2
+
3
3
  class SslEnforcer
4
-
4
+
5
5
  def initialize(app, options = {})
6
- @app = app
6
+ @app = app
7
7
  @options = options
8
8
  end
9
-
9
+
10
10
  def call(env)
11
- @options[:redirect_to] ||= Rack::Request.new(env).url
12
- @options[:redirect_to].gsub!(/^http:/,'https:')
13
- @options[:message] ||= "You are beeing redirected to #{@options[:redirect_to]}."
14
- ssl_request?(env) ? @app.call(env) : [301, {'Location' => @options[:redirect_to]}, @options[:message]]
11
+ if ssl_request?(env)
12
+ @app.call(env)
13
+ else
14
+ @options[:redirect_to] ||= Rack::Request.new(env).url
15
+ @options[:redirect_to].gsub!(/^http:/, 'https:')
16
+ @options[:message] ||= "You are beeing redirected to #{@options[:redirect_to]}."
17
+ [301, { 'Location' => @options[:redirect_to] }, @options[:message]]
18
+ end
15
19
  end
16
20
 
17
-
18
21
  private
19
22
 
20
23
  def ssl_request?(env)
21
24
  (env['HTTP_X_FORWARDED_PROTO'] || env['rack.url_scheme']) == 'https'
22
25
  end
23
-
26
+
24
27
  end
25
- end
28
+ 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.2"
8
+ s.version = "0.1.3"
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-07-30}
12
+ s.date = %q{2010-08-12}
13
13
  s.email = %q{tm@mit2m.de}
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE",
metadata CHANGED
@@ -1,13 +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
+ hash: 29
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
9
+ - 3
10
+ version: 0.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tobias Matthies
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-30 00:00:00 +02:00
18
+ date: 2010-08-12 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency