ssl_routes 0.0.3 → 0.0.4
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 +8 -8
- data/lib/ssl_routes/version.rb +1 -1
- metadata +4 -4
@@ -10,9 +10,9 @@ module SslRoutes::Controller
|
|
10
10
|
|
11
11
|
def enforce_protocols(&block)
|
12
12
|
cattr_accessor :parameter, :secure_session, :enable_ssl
|
13
|
-
self.parameter
|
14
|
-
self.secure_session
|
15
|
-
self.enable_ssl
|
13
|
+
self.parameter = :protocol
|
14
|
+
self.secure_session = false
|
15
|
+
self.enable_ssl = false
|
16
16
|
yield self if block_given?
|
17
17
|
before_filter :ensure_protocol if self.enable_ssl
|
18
18
|
end
|
@@ -26,7 +26,7 @@ module SslRoutes::Controller
|
|
26
26
|
case options
|
27
27
|
when Hash
|
28
28
|
current = request.protocol.split(':').first
|
29
|
-
target = extract_protocol(options
|
29
|
+
target = extract_protocol(options)
|
30
30
|
if current != target
|
31
31
|
options.merge!({ :protocol => target, :only_path => false })
|
32
32
|
end
|
@@ -43,19 +43,19 @@ module SslRoutes::Controller
|
|
43
43
|
ActionController::Routing::Routes.extract_request_environment(request)
|
44
44
|
)
|
45
45
|
current = request.protocol.split(':').first
|
46
|
-
target = extract_protocol(options
|
47
|
-
if current != target
|
46
|
+
target = extract_protocol(options)
|
47
|
+
if current != target && request.get?
|
48
48
|
flash.keep
|
49
49
|
redirect_to "#{target}://#{request.host_with_port + request.request_uri}"
|
50
50
|
return false
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
def extract_protocol(options
|
54
|
+
def extract_protocol(options)
|
55
55
|
protocol = case options[self.parameter]
|
56
56
|
when String then options[self.parameter]
|
57
57
|
when TrueClass then 'https'
|
58
|
-
else
|
58
|
+
else 'http'
|
59
59
|
end
|
60
60
|
protocol = 'https' if self.secure_session && current_user
|
61
61
|
protocol = options[:protocol] if options[:protocol]
|
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:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Cedric Howe
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-12-
|
18
|
+
date: 2010-12-13 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|