shopify_app 13.0.0 → 16.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE.md +5 -0
  3. data/.github/PULL_REQUEST_TEMPLATE.md +6 -0
  4. data/.github/workflows/build.yml +38 -0
  5. data/.github/workflows/rubocop.yml +22 -0
  6. data/.gitignore +0 -2
  7. data/.rubocop.yml +14 -6
  8. data/CHANGELOG.md +95 -0
  9. data/Gemfile +5 -0
  10. data/Gemfile.lock +252 -0
  11. data/README.md +83 -45
  12. data/Rakefile +1 -0
  13. data/SECURITY.md +59 -0
  14. data/app/assets/images/storage_access.svg +1 -2
  15. data/app/assets/javascripts/shopify_app/storage_access.js +2 -1
  16. data/app/assets/javascripts/shopify_app/top_level_interaction.js +1 -1
  17. data/app/controllers/concerns/shopify_app/authenticated.rb +1 -0
  18. data/app/controllers/concerns/shopify_app/require_known_shop.rb +39 -0
  19. data/app/controllers/shopify_app/authenticated_controller.rb +1 -0
  20. data/app/controllers/shopify_app/callback_controller.rb +77 -15
  21. data/app/controllers/shopify_app/extension_verification_controller.rb +2 -7
  22. data/app/controllers/shopify_app/sessions_controller.rb +24 -7
  23. data/app/controllers/shopify_app/webhooks_controller.rb +6 -5
  24. data/app/views/shopify_app/partials/_button_styles.html.erb +41 -36
  25. data/app/views/shopify_app/partials/_card_styles.html.erb +3 -3
  26. data/app/views/shopify_app/partials/_empty_state_styles.html.erb +28 -59
  27. data/app/views/shopify_app/partials/_form_styles.html.erb +56 -0
  28. data/app/views/shopify_app/partials/_layout_styles.html.erb +16 -1
  29. data/app/views/shopify_app/partials/_typography_styles.html.erb +6 -6
  30. data/app/views/shopify_app/sessions/enable_cookies.html.erb +2 -7
  31. data/app/views/shopify_app/sessions/new.html.erb +38 -110
  32. data/app/views/shopify_app/sessions/request_storage_access.html.erb +1 -1
  33. data/app/views/shopify_app/sessions/top_level_interaction.html.erb +21 -22
  34. data/config/locales/fi.yml +1 -1
  35. data/config/locales/nl.yml +7 -7
  36. data/config/locales/th.yml +4 -4
  37. data/config/routes.rb +1 -0
  38. data/docs/Quickstart.md +7 -17
  39. data/docs/Releasing.md +16 -14
  40. data/karma.conf.js +1 -1
  41. data/lib/generators/shopify_app/add_after_authenticate_job/add_after_authenticate_job_generator.rb +5 -3
  42. data/lib/generators/shopify_app/add_after_authenticate_job/templates/after_authenticate_job.rb +1 -0
  43. data/lib/generators/shopify_app/add_marketing_activity_extension/add_marketing_activity_extension_generator.rb +2 -1
  44. data/lib/generators/shopify_app/add_marketing_activity_extension/templates/marketing_activities_controller.rb +4 -4
  45. data/lib/generators/shopify_app/add_webhook/add_webhook_generator.rb +5 -4
  46. data/lib/generators/shopify_app/add_webhook/templates/{webhook_job.rb → webhook_job.rb.tt} +5 -0
  47. data/lib/generators/shopify_app/app_proxy_controller/app_proxy_controller_generator.rb +4 -3
  48. data/lib/generators/shopify_app/app_proxy_controller/templates/app_proxy_controller.rb +3 -3
  49. data/lib/generators/shopify_app/app_proxy_controller/templates/app_proxy_route.rb +10 -9
  50. data/lib/generators/shopify_app/authenticated_controller/authenticated_controller_generator.rb +1 -1
  51. data/lib/generators/shopify_app/controllers/controllers_generator.rb +2 -1
  52. data/lib/generators/shopify_app/home_controller/home_controller_generator.rb +22 -3
  53. data/lib/generators/shopify_app/home_controller/templates/index.html.erb +67 -17
  54. data/lib/generators/shopify_app/home_controller/templates/unauthenticated_home_controller.rb +10 -0
  55. data/lib/generators/shopify_app/install/install_generator.rb +11 -10
  56. data/lib/generators/shopify_app/install/templates/embedded_app.html.erb +1 -1
  57. data/lib/generators/shopify_app/install/templates/flash_messages.js +0 -2
  58. data/lib/generators/shopify_app/install/templates/omniauth.rb +2 -1
  59. data/lib/generators/shopify_app/install/templates/{shopify_app.rb → shopify_app.rb.tt} +4 -3
  60. data/lib/generators/shopify_app/install/templates/user_agent.rb +2 -1
  61. data/lib/generators/shopify_app/products_controller/products_controller_generator.rb +19 -0
  62. data/lib/generators/shopify_app/products_controller/templates/products_controller.rb +8 -0
  63. data/lib/generators/shopify_app/routes/routes_generator.rb +1 -0
  64. data/lib/generators/shopify_app/routes/templates/routes.rb +10 -9
  65. data/lib/generators/shopify_app/shop_model/shop_model_generator.rb +12 -7
  66. data/lib/generators/shopify_app/shop_model/templates/shop.rb +1 -0
  67. data/lib/generators/shopify_app/shopify_app_generator.rb +4 -3
  68. data/lib/generators/shopify_app/user_model/templates/user.rb +1 -0
  69. data/lib/generators/shopify_app/user_model/user_model_generator.rb +12 -7
  70. data/lib/generators/shopify_app/views/views_generator.rb +2 -1
  71. data/lib/shopify_app/configuration.rb +15 -8
  72. data/lib/shopify_app/controller_concerns/app_proxy_verification.rb +3 -3
  73. data/lib/shopify_app/controller_concerns/csrf_protection.rb +15 -0
  74. data/lib/shopify_app/controller_concerns/embedded_app.rb +3 -2
  75. data/lib/shopify_app/controller_concerns/itp.rb +2 -0
  76. data/lib/shopify_app/controller_concerns/localization.rb +1 -0
  77. data/lib/shopify_app/controller_concerns/login_protection.rb +85 -17
  78. data/lib/shopify_app/controller_concerns/payload_verification.rb +24 -0
  79. data/lib/shopify_app/controller_concerns/webhook_verification.rb +3 -18
  80. data/lib/shopify_app/engine.rb +26 -0
  81. data/lib/shopify_app/jobs/scripttags_manager_job.rb +1 -1
  82. data/lib/shopify_app/jobs/webhooks_manager_job.rb +1 -1
  83. data/lib/shopify_app/managers/scripttags_manager.rb +4 -3
  84. data/lib/shopify_app/managers/webhooks_manager.rb +4 -3
  85. data/lib/shopify_app/middleware/jwt_middleware.rb +42 -0
  86. data/lib/shopify_app/middleware/same_site_cookie_middleware.rb +2 -1
  87. data/lib/shopify_app/session/in_memory_session_store.rb +7 -3
  88. data/lib/shopify_app/session/in_memory_shop_session_store.rb +10 -0
  89. data/lib/shopify_app/session/in_memory_user_session_store.rb +10 -0
  90. data/lib/shopify_app/session/jwt.rb +63 -0
  91. data/lib/shopify_app/session/null_user_session_store.rb +22 -0
  92. data/lib/shopify_app/session/session_repository.rb +13 -16
  93. data/lib/shopify_app/session/session_storage.rb +1 -0
  94. data/lib/shopify_app/session/shop_session_storage.rb +21 -9
  95. data/lib/shopify_app/session/user_session_storage.rb +19 -8
  96. data/lib/shopify_app/test_helpers/all.rb +2 -0
  97. data/lib/shopify_app/test_helpers/webhook_verification_helper.rb +17 -0
  98. data/lib/shopify_app/utils.rb +6 -5
  99. data/lib/shopify_app/version.rb +2 -1
  100. data/lib/shopify_app.rb +12 -5
  101. data/package.json +7 -8
  102. data/shopify_app.gemspec +12 -7
  103. data/yarn.lock +2098 -2115
  104. metadata +56 -12
  105. data/.travis.yml +0 -27
  106. data/package-lock.json +0 -7245
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'rails/generators/base'
2
3
 
3
4
  module ShopifyApp
@@ -7,7 +8,7 @@ module ShopifyApp
7
8
 
8
9
  def create_views
9
10
  views.each do |view|
10
- copy_file view
11
+ copy_file(view)
11
12
  end
12
13
  end
13
14
 
@@ -1,11 +1,11 @@
1
+ # frozen_string_literal: true
1
2
  module ShopifyApp
2
3
  class Configuration
3
-
4
4
  # Shopify App settings. These values should match the configuration
5
5
  # for the app in your Shopify Partners page. Change your settings in
6
6
  # `config/initializers/shopify_app.rb`
7
7
  attr_accessor :application_name
8
- attr_accessor :api_key
8
+ attr_accessor :api_key
9
9
  attr_accessor :secret
10
10
  attr_accessor :old_secret
11
11
  attr_accessor :scope
@@ -14,13 +14,11 @@ module ShopifyApp
14
14
  attr_accessor :webhooks
15
15
  attr_accessor :scripttags
16
16
  attr_accessor :after_authenticate_job
17
- attr_reader :shop_session_repository
18
- attr_reader :user_session_repository
19
17
  attr_accessor :api_version
20
18
 
21
19
  # customise urls
22
20
  attr_accessor :root_url
23
- attr_accessor :login_url
21
+ attr_writer :login_url
24
22
 
25
23
  # customise ActiveJob queue names
26
24
  attr_accessor :scripttags_manager_queue_name
@@ -36,7 +34,10 @@ module ShopifyApp
36
34
  attr_accessor :webhook_jobs_namespace
37
35
 
38
36
  # allow enabling of same site none on cookies
39
- attr_accessor :enable_same_site_none
37
+ attr_writer :enable_same_site_none
38
+
39
+ # allow enabling jwt headers for authentication
40
+ attr_accessor :allow_jwt_authentication
40
41
 
41
42
  def initialize
42
43
  @root_url = '/'
@@ -51,15 +52,21 @@ module ShopifyApp
51
52
  end
52
53
 
53
54
  def user_session_repository=(klass)
54
- @user_session_repository = klass
55
55
  ShopifyApp::SessionRepository.user_storage = klass
56
56
  end
57
57
 
58
+ def user_session_repository
59
+ ShopifyApp::SessionRepository.user_storage
60
+ end
61
+
58
62
  def shop_session_repository=(klass)
59
- @shop_session_repository = klass
60
63
  ShopifyApp::SessionRepository.shop_storage = klass
61
64
  end
62
65
 
66
+ def shop_session_repository
67
+ ShopifyApp::SessionRepository.shop_storage
68
+ end
69
+
63
70
  def has_webhooks?
64
71
  webhooks.present?
65
72
  end
@@ -1,14 +1,14 @@
1
+ # frozen_string_literal: true
1
2
  module ShopifyApp
2
3
  module AppProxyVerification
3
4
  extend ActiveSupport::Concern
4
-
5
5
  included do
6
6
  skip_before_action :verify_authenticity_token, raise: false
7
7
  before_action :verify_proxy_request
8
8
  end
9
9
 
10
10
  def verify_proxy_request
11
- return head :forbidden unless query_string_valid?(request.query_string)
11
+ return head(:forbidden) unless query_string_valid?(request.query_string)
12
12
  end
13
13
 
14
14
  private
@@ -26,7 +26,7 @@ module ShopifyApp
26
26
  end
27
27
 
28
28
  def calculated_signature(query_hash_without_signature)
29
- sorted_params = query_hash_without_signature.collect{|k,v| "#{k}=#{Array(v).join(',')}"}.sort.join
29
+ sorted_params = query_hash_without_signature.collect { |k, v| "#{k}=#{Array(v).join(',')}" }.sort.join
30
30
 
31
31
  OpenSSL::HMAC.hexdigest(
32
32
  OpenSSL::Digest.new('sha256'),
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+ module ShopifyApp
3
+ module CsrfProtection
4
+ extend ActiveSupport::Concern
5
+ included do
6
+ protect_from_forgery with: :exception, unless: :valid_session_token?
7
+ end
8
+
9
+ private
10
+
11
+ def valid_session_token?
12
+ request.env['jwt.shopify_domain']
13
+ end
14
+ end
15
+ end
@@ -1,11 +1,12 @@
1
+ # frozen_string_literal: true
1
2
  module ShopifyApp
2
3
  module EmbeddedApp
3
4
  extend ActiveSupport::Concern
4
5
 
5
6
  included do
6
7
  if ShopifyApp.configuration.embedded_app?
7
- after_action :set_esdk_headers
8
- layout 'embedded_app'
8
+ after_action(:set_esdk_headers)
9
+ layout('embedded_app')
9
10
  end
10
11
  end
11
12
 
@@ -13,10 +13,12 @@ module ShopifyApp
13
13
  end
14
14
 
15
15
  def set_top_level_oauth_cookie
16
+ Rails.logger.debug("[ShopifyApp::Itp] Setting top level oauth cookie...")
16
17
  session['shopify.top_level_oauth'] = true
17
18
  end
18
19
 
19
20
  def clear_top_level_oauth_cookie
21
+ Rails.logger.debug("[ShopifyApp::Itp] Clearing top level oauth cookie...")
20
22
  session.delete('shopify.top_level_oauth')
21
23
  end
22
24
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ShopifyApp
2
3
  module Localization
3
4
  extend ActiveSupport::Concern
@@ -11,60 +11,111 @@ module ShopifyApp
11
11
 
12
12
  included do
13
13
  after_action :set_test_cookie
14
- rescue_from ActiveResource::UnauthorizedAccess, :with => :close_session
14
+ rescue_from ActiveResource::UnauthorizedAccess, with: :close_session
15
15
  end
16
16
 
17
+ ACCESS_TOKEN_REQUIRED_HEADER = 'X-Shopify-API-Request-Failure-Unauthorized'
18
+
17
19
  def activate_shopify_session
18
- return redirect_to_login if current_shopify_session.blank?
20
+ if user_session_expected? && user_session.blank?
21
+ Rails.logger.debug("[ShopifyApp::LoginProtection] User session required. Redirecting to login...")
22
+ signal_access_token_required
23
+ return redirect_to_login
24
+ end
25
+
26
+ if current_shopify_session.blank?
27
+ Rails.logger.debug("[ShopifyApp::LoginProtection] Current shopify session is blank. Redirecting to login...")
28
+ return redirect_to_login
29
+ end
30
+
19
31
  clear_top_level_oauth_cookie
20
32
 
21
33
  begin
34
+ Rails.logger.debug("[ShopifyApp::LoginProtection] Activating session...")
22
35
  ShopifyAPI::Base.activate_session(current_shopify_session)
23
36
  yield
24
37
  ensure
38
+ Rails.logger.debug("[ShopifyApp::LoginProtection] Clearing session...")
25
39
  ShopifyAPI::Base.clear_session
26
40
  end
27
41
  end
28
42
 
29
43
  def current_shopify_session
30
- if session[:user_id].present?
31
- @current_shopify_session ||= user_session
32
- else
33
- @current_shopify_session ||= shop_session
44
+ @current_shopify_session ||= begin
45
+ user_session || shop_session
34
46
  end
35
47
  end
36
48
 
37
49
  def user_session
38
- return if session[:user_id].blank?
50
+ user_session_by_jwt || user_session_by_cookie
51
+ end
52
+
53
+ def user_session_by_jwt
54
+ return unless ShopifyApp.configuration.allow_jwt_authentication
55
+ return unless jwt_shopify_user_id
56
+ ShopifyApp::SessionRepository.retrieve_user_session_by_shopify_user_id(jwt_shopify_user_id)
57
+ end
58
+
59
+ def user_session_by_cookie
60
+ return unless session[:user_id].present?
39
61
  ShopifyApp::SessionRepository.retrieve_user_session(session[:user_id])
40
62
  end
41
63
 
42
64
  def shop_session
43
- return if session[:shop_id].blank?
65
+ shop_session_by_jwt || shop_session_by_cookie
66
+ end
67
+
68
+ def shop_session_by_jwt
69
+ return unless ShopifyApp.configuration.allow_jwt_authentication
70
+ return unless jwt_shopify_domain
71
+ ShopifyApp::SessionRepository.retrieve_shop_session_by_shopify_domain(jwt_shopify_domain)
72
+ end
73
+
74
+ def shop_session_by_cookie
75
+ return unless session[:shop_id].present?
44
76
  ShopifyApp::SessionRepository.retrieve_shop_session(session[:shop_id])
45
77
  end
46
78
 
47
79
  def login_again_if_different_user_or_shop
48
80
  if session[:user_session].present? && params[:session].present? # session data was sent/stored correctly
81
+ Rails.logger.debug("[ShopifyApp::LoginProtection] Session data was sent/stored correctly.")
49
82
  clear_session = session[:user_session] != params[:session] # current user is different from stored user
50
-
83
+ if clear_session
84
+ Rails.logger.debug("[ShopifyApp::LoginProtection] Current user is different from stored user.")
85
+ end
86
+ clear_session
51
87
  end
52
88
 
53
- if current_shopify_session && params[:shop] && params[:shop].is_a?(String) && (current_shopify_session.domain != params[:shop])
89
+ if current_shopify_session &&
90
+ params[:shop] && params[:shop].is_a?(String) &&
91
+ (current_shopify_session.domain != params[:shop])
54
92
  clear_session = true
55
93
  end
56
94
 
57
95
  if clear_session
96
+ Rails.logger.debug("[ShopifyApp::LoginProtection] Clearing shopify session and redirecting to login...")
58
97
  clear_shopify_session
59
98
  redirect_to_login
60
99
  end
61
100
  end
62
101
 
102
+ def signal_access_token_required
103
+ response.set_header(ACCESS_TOKEN_REQUIRED_HEADER, "true")
104
+ end
105
+
63
106
  protected
64
107
 
108
+ def jwt_shopify_domain
109
+ request.env['jwt.shopify_domain']
110
+ end
111
+
112
+ def jwt_shopify_user_id
113
+ request.env['jwt.shopify_user_id']
114
+ end
115
+
65
116
  def redirect_to_login
66
117
  if request.xhr?
67
- head :unauthorized
118
+ head(:unauthorized)
68
119
  else
69
120
  if request.get?
70
121
  path = request.path
@@ -74,7 +125,7 @@ module ShopifyApp
74
125
  path = referer.path
75
126
  query = "#{referer.query}&#{sanitized_params.to_query}"
76
127
  end
77
- session[:return_to] = "#{path}?#{query}"
128
+ session[:return_to] = query.blank? ? path.to_s : "#{path}?#{query}"
78
129
  redirect_to(login_url_with_optional_shop)
79
130
  end
80
131
  end
@@ -105,7 +156,7 @@ module ShopifyApp
105
156
  query_params = {}
106
157
  query_params[:shop] = sanitized_params[:shop] if params[:shop].present?
107
158
 
108
- return_to = session[:return_to] || params[:return_to]
159
+ return_to = RedirectSafely.make_safe(session[:return_to] || params[:return_to], nil)
109
160
 
110
161
  if return_to.present? && return_to_param_required?
111
162
  query_params[:return_to] = return_to
@@ -128,14 +179,18 @@ module ShopifyApp
128
179
 
129
180
  def fullpage_redirect_to(url)
130
181
  if ShopifyApp.configuration.embedded_app?
131
- render 'shopify_app/shared/redirect', layout: false, locals: { url: url, current_shopify_domain: current_shopify_domain }
182
+ render('shopify_app/shared/redirect', layout: false,
183
+ locals: { url: url, current_shopify_domain: current_shopify_domain })
132
184
  else
133
- redirect_to url
185
+ redirect_to(url)
134
186
  end
135
187
  end
136
188
 
137
189
  def current_shopify_domain
138
- shopify_domain = sanitized_shop_name || session[:shopify_domain]
190
+ shopify_domain = sanitized_shop_name ||
191
+ jwt_shopify_domain ||
192
+ session[:shopify_domain]
193
+
139
194
  return shopify_domain if shopify_domain.present?
140
195
 
141
196
  raise ShopifyDomainNotFound
@@ -170,11 +225,18 @@ module ShopifyApp
170
225
  end
171
226
 
172
227
  def return_address
228
+ return base_return_address unless ShopifyApp.configuration.allow_jwt_authentication
229
+ return_address_with_params(shop: current_shopify_domain)
230
+ rescue ShopifyDomainNotFound
231
+ base_return_address
232
+ end
233
+
234
+ def base_return_address
173
235
  session.delete(:return_to) || ShopifyApp.configuration.root_url
174
236
  end
175
237
 
176
238
  def return_address_with_params(params)
177
- uri = URI(return_address)
239
+ uri = URI(base_return_address)
178
240
  uri.query = CGI.parse(uri.query.to_s)
179
241
  .symbolize_keys
180
242
  .transform_values { |v| v.one? ? v.first : v }
@@ -182,5 +244,11 @@ module ShopifyApp
182
244
  .to_query
183
245
  uri.to_s
184
246
  end
247
+
248
+ private
249
+
250
+ def user_session_expected?
251
+ !ShopifyApp.configuration.user_session_repository.blank? && ShopifyApp::SessionRepository.user_storage.present?
252
+ end
185
253
  end
186
254
  end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+ module ShopifyApp
3
+ module PayloadVerification
4
+ extend ActiveSupport::Concern
5
+
6
+ private
7
+
8
+ def shopify_hmac
9
+ request.headers['HTTP_X_SHOPIFY_HMAC_SHA256']
10
+ end
11
+
12
+ def hmac_valid?(data)
13
+ secrets = [ShopifyApp.configuration.secret, ShopifyApp.configuration.old_secret].reject(&:blank?)
14
+
15
+ secrets.any? do |secret|
16
+ digest = OpenSSL::Digest.new('sha256')
17
+ ActiveSupport::SecurityUtils.secure_compare(
18
+ shopify_hmac,
19
+ Base64.strict_encode64(OpenSSL::HMAC.digest(digest, secret, data))
20
+ )
21
+ end
22
+ end
23
+ end
24
+ end
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
1
2
  module ShopifyApp
2
3
  module WebhookVerification
3
4
  extend ActiveSupport::Concern
5
+ include ShopifyApp::PayloadVerification
4
6
 
5
7
  included do
6
8
  skip_before_action :verify_authenticity_token, raise: false
@@ -11,28 +13,11 @@ module ShopifyApp
11
13
 
12
14
  def verify_request
13
15
  data = request.raw_post
14
- return head :unauthorized unless hmac_valid?(data)
15
- end
16
-
17
- def hmac_valid?(data)
18
- secrets = [ShopifyApp.configuration.secret, ShopifyApp.configuration.old_secret].reject(&:blank?)
19
-
20
- secrets.any? do |secret|
21
- digest = OpenSSL::Digest.new('sha256')
22
-
23
- ActiveSupport::SecurityUtils.secure_compare(
24
- shopify_hmac,
25
- Base64.strict_encode64(OpenSSL::HMAC.digest(digest, secret, data))
26
- )
27
- end
16
+ return head(:unauthorized) unless hmac_valid?(data)
28
17
  end
29
18
 
30
19
  def shop_domain
31
20
  request.headers['HTTP_X_SHOPIFY_SHOP_DOMAIN']
32
21
  end
33
-
34
- def shopify_hmac
35
- request.headers['HTTP_X_SHOPIFY_HMAC_SHA256']
36
- end
37
22
  end
38
23
  end
@@ -1,4 +1,15 @@
1
+ # frozen_string_literal: true
1
2
  module ShopifyApp
3
+ module RedactJobParams
4
+ private
5
+
6
+ def args_info(job)
7
+ log_disabled_classes = %w(ShopifyApp::ScripttagsManagerJob ShopifyApp::WebhooksManagerJob)
8
+ return "" if log_disabled_classes.include?(job.class.name)
9
+ super
10
+ end
11
+ end
12
+
2
13
  class Engine < Rails::Engine
3
14
  engine_name 'shopify_app'
4
15
  isolate_namespace ShopifyApp
@@ -15,6 +26,21 @@ module ShopifyApp
15
26
 
16
27
  initializer "shopify_app.middleware" do |app|
17
28
  app.config.middleware.insert_after(::Rack::Runtime, ShopifyApp::SameSiteCookieMiddleware)
29
+
30
+ if ShopifyApp.configuration.allow_jwt_authentication
31
+ app.config.middleware.insert_after(ShopifyApp::SameSiteCookieMiddleware, ShopifyApp::JWTMiddleware)
32
+ end
33
+ end
34
+
35
+ initializer "shopify_app.redact_job_params" do
36
+ ActiveSupport.on_load(:active_job) do
37
+ if ActiveJob::Base.respond_to?(:log_arguments?)
38
+ WebhooksManagerJob.log_arguments = false
39
+ ScripttagsManagerJob.log_arguments = false
40
+ elsif ActiveJob::Logging::LogSubscriber.private_method_defined?(:args_info)
41
+ ActiveJob::Logging::LogSubscriber.prepend(RedactJobParams)
42
+ end
43
+ end
18
44
  end
19
45
  end
20
46
  end