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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 47c574bf93fbef64c7b67edaec3d3ba9cb89d479
4
- data.tar.gz: bc29c32d280ef4fb2161460e6b6bc364f30ad61a
3
+ metadata.gz: a75530a3520a376ea8e0d60110a2129f245ecd96
4
+ data.tar.gz: 21dbb6d5b06cc10e573ca7627b232d386d64f7f1
5
5
  SHA512:
6
- metadata.gz: 499515ff1f83003d1fed1e2b477729f3eb8dfba217b86a9f7054646b0f4e3b0b779188fc093ea93d513f399c619bf098986dc0322ac0ec09adf3162fe321bbe9
7
- data.tar.gz: 0b0100d50c70431695695fa33e2b33e0d73c5fbd81e740029d8c06a63b652705758bd60c01a339a0e9c5bfb310c244fb44ba1a26a6e3b5aab673b8a50e249e0f
6
+ metadata.gz: 593ab5653ea5e81ec4f09fea3f1a006e76e983ba57c495abde4b6ec33ed21a166267b3c1ae3d2202cf66bdaf19a0a5d3da1001d90663f517dfb97b34c5ef968d
7
+ data.tar.gz: 6a2761bcde58727ad5f48c5e0e632a72bb2c6d0f743d366b7e492409b12ea885f619ff697d32f60cb8cb4394cac491ddc5ed715c320e07e5d889b92230ee652a
@@ -4,5 +4,5 @@ require "facebook_canvas/helpers"
4
4
  require "facebook_canvas/signed_request"
5
5
 
6
6
  module FacebookCanvas
7
- mattr_accessor :server_name
8
- end
7
+ mattr_accessor :server_name, :custom_filter
8
+ end
@@ -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
- app.config.middleware.use FacebookCanvas::Middleware, server_name
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
@@ -1,3 +1,3 @@
1
1
  module FacebookCanvas
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -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 2016-01-14 15:27:12 +0100
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 3ms (Views: 2.8ms)
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 2016-01-14 15:27:12 +0100
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
- FacebookCanvasTest: test_truth
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: test_no_access_token_from_signed_request
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-01-14 15:27:16 +0100
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 2ms (Views: 2.2ms)
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-01-14 15:27:16 +0100
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.1ms)
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-01-14 15:47:21 +0100
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 2ms (Views: 2.2ms)
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-01-14 15:47:21 +0100
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.1ms)
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.2.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-01-14 00:00:00.000000000 Z
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.6
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/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
127
+ - test/integration/middleware_test.rb
136
128
  - test/dummy/config/application.rb
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
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/locales/en.yml
146
- - test/dummy/config/routes.rb
147
- - test/dummy/config/environments/development.rb
148
- - test/dummy/config/environments/test.rb
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/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
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/integration/middleware_test.rb
166
+ - test/facebook_canvas_test.rb
167
+ - test/fixtures/signed_request_with_user_id.txt
168
+ - test/fixtures/signed_request.txt