ssl_routes 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MmU5MjVhMWY0ZjcyNDMwMDFiNGZjYmI2NmI5YTM4YzgxYjdkYWQzYw==
5
+ data.tar.gz: !binary |-
6
+ YmIyYmM1NjU5MjgxNDMxNDk3NjgyMTY1N2Q5NDU2ZjUwMDViYmQzMQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ NjlhN2I3MTU4OWNhZDA1YmY5Mjk2MGE3MTIzMTYyMGY0MzFlMjhhYTBhMDU4
10
+ ZmNlOTdiNTA2MDJmNTZmOTZjZmM5NTYxYWQ5MWM2OTgyYmUyYWE0YzkyMzcw
11
+ YTc4YWIwYjk4YzI5ZGE4NmEzZmZjZTE5ZTRkZmYxM2FiZTc2NWM=
12
+ data.tar.gz: !binary |-
13
+ Nzk4MTVhYjBmODUyNmQ1ODE5OTYxMzU4NGFkNzNlYTk3YTAwNWRlYjJiN2Q3
14
+ MmE4YzIxMzMxMmZkN2IyNTdlNmJmMzQ4MGQ4N2RjNGE0MzE4Mzk0ZDE4YjJl
15
+ NDVmZWE0YmEyZmQ5MzU5NjAxMzQ0NWJlNTNmYWExMTMxMWYyZmM=
@@ -39,8 +39,11 @@ module SslRoutes
39
39
  routes = Rails.application.routes
40
40
  options = routes.recognize_path request.path, {:method => request.env['REQUEST_METHOD']}
41
41
  current, target = determine_protocols(options)
42
- if current != target && !request.xhr? && request.get?
42
+ safari_preloading = !!request.xhr? && request.accepts.all? { |a| a.symbol != :json }
43
+ if (current != target && safari_preloading && request.get?) || (current != target && !request.xhr? && request.get?)
43
44
  flash.keep
45
+ response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate"
46
+ response.headers["Pragma"] = "no-cache"
44
47
  redirect_to "#{target}://#{request.host_with_port + request.fullpath}"
45
48
  return false
46
49
  end
@@ -55,8 +58,8 @@ module SslRoutes
55
58
  end
56
59
 
57
60
  def url_for_with_ssl_support(options)
61
+ ac = self.respond_to?(:controller) ? self.controller : self
58
62
  if options.is_a?(Hash) && options[:only_path] == true
59
- ac = self.respond_to?(:controller) ? self.controller : self
60
63
  if ac.respond_to?(:enable_ssl) && ac.enable_ssl
61
64
  case options
62
65
  when Hash
@@ -66,7 +69,12 @@ module SslRoutes
66
69
  end
67
70
  end
68
71
  end
72
+ else
73
+ if options[:ssl] && ac.respond_to?(:enable_ssl) && ac.enable_ssl
74
+ options.merge!({ :protocol => 'https' })
75
+ end
69
76
  end
77
+
70
78
  url_for_without_ssl_support(options)
71
79
  end
72
80
 
@@ -1,5 +1,5 @@
1
1
  module SslRoutes
2
2
 
3
- VERSION = '0.2.0'
3
+ VERSION = '0.2.1'
4
4
 
5
5
  end
metadata CHANGED
@@ -1,87 +1,66 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: ssl_routes
3
- version: !ruby/object:Gem::Version
4
- hash: 23
5
- prerelease:
6
- segments:
7
- - 0
8
- - 2
9
- - 0
10
- version: 0.2.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.1
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Cedric Howe
14
8
  - Lance Ivy
15
9
  - Tieg Zaharia
16
10
  autorequire:
17
11
  bindir: bin
18
12
  cert_chain: []
19
-
20
- date: 2013-02-28 00:00:00 Z
21
- dependencies:
22
- - !ruby/object:Gem::Dependency
13
+ date: 2013-10-04 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
23
16
  name: rails
24
- prerelease: false
25
- requirement: &id001 !ruby/object:Gem::Requirement
26
- none: false
27
- requirements:
28
- - - ">="
29
- - !ruby/object:Gem::Version
30
- hash: 7
31
- segments:
32
- - 3
33
- - 0
34
- version: "3.0"
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '3.1'
35
22
  type: :runtime
36
- version_requirements: *id001
37
- description: Define your SSL settings in one place to enforce in your controller, generate URLs with the correct protocol, and protect yourself against session hijacking.
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ! '>='
27
+ - !ruby/object:Gem::Version
28
+ version: '3.1'
29
+ description: Define your SSL settings in one place to enforce in your controller,
30
+ generate URLs with the correct protocol, and protect yourself against session hijacking.
38
31
  email: cedric@howe.net
39
32
  executables: []
40
-
41
33
  extensions: []
42
-
43
34
  extra_rdoc_files: []
44
-
45
- files:
35
+ files:
46
36
  - lib/ssl_routes/paperclip.rb
47
37
  - lib/ssl_routes/rails.rb
48
38
  - lib/ssl_routes/version.rb
49
39
  - lib/ssl_routes.rb
50
40
  - test/test_helper.rb
51
41
  homepage: http://github.com/cedric/ssl_routes
52
- licenses: []
53
-
42
+ licenses:
43
+ - MIT
44
+ metadata: {}
54
45
  post_install_message:
55
46
  rdoc_options: []
56
-
57
- require_paths:
47
+ require_paths:
58
48
  - lib
59
- required_ruby_version: !ruby/object:Gem::Requirement
60
- none: false
61
- requirements:
62
- - - ">="
63
- - !ruby/object:Gem::Version
64
- hash: 3
65
- segments:
66
- - 0
67
- version: "0"
68
- required_rubygems_version: !ruby/object:Gem::Requirement
69
- none: false
70
- requirements:
71
- - - ">="
72
- - !ruby/object:Gem::Version
73
- hash: 23
74
- segments:
75
- - 1
76
- - 3
77
- - 6
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ! '>='
57
+ - !ruby/object:Gem::Version
78
58
  version: 1.3.6
79
59
  requirements: []
80
-
81
- rubyforge_project: ssl_routes
82
- rubygems_version: 1.8.24
60
+ rubyforge_project:
61
+ rubygems_version: 2.0.3
83
62
  signing_key:
84
- specification_version: 3
63
+ specification_version: 4
85
64
  summary: Enforce SSL based on your Rails routes.
86
- test_files:
65
+ test_files:
87
66
  - test/test_helper.rb