shopify_app 18.1.3 → 19.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/build.yml +2 -2
  3. data/.gitignore +1 -0
  4. data/CHANGELOG.md +3 -2
  5. data/Gemfile +3 -2
  6. data/Gemfile.lock +122 -136
  7. data/Rakefile +4 -3
  8. data/app/controllers/concerns/shopify_app/ensure_authenticated_links.rb +1 -1
  9. data/app/controllers/shopify_app/authenticated_controller.rb +1 -0
  10. data/app/controllers/shopify_app/callback_controller.rb +35 -147
  11. data/app/controllers/shopify_app/sessions_controller.rb +25 -137
  12. data/app/controllers/shopify_app/webhooks_controller.rb +5 -23
  13. data/config/routes.rb +6 -12
  14. data/docs/Troubleshooting.md +0 -3
  15. data/docs/Upgrading.md +85 -2
  16. data/docs/shopify_app/webhooks.md +1 -1
  17. data/lib/generators/shopify_app/add_after_authenticate_job/add_after_authenticate_job_generator.rb +10 -9
  18. data/lib/generators/shopify_app/add_after_authenticate_job/templates/after_authenticate_job.rb +1 -0
  19. data/lib/generators/shopify_app/add_marketing_activity_extension/add_marketing_activity_extension_generator.rb +4 -3
  20. data/lib/generators/shopify_app/add_webhook/add_webhook_generator.rb +13 -12
  21. data/lib/generators/shopify_app/add_webhook/templates/webhook_job.rb.tt +9 -1
  22. data/lib/generators/shopify_app/app_proxy_controller/app_proxy_controller_generator.rb +7 -6
  23. data/lib/generators/shopify_app/app_proxy_controller/templates/app_proxy_controller.rb +2 -1
  24. data/lib/generators/shopify_app/app_proxy_controller/templates/app_proxy_route.rb +1 -1
  25. data/lib/generators/shopify_app/authenticated_controller/authenticated_controller_generator.rb +3 -3
  26. data/lib/generators/shopify_app/controllers/controllers_generator.rb +4 -3
  27. data/lib/generators/shopify_app/home_controller/home_controller_generator.rb +11 -15
  28. data/lib/generators/shopify_app/home_controller/templates/home_controller.rb +2 -2
  29. data/lib/generators/shopify_app/home_controller/templates/index.html.erb +3 -3
  30. data/lib/generators/shopify_app/install/install_generator.rb +25 -74
  31. data/lib/generators/shopify_app/install/templates/embedded_app.html.erb +1 -1
  32. data/lib/generators/shopify_app/install/templates/session_store.rb +2 -1
  33. data/lib/generators/shopify_app/install/templates/shopify_app.rb.tt +20 -5
  34. data/lib/generators/shopify_app/products_controller/products_controller_generator.rb +3 -3
  35. data/lib/generators/shopify_app/products_controller/templates/products_controller.rb +1 -1
  36. data/lib/generators/shopify_app/rotate_shopify_token_job/rotate_shopify_token_job_generator.rb +4 -4
  37. data/lib/generators/shopify_app/rotate_shopify_token_job/templates/rotate_shopify_token.rake +1 -0
  38. data/lib/generators/shopify_app/rotate_shopify_token_job/templates/rotate_shopify_token_job.rb +1 -1
  39. data/lib/generators/shopify_app/routes/routes_generator.rb +6 -5
  40. data/lib/generators/shopify_app/routes/templates/routes.rb +5 -5
  41. data/lib/generators/shopify_app/shop_model/shop_model_generator.rb +11 -10
  42. data/lib/generators/shopify_app/shop_model/templates/shop.rb +1 -0
  43. data/lib/generators/shopify_app/shopify_app_generator.rb +4 -3
  44. data/lib/generators/shopify_app/user_model/templates/user.rb +1 -0
  45. data/lib/generators/shopify_app/user_model/user_model_generator.rb +11 -10
  46. data/lib/generators/shopify_app/views/views_generator.rb +4 -3
  47. data/lib/shopify_app/access_scopes/shop_strategy.rb +2 -2
  48. data/lib/shopify_app/access_scopes/user_strategy.rb +4 -4
  49. data/lib/shopify_app/configuration.rb +5 -17
  50. data/lib/shopify_app/controller_concerns/app_proxy_verification.rb +4 -3
  51. data/lib/shopify_app/controller_concerns/csrf_protection.rb +2 -1
  52. data/lib/shopify_app/controller_concerns/embedded_app.rb +4 -3
  53. data/lib/shopify_app/controller_concerns/itp.rb +3 -3
  54. data/lib/shopify_app/controller_concerns/localization.rb +1 -0
  55. data/lib/shopify_app/controller_concerns/login_protection.rb +50 -70
  56. data/lib/shopify_app/controller_concerns/payload_verification.rb +3 -2
  57. data/lib/shopify_app/controller_concerns/webhook_verification.rb +2 -1
  58. data/lib/shopify_app/engine.rb +7 -15
  59. data/lib/shopify_app/jobs/scripttags_manager_job.rb +2 -2
  60. data/lib/shopify_app/jobs/webhooks_manager_job.rb +4 -5
  61. data/lib/shopify_app/managers/scripttags_manager.rb +11 -4
  62. data/lib/shopify_app/managers/webhooks_manager.rb +42 -44
  63. data/lib/shopify_app/middleware/jwt_middleware.rb +5 -4
  64. data/lib/shopify_app/session/in_memory_session_store.rb +1 -0
  65. data/lib/shopify_app/session/in_memory_shop_session_store.rb +2 -1
  66. data/lib/shopify_app/session/in_memory_user_session_store.rb +1 -0
  67. data/lib/shopify_app/session/jwt.rb +9 -8
  68. data/lib/shopify_app/session/null_user_session_store.rb +2 -1
  69. data/lib/shopify_app/session/session_repository.rb +37 -0
  70. data/lib/shopify_app/session/session_storage.rb +4 -6
  71. data/lib/shopify_app/session/shop_session_storage.rb +6 -6
  72. data/lib/shopify_app/session/shop_session_storage_with_scopes.rb +7 -8
  73. data/lib/shopify_app/session/user_session_storage.rb +19 -6
  74. data/lib/shopify_app/session/user_session_storage_with_scopes.rb +21 -8
  75. data/lib/shopify_app/test_helpers/all.rb +2 -1
  76. data/lib/shopify_app/test_helpers/webhook_verification_helper.rb +4 -3
  77. data/lib/shopify_app/utils.rb +2 -9
  78. data/lib/shopify_app/version.rb +2 -1
  79. data/lib/shopify_app.rb +35 -40
  80. data/package.json +1 -1
  81. data/shopify_app.gemspec +21 -20
  82. data/yarn.lock +6 -6
  83. metadata +45 -50
  84. data/lib/generators/shopify_app/install/templates/omniauth.rb +0 -4
  85. data/lib/generators/shopify_app/install/templates/shopify_provider.rb.tt +0 -8
  86. data/lib/generators/shopify_app/install/templates/user_agent.rb +0 -6
  87. data/lib/shopify_app/middleware/same_site_cookie_middleware.rb +0 -34
  88. data/lib/shopify_app/omniauth/omniauth_configuration.rb +0 -64
metadata CHANGED
@@ -1,43 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopify_app
3
3
  version: !ruby/object:Gem::Version
4
- version: 18.1.3
4
+ version: 19.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-03 00:00:00.000000000 Z
11
+ date: 2022-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activeresource
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: browser_sniffer
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
31
  - - "~>"
18
32
  - !ruby/object:Gem::Version
19
- version: '2.0'
33
+ version: 1.4.0
20
34
  type: :runtime
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
38
  - - "~>"
25
39
  - !ruby/object:Gem::Version
26
- version: '2.0'
40
+ version: 1.4.0
27
41
  - !ruby/object:Gem::Dependency
28
- name: omniauth-rails_csrf_protection
42
+ name: jwt
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - ">="
32
46
  - !ruby/object:Gem::Version
33
- version: '0'
47
+ version: 2.2.3
34
48
  type: :runtime
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
52
  - - ">="
39
53
  - !ruby/object:Gem::Version
40
- version: '0'
54
+ version: 2.2.3
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rails
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -53,63 +67,63 @@ dependencies:
53
67
  - !ruby/object:Gem::Version
54
68
  version: 5.2.1
55
69
  - !ruby/object:Gem::Dependency
56
- name: shopify_api
70
+ name: redirect_safely
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - "~>"
60
74
  - !ruby/object:Gem::Version
61
- version: '9.4'
75
+ version: '1.0'
62
76
  type: :runtime
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
80
  - - "~>"
67
81
  - !ruby/object:Gem::Version
68
- version: '9.4'
82
+ version: '1.0'
69
83
  - !ruby/object:Gem::Dependency
70
- name: omniauth-shopify-oauth2
84
+ name: shopify_api
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
87
  - - "~>"
74
88
  - !ruby/object:Gem::Version
75
- version: '2.3'
89
+ version: '10.0'
76
90
  type: :runtime
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
94
  - - "~>"
81
95
  - !ruby/object:Gem::Version
82
- version: '2.3'
96
+ version: '10.0'
83
97
  - !ruby/object:Gem::Dependency
84
- name: jwt
98
+ name: sprockets-rails
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
101
  - - ">="
88
102
  - !ruby/object:Gem::Version
89
- version: 2.2.3
103
+ version: 2.0.0
90
104
  type: :runtime
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
108
  - - ">="
95
109
  - !ruby/object:Gem::Version
96
- version: 2.2.3
110
+ version: 2.0.0
97
111
  - !ruby/object:Gem::Dependency
98
- name: redirect_safely
112
+ name: byebug
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
- - - "~>"
115
+ - - ">="
102
116
  - !ruby/object:Gem::Version
103
- version: '1.0'
104
- type: :runtime
117
+ version: '0'
118
+ type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
- - - "~>"
122
+ - - ">="
109
123
  - !ruby/object:Gem::Version
110
- version: '1.0'
124
+ version: '0'
111
125
  - !ruby/object:Gem::Dependency
112
- name: rake
126
+ name: minitest
113
127
  requirement: !ruby/object:Gem::Requirement
114
128
  requirements:
115
129
  - - ">="
@@ -123,7 +137,7 @@ dependencies:
123
137
  - !ruby/object:Gem::Version
124
138
  version: '0'
125
139
  - !ruby/object:Gem::Dependency
126
- name: byebug
140
+ name: mocha
127
141
  requirement: !ruby/object:Gem::Requirement
128
142
  requirements:
129
143
  - - ">="
@@ -179,7 +193,7 @@ dependencies:
179
193
  - !ruby/object:Gem::Version
180
194
  version: '0'
181
195
  - !ruby/object:Gem::Dependency
182
- name: rb-readline
196
+ name: rake
183
197
  requirement: !ruby/object:Gem::Requirement
184
198
  requirements:
185
199
  - - ">="
@@ -193,21 +207,7 @@ dependencies:
193
207
  - !ruby/object:Gem::Version
194
208
  version: '0'
195
209
  - !ruby/object:Gem::Dependency
196
- name: sqlite3
197
- requirement: !ruby/object:Gem::Requirement
198
- requirements:
199
- - - "~>"
200
- - !ruby/object:Gem::Version
201
- version: '1.4'
202
- type: :development
203
- prerelease: false
204
- version_requirements: !ruby/object:Gem::Requirement
205
- requirements:
206
- - - "~>"
207
- - !ruby/object:Gem::Version
208
- version: '1.4'
209
- - !ruby/object:Gem::Dependency
210
- name: minitest
210
+ name: rb-readline
211
211
  requirement: !ruby/object:Gem::Requirement
212
212
  requirements:
213
213
  - - ">="
@@ -221,19 +221,19 @@ dependencies:
221
221
  - !ruby/object:Gem::Version
222
222
  version: '0'
223
223
  - !ruby/object:Gem::Dependency
224
- name: mocha
224
+ name: sqlite3
225
225
  requirement: !ruby/object:Gem::Requirement
226
226
  requirements:
227
- - - ">="
227
+ - - "~>"
228
228
  - !ruby/object:Gem::Version
229
- version: '0'
229
+ version: '1.4'
230
230
  type: :development
231
231
  prerelease: false
232
232
  version_requirements: !ruby/object:Gem::Requirement
233
233
  requirements:
234
- - - ">="
234
+ - - "~>"
235
235
  - !ruby/object:Gem::Version
236
- version: '0'
236
+ version: '1.4'
237
237
  - !ruby/object:Gem::Dependency
238
238
  name: webmock
239
239
  requirement: !ruby/object:Gem::Requirement
@@ -367,14 +367,11 @@ files:
367
367
  - lib/generators/shopify_app/install/templates/_flash_messages.html.erb
368
368
  - lib/generators/shopify_app/install/templates/embedded_app.html.erb
369
369
  - lib/generators/shopify_app/install/templates/flash_messages.js
370
- - lib/generators/shopify_app/install/templates/omniauth.rb
371
370
  - lib/generators/shopify_app/install/templates/session_store.rb
372
371
  - lib/generators/shopify_app/install/templates/shopify_app.js
373
372
  - lib/generators/shopify_app/install/templates/shopify_app.rb.tt
374
373
  - lib/generators/shopify_app/install/templates/shopify_app_importmap.js
375
374
  - lib/generators/shopify_app/install/templates/shopify_app_index.js
376
- - lib/generators/shopify_app/install/templates/shopify_provider.rb.tt
377
- - lib/generators/shopify_app/install/templates/user_agent.rb
378
375
  - lib/generators/shopify_app/products_controller/products_controller_generator.rb
379
376
  - lib/generators/shopify_app/products_controller/templates/products_controller.rb
380
377
  - lib/generators/shopify_app/rotate_shopify_token_job/rotate_shopify_token_job_generator.rb
@@ -413,8 +410,6 @@ files:
413
410
  - lib/shopify_app/managers/scripttags_manager.rb
414
411
  - lib/shopify_app/managers/webhooks_manager.rb
415
412
  - lib/shopify_app/middleware/jwt_middleware.rb
416
- - lib/shopify_app/middleware/same_site_cookie_middleware.rb
417
- - lib/shopify_app/omniauth/omniauth_configuration.rb
418
413
  - lib/shopify_app/session/in_memory_session_store.rb
419
414
  - lib/shopify_app/session/in_memory_shop_session_store.rb
420
415
  - lib/shopify_app/session/in_memory_user_session_store.rb
@@ -1,4 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Rails.application.config.middleware.use(OmniAuth::Builder) do
4
- end
@@ -1,8 +0,0 @@
1
- provider :shopify,
2
- ShopifyApp.configuration.api_key,
3
- ShopifyApp.configuration.secret,
4
- scope: ShopifyApp.configuration.scope,
5
- setup: lambda { |env|
6
- configuration = ShopifyApp::OmniAuthConfiguration.new(env['omniauth.strategy'], Rack::Request.new(env))
7
- configuration.build_options
8
- }
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
- module ShopifyAPI
3
- class Base < ActiveResource::Base
4
- headers['User-Agent'] << " | ShopifyApp/#{ShopifyApp::VERSION}"
5
- end
6
- end
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
- module ShopifyApp
3
- class SameSiteCookieMiddleware
4
- COOKIE_SEPARATOR = "\n"
5
-
6
- def initialize(app)
7
- @app = app
8
- end
9
-
10
- def call(env)
11
- status, headers, body = @app.call(env)
12
- user_agent = env['HTTP_USER_AGENT']
13
-
14
- if headers && headers['Set-Cookie'] &&
15
- BrowserSniffer.new(user_agent).same_site_none_compatible? &&
16
- ShopifyApp.configuration.enable_same_site_none &&
17
- Rack::Request.new(env).ssl?
18
-
19
- set_cookies = headers['Set-Cookie']
20
- .split(COOKIE_SEPARATOR)
21
- .compact
22
- .map do |cookie|
23
- cookie << '; Secure' unless cookie =~ /;\s*secure/i
24
- cookie << '; SameSite=None' if ShopifyApp.configuration.embedded_app?
25
- cookie
26
- end
27
-
28
- headers['Set-Cookie'] = set_cookies.join(COOKIE_SEPARATOR)
29
- end
30
-
31
- [status, headers, body]
32
- end
33
- end
34
- end
@@ -1,64 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ShopifyApp
4
- class OmniAuthConfiguration
5
- attr_reader :strategy, :request
6
- attr_writer :client_options_site, :scopes, :per_user_permissions
7
-
8
- def initialize(strategy, request)
9
- @strategy = strategy
10
- @request = request
11
- end
12
-
13
- def build_options
14
- strategy.options[:client_options][:site] = client_options_site
15
- strategy.options[:scope] = scopes
16
- strategy.options[:old_client_secret] = ShopifyApp.configuration.old_secret
17
- strategy.options[:per_user_permissions] = request_online_tokens?
18
- end
19
-
20
- private
21
-
22
- def request_online_tokens?
23
- return @per_user_permissions unless @per_user_permissions.nil?
24
- default_request_online_tokens?
25
- end
26
-
27
- def scopes
28
- @scopes || default_scopes
29
- end
30
-
31
- def client_options_site
32
- @client_options_site || default_client_options_site
33
- end
34
-
35
- def default_scopes
36
- if request_online_tokens?
37
- ShopifyApp.configuration.user_access_scopes
38
- else
39
- ShopifyApp.configuration.shop_access_scopes
40
- end
41
- end
42
-
43
- def default_client_options_site
44
- return '' unless shop_domain.present?
45
- "https://#{shopify_auth_params[:shop]}"
46
- end
47
-
48
- def default_request_online_tokens?
49
- strategy.session[:user_tokens] && !update_shop_scopes?
50
- end
51
-
52
- def update_shop_scopes?
53
- ShopifyApp.configuration.shop_access_scopes_strategy.update_access_scopes?(shop_domain)
54
- end
55
-
56
- def shop_domain
57
- request.params['shop'] || (shopify_auth_params && shopify_auth_params['shop'])
58
- end
59
-
60
- def shopify_auth_params
61
- strategy.session['shopify.omniauth_params']&.with_indifferent_access
62
- end
63
- end
64
- end