ssl_routes 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -25,10 +25,10 @@ module SslRoutes::Controller
25
25
  if self.enable_ssl
26
26
  case options
27
27
  when Hash
28
- current = request.protocol.split(':').first
29
- target = extract_protocol(options)
30
- if current != target
31
- options.merge!({ :protocol => target, :only_path => false })
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
- current = request.protocol.split(':').first
47
- target = extract_protocol(options)
48
- if current != target && !request.xhr? && request.get?
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 "#{target}://#{request.host_with_port + request.request_uri}"
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 extract_protocol(options)
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
@@ -1,5 +1,5 @@
1
1
  module SslRoutes
2
2
 
3
- VERSION = '0.0.7'
3
+ VERSION = '0.0.8'
4
4
 
5
5
  end
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: 17
5
- prerelease: false
4
+ hash: 15
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 7
10
- version: 0.0.7
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-11 00:00:00 -05:00
18
+ date: 2011-07-01 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: rails
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
- version_requirements: *id001
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.3.7
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.