ssl_routes 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/ssl_routes/rails.rb +31 -10
- data/lib/ssl_routes/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MjQ1MDVjODMyYjAwODJkMGU0ZmU0YjllNmYzZTRkMTVmYjg1ZGQzMw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZTg1ZGE1NDU5ZDZmZDI3NzczNzJlOWIyZDRkZmE1MTM5NzBlYmViMA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NDZmZWU1MDU0YjM2MTFhZjgxMzViYzc2MGU1MjAyNjg3ZjBmOTAwNTllNTUy
|
10
|
+
OGQ0YjUxYWUzZjkzY2UwYmE2ZDc4MWEyYjc1ZmI0YWU2OTQ5YjI3MzU4M2Q0
|
11
|
+
ZTZlNWQyMWQ2YjgxMTkwYWQxOTcxOTU0OWM1OWNjMjAwM2QzZDQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ODc5MTRhZTk1MzZkMjM1NDE2Yzg0MGI5ODY2MTkwYTNkMGJkYzE1MDFiYzU4
|
14
|
+
ODEyY2MzN2NhOTBmZmNmYzA5YzQ4MjMyMjQ0MDg5NmZjYTdhNWVkNjJlMGVi
|
15
|
+
MzRmOGI3ODk2ZjdlYjljZDYyODQzYmJhOWM2MzJlYmVkYmM2OTI=
|
data/lib/ssl_routes/rails.rb
CHANGED
@@ -25,9 +25,8 @@ module SslRoutes
|
|
25
25
|
when String then options[self.parameter]
|
26
26
|
when TrueClass then 'https'
|
27
27
|
when FalseClass then 'http'
|
28
|
-
else
|
28
|
+
else current
|
29
29
|
end
|
30
|
-
target = current if [:all, :both].include? options[self.parameter]
|
31
30
|
target = 'https' if self.secure_session && current_user
|
32
31
|
target = options[:protocol] if options[:protocol]
|
33
32
|
[ current, target.split(':').first ]
|
@@ -36,8 +35,8 @@ module SslRoutes
|
|
36
35
|
private
|
37
36
|
|
38
37
|
def ensure_protocol
|
39
|
-
|
40
|
-
options =
|
38
|
+
router = Rails.application.routes.router
|
39
|
+
options = recognize_request(router, self.request)
|
41
40
|
current, target = determine_protocols(options)
|
42
41
|
if (current != target && !request.xhr? && request.get?)
|
43
42
|
flash.keep
|
@@ -48,6 +47,31 @@ module SslRoutes
|
|
48
47
|
end
|
49
48
|
end
|
50
49
|
|
50
|
+
Constraints = ::ActionDispatch::Routing::Mapper::Constraints
|
51
|
+
Dispatcher = ::ActionDispatch::Routing::RouteSet::Dispatcher
|
52
|
+
|
53
|
+
def recognize_request(router, req)
|
54
|
+
router.recognize(req) do |route, matches, params|
|
55
|
+
params.each do |key, value|
|
56
|
+
if value.is_a?(String)
|
57
|
+
value = value.dup.force_encoding(Encoding::BINARY) if value.encoding_aware?
|
58
|
+
params[key] = URI.parser.unescape(value)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
dispatcher = route.app
|
63
|
+
while dispatcher.is_a?(Constraints) && dispatcher.matches?(env) do
|
64
|
+
dispatcher = dispatcher.app
|
65
|
+
end
|
66
|
+
|
67
|
+
if dispatcher.is_a?(Dispatcher) && dispatcher.controller(params, false)
|
68
|
+
dispatcher.prepare_params!(params)
|
69
|
+
return params
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
raise ActionController::RoutingError, "No route matches #{path.inspect}"
|
74
|
+
end
|
51
75
|
end
|
52
76
|
|
53
77
|
module ActionDispatch
|
@@ -60,12 +84,9 @@ module SslRoutes
|
|
60
84
|
ac = self.respond_to?(:controller) ? self.controller : self
|
61
85
|
if ac.respond_to?(:enable_ssl) && ac.enable_ssl
|
62
86
|
if options.is_a?(Hash)
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
if current != target
|
67
|
-
options.merge!({ :protocol => target, :only_path => false })
|
68
|
-
end
|
87
|
+
current, target = ac.determine_protocols(options)
|
88
|
+
if current != target
|
89
|
+
options.merge!({ :protocol => target, :only_path => false })
|
69
90
|
end
|
70
91
|
end
|
71
92
|
end
|
data/lib/ssl_routes/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ssl_routes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cedric Howe
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2014-01-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|