facebook_canvas 0.2.0 → 0.3.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.rb +2 -2
- data/lib/facebook_canvas/engine.rb +2 -1
- data/lib/facebook_canvas/middleware.rb +10 -2
- data/lib/facebook_canvas/version.rb +1 -1
- data/test/dummy/log/test.log +26 -59
- metadata +32 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a75530a3520a376ea8e0d60110a2129f245ecd96
|
4
|
+
data.tar.gz: 21dbb6d5b06cc10e573ca7627b232d386d64f7f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 593ab5653ea5e81ec4f09fea3f1a006e76e983ba57c495abde4b6ec33ed21a166267b3c1ae3d2202cf66bdaf19a0a5d3da1001d90663f517dfb97b34c5ef968d
|
7
|
+
data.tar.gz: 6a2761bcde58727ad5f48c5e0e632a72bb2c6d0f743d366b7e492409b12ea885f619ff697d32f60cb8cb4394cac491ddc5ed715c320e07e5d889b92230ee652a
|
data/lib/facebook_canvas.rb
CHANGED
@@ -2,7 +2,8 @@ module FacebookCanvas
|
|
2
2
|
class Engine < ::Rails::Engine
|
3
3
|
initializer "FacebookCanvas.middleware" do |app|
|
4
4
|
server_name = FacebookCanvas.server_name || /.*/
|
5
|
-
|
5
|
+
custom_filter = FacebookCanvas.custom_filter || proc { |_env| true }
|
6
|
+
app.config.middleware.use FacebookCanvas::Middleware, server_name, custom_filter
|
6
7
|
|
7
8
|
ApplicationController.prepend FacebookCanvas::Helpers
|
8
9
|
end
|
@@ -5,18 +5,22 @@
|
|
5
5
|
# We need to check whether the request was originally a GET request.
|
6
6
|
# We assume that Rails inserts a hidden parameter called `utf8` for all non
|
7
7
|
# GET requests.
|
8
|
+
#
|
8
9
|
# So if this parameter is missing, the request is a `GET` request and therefor
|
9
10
|
# we force the `REQUEST_METHOD` to GET.
|
11
|
+
#
|
12
|
+
# Addionally you can restrict `REQUEST_METHOD` rewriting by providing a `custom_filter` block.
|
10
13
|
module FacebookCanvas
|
11
14
|
class Middleware
|
12
|
-
def initialize(app, request_host)
|
15
|
+
def initialize(app, request_host, custom_filter)
|
13
16
|
@app = app
|
14
17
|
@request_host = request_host
|
18
|
+
@custom_filter = custom_filter
|
15
19
|
end
|
16
20
|
|
17
21
|
# Forces REQUEST_METHOD to GET if required.
|
18
22
|
def call(env)
|
19
|
-
if matches_server_name?(env) && was_get_request?(env)
|
23
|
+
if matches_server_name?(env) && was_get_request?(env) && custom_filter?(env)
|
20
24
|
env["REQUEST_METHOD"] = "GET"
|
21
25
|
end
|
22
26
|
@app.call env
|
@@ -32,5 +36,9 @@ module FacebookCanvas
|
|
32
36
|
form_hash = env["rack.request.form_hash"] || {}
|
33
37
|
!form_hash["utf8"]
|
34
38
|
end
|
39
|
+
|
40
|
+
def custom_filter?(env)
|
41
|
+
@custom_filter.call(env)
|
42
|
+
end
|
35
43
|
end
|
36
44
|
end
|
data/test/dummy/log/test.log
CHANGED
@@ -1,12 +1,6 @@
|
|
1
1
|
------------------------------
|
2
2
|
FacebookCanvasTest: test_truth
|
3
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
4
|
-----------------------------------------------------------------------
|
11
5
|
FacebookCanvas::SignedRequestTest: test_get_user_id_from_signed_request
|
12
6
|
-----------------------------------------------------------------------
|
@@ -16,90 +10,81 @@ FacebookCanvas::SignedRequestTest: test_initialize
|
|
16
10
|
---------------------------------------------------------------------------
|
17
11
|
FacebookCanvas::SignedRequestTest: test_no_access_token_from_signed_request
|
18
12
|
---------------------------------------------------------------------------
|
13
|
+
----------------------------------------------------------------------
|
14
|
+
FacebookCanvas::SignedRequestTest: test_no_user_id_from_signed_request
|
15
|
+
----------------------------------------------------------------------
|
16
|
+
----------------------------------------------------------------------------
|
17
|
+
FacebookCanvas::SignedRequestTest: test_get_access_token_from_signed_request
|
18
|
+
----------------------------------------------------------------------------
|
19
19
|
--------------------------------------------------------
|
20
20
|
FacebookCanvas::MiddlewareTest: test_do_not_convert_post
|
21
21
|
--------------------------------------------------------
|
22
|
-
Started POST "/foo/create" for 127.0.0.1 at
|
22
|
+
Started POST "/foo/create" for 127.0.0.1 at 2015-12-03 14:47:24 +0100
|
23
23
|
Processing by FooController#create as HTML
|
24
24
|
Parameters: {"utf8"=>"utf"}
|
25
25
|
Rendered text template (0.0ms)
|
26
|
-
Completed 200 OK in
|
26
|
+
Completed 200 OK in 4ms (Views: 4.0ms)
|
27
27
|
----------------------------------------------------------------
|
28
28
|
FacebookCanvas::MiddlewareTest: test_convert_post_to_get_request
|
29
29
|
----------------------------------------------------------------
|
30
|
-
Started POST "/foo/index" for 127.0.0.1 at
|
30
|
+
Started POST "/foo/index" for 127.0.0.1 at 2015-12-03 14:47:24 +0100
|
31
31
|
Processing by FooController#index as HTML
|
32
32
|
Rendered text template (0.0ms)
|
33
33
|
Completed 200 OK in 0ms (Views: 0.2ms)
|
34
|
-
|
35
|
-
|
36
|
-
|
34
|
+
---------------------------------------------------------------------------
|
35
|
+
FacebookCanvas::SignedRequestTest: test_no_access_token_from_signed_request
|
36
|
+
---------------------------------------------------------------------------
|
37
37
|
-----------------------------------------------------------------------
|
38
38
|
FacebookCanvas::SignedRequestTest: test_get_user_id_from_signed_request
|
39
39
|
-----------------------------------------------------------------------
|
40
|
-
----------------------------------------------------------------------
|
41
|
-
FacebookCanvas::SignedRequestTest: test_no_user_id_from_signed_request
|
42
|
-
----------------------------------------------------------------------
|
43
40
|
--------------------------------------------------
|
44
41
|
FacebookCanvas::SignedRequestTest: test_initialize
|
45
42
|
--------------------------------------------------
|
46
|
-
|
47
|
-
FacebookCanvas::SignedRequestTest:
|
48
|
-
|
43
|
+
----------------------------------------------------------------------
|
44
|
+
FacebookCanvas::SignedRequestTest: test_no_user_id_from_signed_request
|
45
|
+
----------------------------------------------------------------------
|
49
46
|
----------------------------------------------------------------------------
|
50
47
|
FacebookCanvas::SignedRequestTest: test_get_access_token_from_signed_request
|
51
48
|
----------------------------------------------------------------------------
|
52
49
|
--------------------------------------------------------
|
53
50
|
FacebookCanvas::MiddlewareTest: test_do_not_convert_post
|
54
51
|
--------------------------------------------------------
|
55
|
-
Started POST "/foo/create" for 127.0.0.1 at 2016-
|
52
|
+
Started POST "/foo/create" for 127.0.0.1 at 2016-02-04 13:27:17 +0100
|
56
53
|
Processing by FooController#create as HTML
|
57
54
|
Parameters: {"utf8"=>"utf"}
|
58
55
|
Rendered text template (0.0ms)
|
59
|
-
Completed 200 OK in
|
56
|
+
Completed 200 OK in 7ms (Views: 6.4ms)
|
60
57
|
----------------------------------------------------------------
|
61
58
|
FacebookCanvas::MiddlewareTest: test_convert_post_to_get_request
|
62
59
|
----------------------------------------------------------------
|
63
|
-
Started POST "/foo/index" for 127.0.0.1 at 2016-
|
60
|
+
Started POST "/foo/index" for 127.0.0.1 at 2016-02-04 13:27:17 +0100
|
64
61
|
Processing by FooController#index as HTML
|
65
62
|
Rendered text template (0.0ms)
|
66
|
-
Completed 200 OK in 0ms (Views: 0.
|
63
|
+
Completed 200 OK in 0ms (Views: 0.2ms)
|
64
|
+
------------------------------
|
65
|
+
FacebookCanvasTest: test_truth
|
66
|
+
------------------------------
|
67
67
|
------------------------------
|
68
68
|
FacebookCanvasTest: test_truth
|
69
69
|
------------------------------
|
70
70
|
----------------------------------------------------------------
|
71
71
|
FacebookCanvas::MiddlewareTest: test_convert_post_to_get_request
|
72
72
|
----------------------------------------------------------------
|
73
|
-
Started POST "/foo/index" for 127.0.0.1 at 2016-
|
73
|
+
Started POST "/foo/index" for 127.0.0.1 at 2016-02-16 15:19:16 +0100
|
74
74
|
Processing by FooController#index as HTML
|
75
75
|
Rendered text template (0.0ms)
|
76
|
-
Completed 200 OK in
|
76
|
+
Completed 200 OK in 5ms (Views: 4.7ms)
|
77
77
|
--------------------------------------------------------
|
78
78
|
FacebookCanvas::MiddlewareTest: test_do_not_convert_post
|
79
79
|
--------------------------------------------------------
|
80
|
-
Started POST "/foo/create" for 127.0.0.1 at 2016-
|
80
|
+
Started POST "/foo/create" for 127.0.0.1 at 2016-02-16 15:19:16 +0100
|
81
81
|
Processing by FooController#create as HTML
|
82
82
|
Parameters: {"utf8"=>"utf"}
|
83
83
|
Rendered text template (0.0ms)
|
84
|
-
Completed 200 OK in 0ms (Views: 0.
|
85
|
-
--------------------------------------------------
|
86
|
-
FacebookCanvas::SignedRequestTest: test_initialize
|
87
|
-
--------------------------------------------------
|
84
|
+
Completed 200 OK in 0ms (Views: 0.2ms)
|
88
85
|
----------------------------------------------------------------------------
|
89
86
|
FacebookCanvas::SignedRequestTest: test_get_access_token_from_signed_request
|
90
87
|
----------------------------------------------------------------------------
|
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
88
|
--------------------------------------------------
|
104
89
|
FacebookCanvas::SignedRequestTest: test_initialize
|
105
90
|
--------------------------------------------------
|
@@ -109,24 +94,6 @@ FacebookCanvas::SignedRequestTest: test_get_user_id_from_signed_request
|
|
109
94
|
----------------------------------------------------------------------
|
110
95
|
FacebookCanvas::SignedRequestTest: test_no_user_id_from_signed_request
|
111
96
|
----------------------------------------------------------------------
|
112
|
-
----------------------------------------------------------------------------
|
113
|
-
FacebookCanvas::SignedRequestTest: test_get_access_token_from_signed_request
|
114
|
-
----------------------------------------------------------------------------
|
115
97
|
---------------------------------------------------------------------------
|
116
98
|
FacebookCanvas::SignedRequestTest: test_no_access_token_from_signed_request
|
117
99
|
---------------------------------------------------------------------------
|
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)
|
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.3.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: 2016-
|
11
|
+
date: 2016-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -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.8
|
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/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
|
127
|
+
- test/integration/middleware_test.rb
|
136
128
|
- test/dummy/config/application.rb
|
137
|
-
- test/dummy/config/
|
138
|
-
- test/dummy/config/
|
139
|
-
- test/dummy/config/initializers/assets.rb
|
140
|
-
- test/dummy/config/initializers/filter_parameter_logging.rb
|
129
|
+
- test/dummy/config/routes.rb
|
130
|
+
- test/dummy/config/database.yml
|
141
131
|
- test/dummy/config/initializers/cookies_serializer.rb
|
142
|
-
- test/dummy/config/initializers/inflections.rb
|
143
132
|
- test/dummy/config/initializers/backtrace_silencers.rb
|
144
133
|
- test/dummy/config/initializers/mime_types.rb
|
145
|
-
- test/dummy/config/
|
146
|
-
- test/dummy/config/
|
147
|
-
- test/dummy/config/
|
148
|
-
- test/dummy/config/
|
134
|
+
- test/dummy/config/initializers/assets.rb
|
135
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
136
|
+
- test/dummy/config/initializers/session_store.rb
|
137
|
+
- test/dummy/config/initializers/inflections.rb
|
138
|
+
- test/dummy/config/initializers/filter_parameter_logging.rb
|
149
139
|
- test/dummy/config/environments/production.rb
|
140
|
+
- test/dummy/config/environments/test.rb
|
141
|
+
- test/dummy/config/environments/development.rb
|
142
|
+
- test/dummy/config/locales/en.yml
|
150
143
|
- test/dummy/config/environment.rb
|
151
|
-
- test/dummy/config/database.yml
|
152
144
|
- test/dummy/config/boot.rb
|
153
145
|
- test/dummy/config/secrets.yml
|
146
|
+
- test/dummy/config.ru
|
147
|
+
- test/dummy/bin/bundle
|
148
|
+
- test/dummy/bin/rake
|
149
|
+
- test/dummy/bin/rails
|
150
|
+
- test/dummy/bin/setup
|
154
151
|
- test/dummy/Rakefile
|
152
|
+
- test/dummy/README.rdoc
|
153
|
+
- test/dummy/app/assets/stylesheets/application.css
|
154
|
+
- test/dummy/app/assets/javascripts/application.js
|
155
|
+
- test/dummy/app/helpers/application_helper.rb
|
156
|
+
- test/dummy/app/controllers/foo_controller.rb
|
157
|
+
- test/dummy/app/controllers/application_controller.rb
|
158
|
+
- test/dummy/app/views/foo/create.haml
|
159
|
+
- test/dummy/app/views/layouts/application.html.erb
|
160
|
+
- test/dummy/log/test.log
|
155
161
|
- test/dummy/public/favicon.ico
|
156
|
-
- test/dummy/public/422.html
|
157
162
|
- test/dummy/public/404.html
|
158
163
|
- test/dummy/public/500.html
|
159
|
-
- test/dummy/
|
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
|
165
|
-
- test/fixtures/signed_request.txt
|
166
|
-
- test/fixtures/signed_request_with_user_id.txt
|
164
|
+
- test/dummy/public/422.html
|
167
165
|
- test/test_helper.rb
|
168
|
-
- test/
|
166
|
+
- test/facebook_canvas_test.rb
|
167
|
+
- test/fixtures/signed_request_with_user_id.txt
|
168
|
+
- test/fixtures/signed_request.txt
|