shopify_app 12.0.7 → 13.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +12 -6
  3. data/.travis.yml +4 -3
  4. data/CHANGELOG.md +33 -0
  5. data/Gemfile +3 -0
  6. data/README.md +98 -42
  7. data/Rakefile +1 -0
  8. data/app/controllers/concerns/shopify_app/authenticated.rb +1 -1
  9. data/app/controllers/shopify_app/authenticated_controller.rb +1 -0
  10. data/app/controllers/shopify_app/callback_controller.rb +50 -17
  11. data/app/controllers/shopify_app/sessions_controller.rb +36 -10
  12. data/app/controllers/shopify_app/webhooks_controller.rb +6 -5
  13. data/config/locales/fi.yml +1 -1
  14. data/config/locales/nl.yml +7 -7
  15. data/config/routes.rb +1 -0
  16. data/docs/Releasing.md +1 -0
  17. data/lib/generators/shopify_app/add_after_authenticate_job/add_after_authenticate_job_generator.rb +5 -3
  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 +2 -1
  20. data/lib/generators/shopify_app/add_marketing_activity_extension/templates/marketing_activities_controller.rb +4 -4
  21. data/lib/generators/shopify_app/add_webhook/add_webhook_generator.rb +5 -4
  22. data/lib/generators/shopify_app/add_webhook/templates/{webhook_job.rb → webhook_job.rb.tt} +5 -0
  23. data/lib/generators/shopify_app/app_proxy_controller/app_proxy_controller_generator.rb +4 -3
  24. data/lib/generators/shopify_app/app_proxy_controller/templates/app_proxy_controller.rb +3 -3
  25. data/lib/generators/shopify_app/app_proxy_controller/templates/app_proxy_route.rb +10 -9
  26. data/lib/generators/shopify_app/controllers/controllers_generator.rb +1 -0
  27. data/lib/generators/shopify_app/home_controller/home_controller_generator.rb +4 -3
  28. data/lib/generators/shopify_app/home_controller/templates/index.html.erb +1 -1
  29. data/lib/generators/shopify_app/install/install_generator.rb +10 -9
  30. data/lib/generators/shopify_app/install/templates/embedded_app.html.erb +1 -1
  31. data/lib/generators/shopify_app/install/templates/omniauth.rb +2 -1
  32. data/lib/generators/shopify_app/install/templates/{shopify_app.rb → shopify_app.rb.tt} +1 -1
  33. data/lib/generators/shopify_app/install/templates/shopify_provider.rb +1 -1
  34. data/lib/generators/shopify_app/install/templates/user_agent.rb +2 -1
  35. data/lib/generators/shopify_app/routes/routes_generator.rb +1 -0
  36. data/lib/generators/shopify_app/routes/templates/routes.rb +10 -9
  37. data/lib/generators/shopify_app/shop_model/shop_model_generator.rb +12 -7
  38. data/lib/generators/shopify_app/shop_model/templates/shop.rb +2 -1
  39. data/lib/generators/shopify_app/shopify_app_generator.rb +4 -3
  40. data/lib/generators/shopify_app/user_model/templates/user.rb +2 -1
  41. data/lib/generators/shopify_app/user_model/user_model_generator.rb +12 -7
  42. data/lib/generators/shopify_app/views/views_generator.rb +1 -0
  43. data/lib/shopify_app.rb +11 -4
  44. data/lib/shopify_app/configuration.rb +21 -11
  45. data/lib/shopify_app/controller_concerns/app_proxy_verification.rb +3 -2
  46. data/lib/shopify_app/controller_concerns/embedded_app.rb +3 -2
  47. data/lib/shopify_app/controller_concerns/localization.rb +1 -0
  48. data/lib/shopify_app/controller_concerns/login_protection.rb +71 -29
  49. data/lib/shopify_app/controller_concerns/webhook_verification.rb +2 -1
  50. data/lib/shopify_app/engine.rb +5 -0
  51. data/lib/shopify_app/jobs/scripttags_manager_job.rb +1 -1
  52. data/lib/shopify_app/jobs/webhooks_manager_job.rb +1 -1
  53. data/lib/shopify_app/managers/scripttags_manager.rb +4 -3
  54. data/lib/shopify_app/managers/webhooks_manager.rb +4 -3
  55. data/lib/shopify_app/middleware/jwt_middleware.rb +41 -0
  56. data/lib/shopify_app/middleware/same_site_cookie_middleware.rb +2 -1
  57. data/lib/shopify_app/session/in_memory_session_store.rb +7 -3
  58. data/lib/shopify_app/session/in_memory_shop_session_store.rb +14 -0
  59. data/lib/shopify_app/session/in_memory_user_session_store.rb +14 -0
  60. data/lib/shopify_app/session/jwt.rb +61 -0
  61. data/lib/shopify_app/session/null_user_session_store.rb +22 -0
  62. data/lib/shopify_app/session/session_repository.rb +36 -14
  63. data/lib/shopify_app/session/session_storage.rb +1 -10
  64. data/lib/shopify_app/session/shop_session_storage.rb +42 -0
  65. data/lib/shopify_app/session/user_session_storage.rb +42 -0
  66. data/lib/shopify_app/test_helpers/all.rb +2 -0
  67. data/lib/shopify_app/test_helpers/webhook_verification_helper.rb +17 -0
  68. data/lib/shopify_app/utils.rb +6 -5
  69. data/lib/shopify_app/version.rb +2 -1
  70. data/package-lock.json +1231 -1210
  71. data/package.json +1 -1
  72. data/shopify_app.gemspec +13 -8
  73. data/yarn.lock +3 -3
  74. metadata +50 -14
  75. data/lib/shopify_app/session/storage_strategies/shop_storage_strategy.rb +0 -23
  76. data/lib/shopify_app/session/storage_strategies/user_storage_strategy.rb +0 -24
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shopify_app",
3
- "version": "12.0.5",
3
+ "version": "13.2.0",
4
4
  "repository": "git@github.com:Shopify/shopify_app.git",
5
5
  "author": "Shopify",
6
6
  "license": "MIT",
@@ -1,4 +1,5 @@
1
- $LOAD_PATH.push File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+ $LOAD_PATH.push(File.expand_path('../lib', __FILE__))
2
3
  require "shopify_app/version"
3
4
 
4
5
  Gem::Specification.new do |s|
@@ -6,14 +7,18 @@ Gem::Specification.new do |s|
6
7
  s.version = ShopifyApp::VERSION
7
8
  s.platform = Gem::Platform::RUBY
8
9
  s.author = "Shopify"
9
- s.summary = %q{This gem is used to get quickly started with the Shopify API}
10
+ s.summary = 'This gem is used to get quickly started with the Shopify API'
10
11
 
11
- s.required_ruby_version = ">= 2.3.1"
12
+ s.required_ruby_version = ">= 2.4"
12
13
 
13
- s.add_runtime_dependency('browser_sniffer', '~> 1.2.0')
14
+ s.metadata['allowed_push_host'] = 'https://rubygems.org'
15
+
16
+ s.add_runtime_dependency('browser_sniffer', '~> 1.2.2')
14
17
  s.add_runtime_dependency('rails', '> 5.2.1')
15
- s.add_runtime_dependency('shopify_api', '~> 9.0.1')
16
- s.add_runtime_dependency('omniauth-shopify-oauth2', '~> 2.2.0')
18
+ s.add_runtime_dependency('shopify_api', '~> 9.1.0')
19
+ s.add_runtime_dependency('omniauth-shopify-oauth2', '~> 2.2.2')
20
+ s.add_runtime_dependency('jwt', '~> 2.2.1')
21
+ s.add_runtime_dependency('redirect_safely', '~> 1.0')
17
22
 
18
23
  s.add_development_dependency('rake')
19
24
  s.add_development_dependency('byebug')
@@ -26,7 +31,7 @@ Gem::Specification.new do |s|
26
31
  s.add_development_dependency('mocha')
27
32
  s.add_development_dependency('webmock')
28
33
 
29
- s.files = `git ls-files`.split("\n").reject { |f| f.match(%r{^(test|example)/}) }
30
- s.test_files = `git ls-files -- {test}/*`.split("\n")
34
+ s.files = %x(git ls-files).split("\n").reject { |f| f.match(%r{^(test|example)/}) }
35
+ s.test_files = %x(git ls-files -- {test}/*).split("\n")
31
36
  s.require_paths = ["lib"]
32
37
  end
data/yarn.lock CHANGED
@@ -994,9 +994,9 @@ accepts@~1.3.4:
994
994
  negotiator "0.6.2"
995
995
 
996
996
  acorn@^6.2.1:
997
- version "6.3.0"
998
- resolved "https://registry.yarnpkg.com/acorn/-/acorn-6.3.0.tgz#0087509119ffa4fc0a0041d1e93a417e68cb856e"
999
- integrity sha512-/czfa8BwS88b9gWQVhc8eknunSA2DoJpJyTQkhheIf5E48u1N0R4q/YxxsAeqRrmK9TQ/uYfgLDfZo91UlANIA==
997
+ version "6.4.1"
998
+ resolved "https://registry.yarnpkg.com/acorn/-/acorn-6.4.1.tgz#531e58ba3f51b9dacb9a6646ca4debf5b14ca474"
999
+ integrity sha512-ZVA9k326Nwrj3Cj9jlh3wGFutC2ZornPNARZwsNYqQYgN0EsV2d53w5RN/co65Ohn4sUAUtb1rSUAOD6XN9idA==
1000
1000
 
1001
1001
  after@0.8.2:
1002
1002
  version "0.8.2"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopify_app
3
3
  version: !ruby/object:Gem::Version
4
- version: 12.0.7
4
+ version: 13.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-03 00:00:00.000000000 Z
11
+ date: 2020-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: browser_sniffer
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.2.0
19
+ version: 1.2.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.2.0
26
+ version: 1.2.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rails
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,28 +44,56 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 9.0.1
47
+ version: 9.1.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 9.0.1
54
+ version: 9.1.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: omniauth-shopify-oauth2
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 2.2.0
61
+ version: 2.2.2
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 2.2.0
68
+ version: 2.2.2
69
+ - !ruby/object:Gem::Dependency
70
+ name: jwt
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 2.2.1
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 2.2.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: redirect_safely
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.0'
69
97
  - !ruby/object:Gem::Dependency
70
98
  name: rake
71
99
  requirement: !ruby/object:Gem::Requirement
@@ -287,7 +315,7 @@ files:
287
315
  - lib/generators/shopify_app/add_marketing_activity_extension/add_marketing_activity_extension_generator.rb
288
316
  - lib/generators/shopify_app/add_marketing_activity_extension/templates/marketing_activities_controller.rb
289
317
  - lib/generators/shopify_app/add_webhook/add_webhook_generator.rb
290
- - lib/generators/shopify_app/add_webhook/templates/webhook_job.rb
318
+ - lib/generators/shopify_app/add_webhook/templates/webhook_job.rb.tt
291
319
  - lib/generators/shopify_app/app_proxy_controller/app_proxy_controller_generator.rb
292
320
  - lib/generators/shopify_app/app_proxy_controller/templates/app_proxy_controller.rb
293
321
  - lib/generators/shopify_app/app_proxy_controller/templates/app_proxy_route.rb
@@ -305,7 +333,7 @@ files:
305
333
  - lib/generators/shopify_app/install/templates/omniauth.rb
306
334
  - lib/generators/shopify_app/install/templates/session_store.rb
307
335
  - lib/generators/shopify_app/install/templates/shopify_app.js
308
- - lib/generators/shopify_app/install/templates/shopify_app.rb
336
+ - lib/generators/shopify_app/install/templates/shopify_app.rb.tt
309
337
  - lib/generators/shopify_app/install/templates/shopify_app_index.js
310
338
  - lib/generators/shopify_app/install/templates/shopify_provider.rb
311
339
  - lib/generators/shopify_app/install/templates/user_agent.rb
@@ -337,12 +365,19 @@ files:
337
365
  - lib/shopify_app/jobs/webhooks_manager_job.rb
338
366
  - lib/shopify_app/managers/scripttags_manager.rb
339
367
  - lib/shopify_app/managers/webhooks_manager.rb
368
+ - lib/shopify_app/middleware/jwt_middleware.rb
340
369
  - lib/shopify_app/middleware/same_site_cookie_middleware.rb
341
370
  - lib/shopify_app/session/in_memory_session_store.rb
371
+ - lib/shopify_app/session/in_memory_shop_session_store.rb
372
+ - lib/shopify_app/session/in_memory_user_session_store.rb
373
+ - lib/shopify_app/session/jwt.rb
374
+ - lib/shopify_app/session/null_user_session_store.rb
342
375
  - lib/shopify_app/session/session_repository.rb
343
376
  - lib/shopify_app/session/session_storage.rb
344
- - lib/shopify_app/session/storage_strategies/shop_storage_strategy.rb
345
- - lib/shopify_app/session/storage_strategies/user_storage_strategy.rb
377
+ - lib/shopify_app/session/shop_session_storage.rb
378
+ - lib/shopify_app/session/user_session_storage.rb
379
+ - lib/shopify_app/test_helpers/all.rb
380
+ - lib/shopify_app/test_helpers/webhook_verification_helper.rb
346
381
  - lib/shopify_app/utils.rb
347
382
  - lib/shopify_app/version.rb
348
383
  - package-lock.json
@@ -355,7 +390,8 @@ files:
355
390
  - yarn.lock
356
391
  homepage:
357
392
  licenses: []
358
- metadata: {}
393
+ metadata:
394
+ allowed_push_host: https://rubygems.org
359
395
  post_install_message:
360
396
  rdoc_options: []
361
397
  require_paths:
@@ -364,7 +400,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
364
400
  requirements:
365
401
  - - ">="
366
402
  - !ruby/object:Gem::Version
367
- version: 2.3.1
403
+ version: '2.4'
368
404
  required_rubygems_version: !ruby/object:Gem::Requirement
369
405
  requirements:
370
406
  - - ">="
@@ -1,23 +0,0 @@
1
- module ShopifyApp
2
- module SessionStorage
3
- module ShopStorageStrategy
4
- def store(auth_session, *args)
5
- shop = find_or_initialize_by(shopify_domain: auth_session.domain)
6
- shop.shopify_token = auth_session.token
7
- shop.save!
8
- shop.id
9
- end
10
-
11
- def retrieve(id)
12
- return unless id
13
- if shop = self.find_by(id: id)
14
- ShopifyAPI::Session.new(
15
- domain: shop.shopify_domain,
16
- token: shop.shopify_token,
17
- api_version: shop.api_version
18
- )
19
- end
20
- end
21
- end
22
- end
23
- end
@@ -1,24 +0,0 @@
1
- module ShopifyApp
2
- module SessionStorage
3
- module UserStorageStrategy
4
- def store(auth_session, user)
5
- user = find_or_initialize_by(shopify_user_id: user[:id])
6
- user.shopify_token = auth_session.token
7
- user.shopify_domain = auth_session.domain
8
- user.save!
9
- user.id
10
- end
11
-
12
- def retrieve(id)
13
- return unless id
14
- if user = self.find_by(shopify_user_id: id)
15
- ShopifyAPI::Session.new(
16
- domain: user.shopify_domain,
17
- token: user.shopify_token,
18
- api_version: user.api_version
19
- )
20
- end
21
- end
22
- end
23
- end
24
- end