ssl_routes 0.0.7 → 0.0.8
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/lib/ssl_routes/controller.rb +10 -9
- data/lib/ssl_routes/version.rb +1 -1
- metadata +12 -12
@@ -25,10 +25,10 @@ module SslRoutes::Controller
|
|
25
25
|
if self.enable_ssl
|
26
26
|
case options
|
27
27
|
when Hash
|
28
|
-
|
29
|
-
|
30
|
-
if
|
31
|
-
options.merge!({ :protocol =>
|
28
|
+
current_protocol = request.protocol.split(':').first
|
29
|
+
target_protocol = determine_target_protocol(current_protocol, options)
|
30
|
+
if current_protocol != target_protocol
|
31
|
+
options.merge!({ :protocol => target_protocol, :only_path => false })
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -43,21 +43,22 @@ module SslRoutes::Controller
|
|
43
43
|
request.path,
|
44
44
|
ActionController::Routing::Routes.extract_request_environment(request)
|
45
45
|
)
|
46
|
-
|
47
|
-
|
48
|
-
if
|
46
|
+
current_protocol = request.protocol.split(':').first
|
47
|
+
target_protocol = determine_target_protocol(current_protocol, options)
|
48
|
+
if current_protocol != target_protocol && !request.xhr? && request.get?
|
49
49
|
flash.keep
|
50
|
-
redirect_to "#{
|
50
|
+
redirect_to "#{target_protocol}://#{request.host_with_port + request.request_uri}"
|
51
51
|
return false
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
-
def
|
55
|
+
def determine_target_protocol(current_protocol, options)
|
56
56
|
protocol = case options[self.parameter]
|
57
57
|
when String then options[self.parameter]
|
58
58
|
when TrueClass then 'https'
|
59
59
|
else 'http'
|
60
60
|
end
|
61
|
+
protocol = current_protocol if [:all, :both].include? options[self.parameter]
|
61
62
|
protocol = 'https' if self.secure_session && current_user
|
62
63
|
protocol = options[:protocol] if options[:protocol]
|
63
64
|
return protocol.split(':').first
|
data/lib/ssl_routes/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ssl_routes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 15
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 8
|
10
|
+
version: 0.0.8
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Cedric Howe
|
@@ -15,24 +15,24 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-01
|
18
|
+
date: 2011-07-01 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
-
|
23
|
-
prerelease: false
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
22
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
25
23
|
none: false
|
26
24
|
requirements:
|
27
|
-
- -
|
25
|
+
- - ~>
|
28
26
|
- !ruby/object:Gem::Version
|
29
27
|
hash: 5
|
30
28
|
segments:
|
31
29
|
- 2
|
32
30
|
- 3
|
33
31
|
version: "2.3"
|
32
|
+
name: rails
|
34
33
|
type: :runtime
|
35
|
-
|
34
|
+
prerelease: false
|
35
|
+
requirement: *id001
|
36
36
|
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.
|
37
37
|
email: cedric@freezerbox.com
|
38
38
|
executables: []
|
@@ -68,7 +68,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
68
68
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
69
|
none: false
|
70
70
|
requirements:
|
71
|
-
- -
|
71
|
+
- - ~>
|
72
72
|
- !ruby/object:Gem::Version
|
73
73
|
hash: 23
|
74
74
|
segments:
|
@@ -79,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
79
|
requirements: []
|
80
80
|
|
81
81
|
rubyforge_project: ssl_routes
|
82
|
-
rubygems_version: 1.
|
82
|
+
rubygems_version: 1.6.2
|
83
83
|
signing_key:
|
84
84
|
specification_version: 3
|
85
85
|
summary: Enforce SSL based on your Rails routes.
|