facebook_canvas 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/facebook_canvas/engine.rb +1 -1
- data/lib/facebook_canvas/middleware.rb +9 -19
- data/lib/facebook_canvas/version.rb +1 -1
- data/test/dummy/config/application.rb +1 -1
- data/test/dummy/log/test.log +132 -0
- data/test/test_helper.rb +5 -0
- metadata +33 -33
- data/test/integration/navigation_test.rb +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47c574bf93fbef64c7b67edaec3d3ba9cb89d479
|
4
|
+
data.tar.gz: bc29c32d280ef4fb2161460e6b6bc364f30ad61a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 499515ff1f83003d1fed1e2b477729f3eb8dfba217b86a9f7054646b0f4e3b0b779188fc093ea93d513f399c619bf098986dc0322ac0ec09adf3162fe321bbe9
|
7
|
+
data.tar.gz: 0b0100d50c70431695695fa33e2b33e0d73c5fbd81e740029d8c06a63b652705758bd60c01a339a0e9c5bfb310c244fb44ba1a26a6e3b5aab673b8a50e249e0f
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module FacebookCanvas
|
2
2
|
class Engine < ::Rails::Engine
|
3
3
|
initializer "FacebookCanvas.middleware" do |app|
|
4
|
-
server_name = FacebookCanvas.server_name ||
|
4
|
+
server_name = FacebookCanvas.server_name || /.*/
|
5
5
|
app.config.middleware.use FacebookCanvas::Middleware, server_name
|
6
6
|
|
7
7
|
ApplicationController.prepend FacebookCanvas::Helpers
|
@@ -1,17 +1,12 @@
|
|
1
|
-
# This
|
2
|
-
#
|
3
|
-
# config/application.rb
|
4
|
-
#
|
5
|
-
# module FacebookCanvas
|
6
|
-
# class Engine < ::Rails::Engine
|
7
|
-
# ...
|
8
|
-
# initializer "FacebookCanvas.middleware" do |app|
|
9
|
-
# app.config.middleware.use FacebookCanvas::Middleware, /\.fb\./
|
10
|
-
# end
|
11
|
-
# ...
|
12
|
-
# end
|
13
|
-
# end
|
1
|
+
# This middleware modifies the `REQUEST_METHOD` if needed and should be inserted
|
2
|
+
# after the middleware `Rack::MethodOverride`
|
14
3
|
#
|
4
|
+
# All requests coming from Facebook to our canvas are POST requests.
|
5
|
+
# We need to check whether the request was originally a GET request.
|
6
|
+
# We assume that Rails inserts a hidden parameter called `utf8` for all non
|
7
|
+
# GET requests.
|
8
|
+
# So if this parameter is missing, the request is a `GET` request and therefor
|
9
|
+
# we force the `REQUEST_METHOD` to GET.
|
15
10
|
module FacebookCanvas
|
16
11
|
class Middleware
|
17
12
|
def initialize(app, request_host)
|
@@ -19,12 +14,7 @@ module FacebookCanvas
|
|
19
14
|
@request_host = request_host
|
20
15
|
end
|
21
16
|
|
22
|
-
#
|
23
|
-
# We need to check wether the request was originally a GET request.
|
24
|
-
# We assume that rails inserts a hidden parameter with UTF8 for all non
|
25
|
-
# GET requests.
|
26
|
-
# So if this parameter is missing, the request is a GET request and there for
|
27
|
-
# we set the REQUEST_METHOD to GET.
|
17
|
+
# Forces REQUEST_METHOD to GET if required.
|
28
18
|
def call(env)
|
29
19
|
if matches_server_name?(env) && was_get_request?(env)
|
30
20
|
env["REQUEST_METHOD"] = "GET"
|
@@ -0,0 +1,132 @@
|
|
1
|
+
------------------------------
|
2
|
+
FacebookCanvasTest: test_truth
|
3
|
+
------------------------------
|
4
|
+
----------------------------------------------------------------------
|
5
|
+
FacebookCanvas::SignedRequestTest: test_no_user_id_from_signed_request
|
6
|
+
----------------------------------------------------------------------
|
7
|
+
----------------------------------------------------------------------------
|
8
|
+
FacebookCanvas::SignedRequestTest: test_get_access_token_from_signed_request
|
9
|
+
----------------------------------------------------------------------------
|
10
|
+
-----------------------------------------------------------------------
|
11
|
+
FacebookCanvas::SignedRequestTest: test_get_user_id_from_signed_request
|
12
|
+
-----------------------------------------------------------------------
|
13
|
+
--------------------------------------------------
|
14
|
+
FacebookCanvas::SignedRequestTest: test_initialize
|
15
|
+
--------------------------------------------------
|
16
|
+
---------------------------------------------------------------------------
|
17
|
+
FacebookCanvas::SignedRequestTest: test_no_access_token_from_signed_request
|
18
|
+
---------------------------------------------------------------------------
|
19
|
+
--------------------------------------------------------
|
20
|
+
FacebookCanvas::MiddlewareTest: test_do_not_convert_post
|
21
|
+
--------------------------------------------------------
|
22
|
+
Started POST "/foo/create" for 127.0.0.1 at 2016-01-14 15:27:12 +0100
|
23
|
+
Processing by FooController#create as HTML
|
24
|
+
Parameters: {"utf8"=>"utf"}
|
25
|
+
Rendered text template (0.0ms)
|
26
|
+
Completed 200 OK in 3ms (Views: 2.8ms)
|
27
|
+
----------------------------------------------------------------
|
28
|
+
FacebookCanvas::MiddlewareTest: test_convert_post_to_get_request
|
29
|
+
----------------------------------------------------------------
|
30
|
+
Started POST "/foo/index" for 127.0.0.1 at 2016-01-14 15:27:12 +0100
|
31
|
+
Processing by FooController#index as HTML
|
32
|
+
Rendered text template (0.0ms)
|
33
|
+
Completed 200 OK in 0ms (Views: 0.2ms)
|
34
|
+
------------------------------
|
35
|
+
FacebookCanvasTest: test_truth
|
36
|
+
------------------------------
|
37
|
+
-----------------------------------------------------------------------
|
38
|
+
FacebookCanvas::SignedRequestTest: test_get_user_id_from_signed_request
|
39
|
+
-----------------------------------------------------------------------
|
40
|
+
----------------------------------------------------------------------
|
41
|
+
FacebookCanvas::SignedRequestTest: test_no_user_id_from_signed_request
|
42
|
+
----------------------------------------------------------------------
|
43
|
+
--------------------------------------------------
|
44
|
+
FacebookCanvas::SignedRequestTest: test_initialize
|
45
|
+
--------------------------------------------------
|
46
|
+
---------------------------------------------------------------------------
|
47
|
+
FacebookCanvas::SignedRequestTest: test_no_access_token_from_signed_request
|
48
|
+
---------------------------------------------------------------------------
|
49
|
+
----------------------------------------------------------------------------
|
50
|
+
FacebookCanvas::SignedRequestTest: test_get_access_token_from_signed_request
|
51
|
+
----------------------------------------------------------------------------
|
52
|
+
--------------------------------------------------------
|
53
|
+
FacebookCanvas::MiddlewareTest: test_do_not_convert_post
|
54
|
+
--------------------------------------------------------
|
55
|
+
Started POST "/foo/create" for 127.0.0.1 at 2016-01-14 15:27:16 +0100
|
56
|
+
Processing by FooController#create as HTML
|
57
|
+
Parameters: {"utf8"=>"utf"}
|
58
|
+
Rendered text template (0.0ms)
|
59
|
+
Completed 200 OK in 2ms (Views: 2.2ms)
|
60
|
+
----------------------------------------------------------------
|
61
|
+
FacebookCanvas::MiddlewareTest: test_convert_post_to_get_request
|
62
|
+
----------------------------------------------------------------
|
63
|
+
Started POST "/foo/index" for 127.0.0.1 at 2016-01-14 15:27:16 +0100
|
64
|
+
Processing by FooController#index as HTML
|
65
|
+
Rendered text template (0.0ms)
|
66
|
+
Completed 200 OK in 0ms (Views: 0.1ms)
|
67
|
+
------------------------------
|
68
|
+
FacebookCanvasTest: test_truth
|
69
|
+
------------------------------
|
70
|
+
----------------------------------------------------------------
|
71
|
+
FacebookCanvas::MiddlewareTest: test_convert_post_to_get_request
|
72
|
+
----------------------------------------------------------------
|
73
|
+
Started POST "/foo/index" for 127.0.0.1 at 2016-01-14 15:47:21 +0100
|
74
|
+
Processing by FooController#index as HTML
|
75
|
+
Rendered text template (0.0ms)
|
76
|
+
Completed 200 OK in 2ms (Views: 2.2ms)
|
77
|
+
--------------------------------------------------------
|
78
|
+
FacebookCanvas::MiddlewareTest: test_do_not_convert_post
|
79
|
+
--------------------------------------------------------
|
80
|
+
Started POST "/foo/create" for 127.0.0.1 at 2016-01-14 15:47:21 +0100
|
81
|
+
Processing by FooController#create as HTML
|
82
|
+
Parameters: {"utf8"=>"utf"}
|
83
|
+
Rendered text template (0.0ms)
|
84
|
+
Completed 200 OK in 0ms (Views: 0.1ms)
|
85
|
+
--------------------------------------------------
|
86
|
+
FacebookCanvas::SignedRequestTest: test_initialize
|
87
|
+
--------------------------------------------------
|
88
|
+
----------------------------------------------------------------------------
|
89
|
+
FacebookCanvas::SignedRequestTest: test_get_access_token_from_signed_request
|
90
|
+
----------------------------------------------------------------------------
|
91
|
+
---------------------------------------------------------------------------
|
92
|
+
FacebookCanvas::SignedRequestTest: test_no_access_token_from_signed_request
|
93
|
+
---------------------------------------------------------------------------
|
94
|
+
-----------------------------------------------------------------------
|
95
|
+
FacebookCanvas::SignedRequestTest: test_get_user_id_from_signed_request
|
96
|
+
-----------------------------------------------------------------------
|
97
|
+
----------------------------------------------------------------------
|
98
|
+
FacebookCanvas::SignedRequestTest: test_no_user_id_from_signed_request
|
99
|
+
----------------------------------------------------------------------
|
100
|
+
------------------------------
|
101
|
+
FacebookCanvasTest: test_truth
|
102
|
+
------------------------------
|
103
|
+
--------------------------------------------------
|
104
|
+
FacebookCanvas::SignedRequestTest: test_initialize
|
105
|
+
--------------------------------------------------
|
106
|
+
-----------------------------------------------------------------------
|
107
|
+
FacebookCanvas::SignedRequestTest: test_get_user_id_from_signed_request
|
108
|
+
-----------------------------------------------------------------------
|
109
|
+
----------------------------------------------------------------------
|
110
|
+
FacebookCanvas::SignedRequestTest: test_no_user_id_from_signed_request
|
111
|
+
----------------------------------------------------------------------
|
112
|
+
----------------------------------------------------------------------------
|
113
|
+
FacebookCanvas::SignedRequestTest: test_get_access_token_from_signed_request
|
114
|
+
----------------------------------------------------------------------------
|
115
|
+
---------------------------------------------------------------------------
|
116
|
+
FacebookCanvas::SignedRequestTest: test_no_access_token_from_signed_request
|
117
|
+
---------------------------------------------------------------------------
|
118
|
+
----------------------------------------------------------------
|
119
|
+
FacebookCanvas::MiddlewareTest: test_convert_post_to_get_request
|
120
|
+
----------------------------------------------------------------
|
121
|
+
Started POST "/foo/index" for 127.0.0.1 at 2016-01-14 15:48:01 +0100
|
122
|
+
Processing by FooController#index as HTML
|
123
|
+
Rendered text template (0.0ms)
|
124
|
+
Completed 200 OK in 2ms (Views: 2.1ms)
|
125
|
+
--------------------------------------------------------
|
126
|
+
FacebookCanvas::MiddlewareTest: test_do_not_convert_post
|
127
|
+
--------------------------------------------------------
|
128
|
+
Started POST "/foo/create" for 127.0.0.1 at 2016-01-14 15:48:01 +0100
|
129
|
+
Processing by FooController#create as HTML
|
130
|
+
Parameters: {"utf8"=>"utf"}
|
131
|
+
Rendered text template (0.0ms)
|
132
|
+
Completed 200 OK in 0ms (Views: 0.1ms)
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: facebook_canvas
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- André Stuhrmann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -87,6 +87,7 @@ files:
|
|
87
87
|
- test/dummy/config/locales/en.yml
|
88
88
|
- test/dummy/config/routes.rb
|
89
89
|
- test/dummy/config/secrets.yml
|
90
|
+
- test/dummy/log/test.log
|
90
91
|
- test/dummy/public/404.html
|
91
92
|
- test/dummy/public/422.html
|
92
93
|
- test/dummy/public/500.html
|
@@ -96,7 +97,6 @@ files:
|
|
96
97
|
- test/fixtures/signed_request.txt
|
97
98
|
- test/fixtures/signed_request_with_user_id.txt
|
98
99
|
- test/integration/middleware_test.rb
|
99
|
-
- test/integration/navigation_test.rb
|
100
100
|
- test/test_helper.rb
|
101
101
|
homepage:
|
102
102
|
licenses:
|
@@ -118,51 +118,51 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
118
|
version: '0'
|
119
119
|
requirements: []
|
120
120
|
rubyforge_project:
|
121
|
-
rubygems_version: 2.4.
|
121
|
+
rubygems_version: 2.4.6
|
122
122
|
signing_key:
|
123
123
|
specification_version: 4
|
124
124
|
summary: Rails engine for Facebook's canvas integration.
|
125
125
|
test_files:
|
126
126
|
- test/facebook_canvas/signed_request_test.rb
|
127
|
-
- test/
|
128
|
-
- test/
|
127
|
+
- test/facebook_canvas_test.rb
|
128
|
+
- test/dummy/README.rdoc
|
129
|
+
- test/dummy/app/assets/stylesheets/application.css
|
130
|
+
- test/dummy/app/assets/javascripts/application.js
|
131
|
+
- test/dummy/app/controllers/foo_controller.rb
|
132
|
+
- test/dummy/app/controllers/application_controller.rb
|
133
|
+
- test/dummy/app/views/foo/create.haml
|
134
|
+
- test/dummy/app/views/layouts/application.html.erb
|
135
|
+
- test/dummy/app/helpers/application_helper.rb
|
129
136
|
- test/dummy/config/application.rb
|
130
|
-
- test/dummy/config/
|
131
|
-
- test/dummy/config/
|
137
|
+
- test/dummy/config/initializers/session_store.rb
|
138
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
139
|
+
- test/dummy/config/initializers/assets.rb
|
140
|
+
- test/dummy/config/initializers/filter_parameter_logging.rb
|
132
141
|
- test/dummy/config/initializers/cookies_serializer.rb
|
142
|
+
- test/dummy/config/initializers/inflections.rb
|
133
143
|
- test/dummy/config/initializers/backtrace_silencers.rb
|
134
144
|
- test/dummy/config/initializers/mime_types.rb
|
135
|
-
- test/dummy/config/initializers/assets.rb
|
136
|
-
- test/dummy/config/initializers/wrap_parameters.rb
|
137
|
-
- test/dummy/config/initializers/session_store.rb
|
138
|
-
- test/dummy/config/initializers/inflections.rb
|
139
|
-
- test/dummy/config/initializers/filter_parameter_logging.rb
|
140
|
-
- test/dummy/config/environments/production.rb
|
141
|
-
- test/dummy/config/environments/test.rb
|
142
|
-
- test/dummy/config/environments/development.rb
|
143
145
|
- test/dummy/config/locales/en.yml
|
146
|
+
- test/dummy/config/routes.rb
|
147
|
+
- test/dummy/config/environments/development.rb
|
148
|
+
- test/dummy/config/environments/test.rb
|
149
|
+
- test/dummy/config/environments/production.rb
|
144
150
|
- test/dummy/config/environment.rb
|
151
|
+
- test/dummy/config/database.yml
|
145
152
|
- test/dummy/config/boot.rb
|
146
153
|
- test/dummy/config/secrets.yml
|
147
|
-
- test/dummy/config.ru
|
148
|
-
- test/dummy/bin/bundle
|
149
|
-
- test/dummy/bin/rake
|
150
|
-
- test/dummy/bin/rails
|
151
|
-
- test/dummy/bin/setup
|
152
154
|
- test/dummy/Rakefile
|
153
|
-
- test/dummy/README.rdoc
|
154
|
-
- test/dummy/app/assets/stylesheets/application.css
|
155
|
-
- test/dummy/app/assets/javascripts/application.js
|
156
|
-
- test/dummy/app/helpers/application_helper.rb
|
157
|
-
- test/dummy/app/controllers/foo_controller.rb
|
158
|
-
- test/dummy/app/controllers/application_controller.rb
|
159
|
-
- test/dummy/app/views/foo/create.haml
|
160
|
-
- test/dummy/app/views/layouts/application.html.erb
|
161
155
|
- test/dummy/public/favicon.ico
|
156
|
+
- test/dummy/public/422.html
|
162
157
|
- test/dummy/public/404.html
|
163
158
|
- test/dummy/public/500.html
|
164
|
-
- test/dummy/
|
165
|
-
- test/
|
166
|
-
- test/
|
167
|
-
- test/
|
159
|
+
- test/dummy/log/test.log
|
160
|
+
- test/dummy/bin/setup
|
161
|
+
- test/dummy/bin/rake
|
162
|
+
- test/dummy/bin/rails
|
163
|
+
- test/dummy/bin/bundle
|
164
|
+
- test/dummy/config.ru
|
168
165
|
- test/fixtures/signed_request.txt
|
166
|
+
- test/fixtures/signed_request_with_user_id.txt
|
167
|
+
- test/test_helper.rb
|
168
|
+
- test/integration/middleware_test.rb
|