fb_util 0.0.7 → 0.0.7.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.
Files changed (2) hide show
  1. data/lib/fb_util.rb +11 -5
  2. metadata +2 -2
data/lib/fb_util.rb CHANGED
@@ -175,11 +175,10 @@ class FBUtil
175
175
 
176
176
  # These are the methods that don't need to be called with an instanciated class because they don't need an access token
177
177
  class << self
178
- def base64_url_decode(encoded_url)
179
- encoded_url += '=' * (4 - encoded_url.length.modulo(4))
180
- Base64.decode64(encoded_url.gsub('-', '+').gsub('_', '/'))
181
- end
182
-
178
+ # This method will parse out a signed request using all the necessary validation required to find out if a facebook request is completely valid
179
+ # signed_request: the signed request passed in by facebook
180
+ # application_secret: the application secret assigned to your application form facebook
181
+ # max_age: the allowed age of the signed request. Defaults to 1 hour
183
182
  def parse_signed_request(signed_request, application_secret, max_age = 3600)
184
183
  encoded_signature, encoded_json = signed_request.split('.', 2)
185
184
  json = JSON.parse(base64_url_decode(encoded_json))
@@ -195,5 +194,12 @@ class FBUtil
195
194
 
196
195
  return json
197
196
  end
197
+
198
+ private
199
+ # This is a modifed Base64 decode method to ensure that the request ends with the proper amount of equals signs. Base64 is supposed to have a multple of 4 characters in it. i.e. 12341234. If it doesn't have a multiple of 4 characters in it then it is supposed to pad the string with equals signs. i.e. 1234123412== This method will do this.
200
+ def base64_url_decode(encoded_url)
201
+ encoded_url += '=' * (4 - encoded_url.length.modulo(4))
202
+ Base64.decode64(encoded_url.gsub('-', '+').gsub('_', '/'))
203
+ end
198
204
  end
199
205
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fb_util
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.7.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -35,7 +35,7 @@ extensions: []
35
35
  extra_rdoc_files: []
36
36
  files:
37
37
  - lib/fb_util.rb
38
- homepage: http://rubygems.org/gems/fb_util
38
+ homepage: https://github.com/jbrennon/fb_util
39
39
  licenses: []
40
40
  post_install_message:
41
41
  rdoc_options: []