ruby-satisfaction 0.6.3 → 0.6.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/README.markdown +5 -1
- data/lib/satisfaction/associations.rb +13 -8
- data/lib/satisfaction/loader.rb +17 -3
- data/lib/satisfaction/resource/attributes.rb +7 -5
- data/lib/satisfaction/version.rb +1 -1
- metadata +4 -4
data/Gemfile.lock
CHANGED
data/README.markdown
CHANGED
@@ -11,8 +11,12 @@ For questions, please visit the [Get Satisfaction API community][3]
|
|
11
11
|
|
12
12
|
Changelog
|
13
13
|
=========
|
14
|
+
0.6.4
|
14
15
|
|
15
|
-
|
16
|
+
* Fixed a security issue with the resource associations and attributes.
|
17
|
+
* Provide a more descriptive error message when the client tries to access a community that has restricted its identity provider.
|
18
|
+
|
19
|
+
0.6.3
|
16
20
|
|
17
21
|
* Fixed known issue with scoping. Calling resource methods could potentially change scope for
|
18
22
|
other objects. For example:
|
@@ -1,20 +1,25 @@
|
|
1
1
|
module Associations
|
2
|
+
|
2
3
|
def has_many(resource, options={})
|
3
4
|
class_name = options[:class_name] || "Sfn::#{resource.to_s.classify}"
|
4
|
-
|
5
|
-
|
6
|
-
|
5
|
+
|
6
|
+
class_eval do
|
7
|
+
define_method resource do
|
8
|
+
instance_variable_get("@#{resource}") ||
|
9
|
+
instance_variable_set("@#{resource}", Sfn::ResourceCollection.new(class_name.constantize, self.satisfaction, options[:url]))
|
7
10
|
end
|
8
|
-
|
11
|
+
end
|
9
12
|
end
|
10
13
|
|
11
14
|
def belongs_to(resource, options={})
|
12
15
|
class_name = options[:class_name] || "Sfn::#{resource.to_s.classify}"
|
13
16
|
parent_id = options[:parent_attribute] || "#{resource}_id"
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
+
|
18
|
+
class_eval do
|
19
|
+
define_method resource do
|
20
|
+
instance_variable_get("@#{resource}") ||
|
21
|
+
instance_variable_set("@#{resource}", class_name.constantize.new(parent_id, self.satisfaction))
|
17
22
|
end
|
18
|
-
|
23
|
+
end
|
19
24
|
end
|
20
25
|
end
|
data/lib/satisfaction/loader.rb
CHANGED
@@ -48,7 +48,14 @@ class Sfn::Loader
|
|
48
48
|
when Net::HTTPBadRequest
|
49
49
|
raise Sfn::BadRequest, "Bad request. Response body:\n" + response.body
|
50
50
|
when Net::HTTPForbidden, Net::HTTPUnauthorized
|
51
|
-
|
51
|
+
message = "Not authorized"
|
52
|
+
if restricted_provider = response['X-Sfn-Restricted-Identity-Provider']
|
53
|
+
message += " - Restricted to login provider"
|
54
|
+
if restricted_provider != 'yes'
|
55
|
+
message += " #{restricted_provider.capitalize}"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
raise Sfn::AuthorizationError, message
|
52
59
|
when Net::HTTPNotFound
|
53
60
|
raise Sfn::NotFound, "Not found"
|
54
61
|
when Net::HTTPServiceUnavailable
|
@@ -75,10 +82,17 @@ class Sfn::Loader
|
|
75
82
|
http = Net::HTTP.new(uri.host, uri.port)
|
76
83
|
add_authentication(request, http, options)
|
77
84
|
response = execute(http, request)
|
78
|
-
|
85
|
+
|
79
86
|
case response
|
80
87
|
when Net::HTTPForbidden, Net::HTTPUnauthorized
|
81
|
-
|
88
|
+
message = "Not authorized"
|
89
|
+
if restricted_provider = response['X-Sfn-Restricted-Identity-Provider']
|
90
|
+
message += " - Restricted to login provider"
|
91
|
+
if restricted_provider != 'yes'
|
92
|
+
message += " #{restricted_provider.capitalize}"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
raise Sfn::AuthorizationError, message
|
82
96
|
when Net::HTTPNotFound
|
83
97
|
raise Sfn::NotFound, "Not found"
|
84
98
|
when Net::HTTPBadRequest
|
@@ -21,12 +21,14 @@ module Sfn::Resource::Attributes
|
|
21
21
|
options.reverse_merge!(:type => 'nil')
|
22
22
|
raise "Name can't be empty" if name.blank?
|
23
23
|
|
24
|
-
class_eval
|
25
|
-
|
24
|
+
class_eval do
|
25
|
+
define_method name do
|
26
26
|
self.load unless self.loaded?
|
27
|
-
|
27
|
+
|
28
|
+
instance_variable_get("@#{name}") ||
|
29
|
+
(@attributes && instance_variable_set("@#{name}", decode_raw_attribute(@attributes[name], options[:type])))
|
28
30
|
end
|
29
|
-
|
31
|
+
end
|
30
32
|
end
|
31
33
|
|
32
34
|
end
|
@@ -64,4 +66,4 @@ class Sfn::Resource
|
|
64
66
|
new(value, satisfaction)
|
65
67
|
end
|
66
68
|
end
|
67
|
-
end
|
69
|
+
end
|
data/lib/satisfaction/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-satisfaction
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
9
|
+
- 4
|
10
|
+
version: 0.6.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Get Satisfaction
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-04-08 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|