rack-initforthe-facebook 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -2,8 +2,15 @@
2
2
 
3
3
  ## SignedRequest
4
4
 
5
- Parses the Facebook signed requests into the RACK environment.
6
- Currently doesn't validate the request signature.
5
+ Parses a Facebook signed request or oauth cookie and stores it in the RACK environment.
6
+ In order to parse an fbsr_APP_ID cookie you'll need to pass the :app_id => X option to the middleware.
7
+ This option can be a lambda, in case you have the app ID stored in such a way that it's not available at rackup parsing time.
8
+
9
+ For example, if you are using rails_config, you might configure SignedRequest like so:
10
+
11
+ use Rack::Initforthe::Facebook::SignedRequest, app_id: -> { Settings.facebook.app_id }
12
+
13
+ Note: Currently the signature is not validated.
7
14
 
8
15
  ## MethodFix
9
16
 
@@ -4,12 +4,22 @@ module Rack
4
4
  class SignedRequest
5
5
  def initialize(app, options = {})
6
6
  @app = app
7
+ @options = options
8
+ end
9
+
10
+ def app_id
11
+ @app_id ||= begin
12
+ app_id = @options[:app_id]
13
+ app_id.respond_to?(:call) ? app_id.call : app_id
14
+ end
7
15
  end
8
16
 
9
17
  def call(env)
10
18
  request = Request.new(env)
11
- if request.params['signed_request']
12
- env['facebook.signed_request'] = parse_signature(request.params['signed_request'])
19
+ signature = request.params['signed_request']
20
+ signature ||= request.cookies["fbsr_#{app_id}"] unless app_id.nil?
21
+ if signature
22
+ env['facebook.signed_request'] = parse_signature(signature)
13
23
  end
14
24
  @app.call(env)
15
25
  end
@@ -1,7 +1,7 @@
1
1
  module Rack
2
2
  module Initforthe
3
3
  module Facebook
4
- VERSION = "0.0.5"
4
+ VERSION = "0.0.6"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-initforthe-facebook
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-26 00:00:00.000000000Z
12
+ date: 2012-09-25 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Rack middleware for Facebook applications
15
15
  email:
@@ -50,7 +50,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
50
50
  version: '0'
51
51
  requirements: []
52
52
  rubyforge_project:
53
- rubygems_version: 1.8.7
53
+ rubygems_version: 1.8.23
54
54
  signing_key:
55
55
  specification_version: 3
56
56
  summary: Rack middleware for Facebook applications