bartt-ssl_requirement 1.4.0 → 1.4.1
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/README.md +10 -0
- data/VERSION +1 -1
- data/lib/ssl_requirement.rb +17 -10
- metadata +3 -3
data/README.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
Installing
|
2
|
+
==========
|
3
|
+
|
4
|
+
This version of SSL Requirement is **only** compatible with Rails 3.x. To install add the following line to your project's
|
5
|
+
`Gemfile`:
|
6
|
+
|
7
|
+
gem 'bartt-ssl_requirement', '~>1.4.0', :require => 'ssl_requirement'
|
8
|
+
|
9
|
+
`bartt-ssl_requirement` is compatible with ruby 1.8.7 and 1.9.x.
|
10
|
+
|
1
11
|
SSL Requirement
|
2
12
|
===============
|
3
13
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.4.
|
1
|
+
1.4.1
|
data/lib/ssl_requirement.rb
CHANGED
@@ -22,6 +22,8 @@ require "active_support/core_ext/class"
|
|
22
22
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
23
23
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
24
24
|
module SslRequirement
|
25
|
+
extend ActiveSupport::Concern
|
26
|
+
|
25
27
|
mattr_writer :ssl_host, :ssl_port, :non_ssl_host, :disable_ssl_check
|
26
28
|
mattr_accessor :redirect_status
|
27
29
|
|
@@ -55,34 +57,39 @@ module SslRequirement
|
|
55
57
|
end
|
56
58
|
|
57
59
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
60
|
+
included do
|
61
|
+
class_attribute :ssl_required_actions
|
62
|
+
class_attribute :ssl_required_except_actions
|
63
|
+
class_attribute :ssl_allowed_actions
|
64
|
+
|
65
|
+
before_filter :ensure_proper_protocol
|
62
66
|
end
|
63
67
|
|
64
68
|
module ClassMethods
|
65
69
|
# Specifies that the named actions requires an SSL connection to be performed (which is enforced by ensure_proper_protocol).
|
66
70
|
def ssl_required(*actions)
|
67
|
-
|
71
|
+
self.ssl_required_actions ||= []
|
72
|
+
self.ssl_required_actions += actions
|
68
73
|
end
|
69
74
|
|
70
75
|
def ssl_exceptions(*actions)
|
71
|
-
|
76
|
+
self.ssl_required_except_actions ||= []
|
77
|
+
self.ssl_required_except_actions += actions
|
72
78
|
end
|
73
79
|
|
74
80
|
# To allow SSL for any action pass :all as action like this:
|
75
81
|
# ssl_allowed :all
|
76
82
|
def ssl_allowed(*actions)
|
77
|
-
|
83
|
+
self.ssl_allowed_actions ||= []
|
84
|
+
self.ssl_allowed_actions += actions
|
78
85
|
end
|
79
86
|
end
|
80
87
|
|
81
88
|
protected
|
82
89
|
# Returns true if the current action is supposed to run as SSL
|
83
90
|
def ssl_required?
|
84
|
-
required =
|
85
|
-
except = self.class.
|
91
|
+
required = self.class.ssl_required_actions || []
|
92
|
+
except = self.class.ssl_required_except_actions
|
86
93
|
|
87
94
|
unless except
|
88
95
|
required.include?(action_name.to_sym)
|
@@ -92,7 +99,7 @@ module SslRequirement
|
|
92
99
|
end
|
93
100
|
|
94
101
|
def ssl_allowed?
|
95
|
-
allowed_actions =
|
102
|
+
allowed_actions = self.class.ssl_allowed_actions || []
|
96
103
|
|
97
104
|
allowed_actions == [:all] || allowed_actions.include?(action_name.to_sym)
|
98
105
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bartt-ssl_requirement
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -17,7 +17,7 @@ authors:
|
|
17
17
|
autorequire:
|
18
18
|
bindir: bin
|
19
19
|
cert_chain: []
|
20
|
-
date:
|
20
|
+
date: 2012-01-03 00:00:00.000000000 Z
|
21
21
|
dependencies: []
|
22
22
|
description: SSL requirement adds a declarative way of specifying that certain actions
|
23
23
|
should only be allowed to run under SSL, and if they're accessed without it, they
|
@@ -58,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
58
58
|
version: 1.3.6
|
59
59
|
requirements: []
|
60
60
|
rubyforge_project:
|
61
|
-
rubygems_version: 1.8.
|
61
|
+
rubygems_version: 1.8.6
|
62
62
|
signing_key:
|
63
63
|
specification_version: 3
|
64
64
|
summary: Allow controller actions to force SSL on specific parts of the site.
|