fbauth 0.9.9.3 → 0.9.9.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.
@@ -36,6 +36,9 @@ private
36
36
  # If no valid session auth or params auth, last chance try the JS SDK
37
37
  data = parse_cookie
38
38
  auth = validate_and_save(data) unless data.nil?
39
+
40
+ logger.warn("Unable to parse any security params for request - cold authentication required")
41
+
39
42
  return auth
40
43
  end
41
44
 
@@ -53,6 +56,7 @@ private
53
56
  unless session[:fbauth].nil?
54
57
  begin
55
58
  parms = JSON.parse(session[:fbauth])
59
+ logger.warn("Parsed facebook params from existing rails session")
56
60
  rescue => e
57
61
  session[:fbauth] = nil
58
62
  end
@@ -65,22 +69,12 @@ private
65
69
  parms = JSON.parse(params[:session])
66
70
  logger.warn("Parsed facebook params from session parameter (deprecated)")
67
71
  elsif params[:signed_request].present?
68
- sig, b64udata = params[:signed_request].split('.')
69
- json = b64udata.tr('-_', '+/').unpack('m')[0]
70
72
  begin
71
- parms = JSON.parse(json)
73
+ parms = FacebookDecoder.decode(params[:signed_request])
74
+ logger.warn("Parsed facebook params from signed_request parameter")
72
75
  rescue => e
73
- begin
74
- parms = JSON.parse(json + '"}')
75
- rescue => e2
76
- begin
77
- parms = JSON.parse(json + '}')
78
- rescue => e3
79
- parms = {}
80
- end
81
- end
76
+ logger.warn("Error with signed_request data: #{e}")
82
77
  end
83
- logger.warn("Parsed facebook params from signed_request parameter")
84
78
  end
85
79
  parms
86
80
  end
@@ -93,6 +87,7 @@ private
93
87
  key, value = pair.split("=")
94
88
  parms[key] = value
95
89
  end
90
+ logger.warn("Parsed facebook params from cookie")
96
91
  end
97
92
  parms
98
93
  end
@@ -0,0 +1,29 @@
1
+ require 'active_support'
2
+
3
+ class FacebookDecoder
4
+
5
+ def self.decode data
6
+ unless data.nil?
7
+ sig, b64udata = data.split('.')
8
+ unless b64udata.nil?
9
+ json = b64udata.tr('-_', '+/').unpack('m')[0]
10
+ begin
11
+ parms = JSON.parse(json)
12
+ rescue => e
13
+ begin
14
+ parms = JSON.parse(json + '"}')
15
+ rescue => e2
16
+ begin
17
+ parms = JSON.parse(json + '}')
18
+ rescue => e3
19
+ raise "Unable to parse json structure - '#{json}'"
20
+ parms = {}
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ parms
27
+ end
28
+
29
+ end
data/lib/fbauth.rb CHANGED
@@ -9,6 +9,7 @@
9
9
  end
10
10
  end
11
11
 
12
+ require 'facebook_decoder.rb'
12
13
  require 'facebook_auth.rb'
13
14
  require 'facebook_config.rb'
14
15
  require 'facebook_graph.rb'
metadata CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
6
6
  - 0
7
7
  - 9
8
8
  - 9
9
- - 3
10
- version: 0.9.9.3
9
+ - 4
10
+ version: 0.9.9.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Three Wise Men Inc.
@@ -30,6 +30,7 @@ extra_rdoc_files:
30
30
  files:
31
31
  - lib/facebook_auth.rb
32
32
  - lib/facebook_config.rb
33
+ - lib/facebook_decoder.rb
33
34
  - lib/facebook_graph.rb
34
35
  - lib/fbauth.rb
35
36
  - app/controllers/facebook_auth_functions.rb