ruby-satisfaction 0.6.3 → 0.6.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/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby-satisfaction (0.6.1)
4
+ ruby-satisfaction (0.6.3)
5
5
  activesupport (~> 2.3)
6
6
  json (>= 1.4.6)
7
7
  memcache-client (>= 1.5.0)
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
- 0.6.2
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
- eval <<-EOS
5
- def self.#{resource}
6
- @#{resource} ||= Sfn::ResourceCollection.new(#{class_name}, self.satisfaction, '#{options[:url]}')
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
- EOS
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
- eval <<-EOS
15
- def self.#{resource}
16
- @#{resource} ||= #{class_name}.new(#{parent_id}, self.satisfaction)
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
- EOS
23
+ end
19
24
  end
20
25
  end
@@ -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
- raise Sfn::AuthorizationError, "Not authorized"
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
- raise Sfn::AuthorizationError, "Not authorized"
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 <<-EOS
25
- def #{name}
24
+ class_eval do
25
+ define_method name do
26
26
  self.load unless self.loaded?
27
- @#{name} ||= decode_raw_attribute(@attributes['#{name}'], #{options[:type]}) if @attributes
27
+
28
+ instance_variable_get("@#{name}") ||
29
+ (@attributes && instance_variable_set("@#{name}", decode_raw_attribute(@attributes[name], options[:type])))
28
30
  end
29
- EOS
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
@@ -2,7 +2,7 @@ module Satisfaction
2
2
  module VERSION
3
3
  MAJOR = 0
4
4
  MINOR = 6
5
- PATCH = 3
5
+ PATCH = 4
6
6
  PRE = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.')
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: 1
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 3
10
- version: 0.6.3
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: 2010-12-14 00:00:00 -08:00
18
+ date: 2011-04-08 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency