rack-initforthe-facebook 0.0.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.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in rack-initforthe-facebook.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2012 Initforthe Ltd. http://www.initforthe.com/
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,10 @@
1
+ RACK middleware to:
2
+
3
+ * Parse the Facebook signed requests into the RACK environment.
4
+ * Correct Facebook POST to GET for signed requests.
5
+
6
+ Currently doesn't validate the request signature.
7
+
8
+ The MethodFix middleware relies on the SignedRequest middleware. SignedRequest should be before MethodFix in the chain.
9
+
10
+ Copyright 2012 Initforthe Ltd
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,20 @@
1
+ require "rack-initforthe-facebook/version"
2
+
3
+ module Rack
4
+ module Initforthe
5
+ module Facebook
6
+ class MethodFix
7
+ def initialize(app, options = {})
8
+ @app = app
9
+ end
10
+
11
+ def call(env)
12
+ if env['facebook.signed_request'] && env['REQUEST_METHOD'] == 'POST'
13
+ env['REQUEST_METHOD'] = 'GET'
14
+ end
15
+ @app.call(env)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,27 @@
1
+ require "rack-initforthe-facebook/version"
2
+
3
+ module Rack
4
+ module Initforthe
5
+ module Facebook
6
+ class SignedRequest
7
+ def initialize(app, options = {})
8
+ @app = app
9
+ end
10
+
11
+ def call(env)
12
+ request = Request.new(env)
13
+ if request.params['signed_request']
14
+ env['facebook.signed_request'] = parse_signature(request.params['signed_request'])
15
+ end
16
+ @app.call(env)
17
+ end
18
+
19
+ def parse_signature(signed_request)
20
+ signature, data = signed_request.split('.', 2)
21
+ data << '=' while data.length % 4 > 0
22
+ JSON.parse(Base64.urlsafe_decode64(data))
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,7 @@
1
+ module Rack
2
+ module Initforthe
3
+ module Facebook
4
+ VERSION = "0.0.1"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "rack/initforthe/facebook/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "rack-initforthe-facebook"
7
+ s.version = Rack::Initforthe::Facebook::VERSION
8
+ s.authors = ["Rob Holland"]
9
+ s.email = ["rob@initforthe.com"]
10
+ s.homepage = "http://github.com/initforthe/rack-initforthe-facebook"
11
+ s.summary = %q{Rack middleware for Facebook applications}
12
+ s.description = %q{Rack middleware for Facebook applications}
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ s.require_paths = ["lib"]
18
+
19
+ # specify any dependencies here; for example:
20
+ # s.add_development_dependency "rspec"
21
+ # s.add_runtime_dependency "rest-client"
22
+ end
metadata ADDED
@@ -0,0 +1,54 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rack-initforthe-facebook
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Rob Holland
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-05-26 00:00:00.000000000Z
13
+ dependencies: []
14
+ description: Rack middleware for Facebook applications
15
+ email:
16
+ - rob@initforthe.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - Gemfile
23
+ - LICENSE
24
+ - README.md
25
+ - Rakefile
26
+ - lib/rack/initforthe/facebook/method_fix.rb
27
+ - lib/rack/initforthe/facebook/signed_request.rb
28
+ - lib/rack/initforthe/facebook/version.rb
29
+ - rack-initforthe-facebook.gemspec
30
+ homepage: http://github.com/initforthe/rack-initforthe-facebook
31
+ licenses: []
32
+ post_install_message:
33
+ rdoc_options: []
34
+ require_paths:
35
+ - lib
36
+ required_ruby_version: !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ! '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ required_rubygems_version: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ requirements: []
49
+ rubyforge_project:
50
+ rubygems_version: 1.8.7
51
+ signing_key:
52
+ specification_version: 3
53
+ summary: Rack middleware for Facebook applications
54
+ test_files: []