shopify_app 13.0.0 → 14.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/.github/PULL_REQUEST_TEMPLATE.md +6 -0
  3. data/.github/workflows/rubocop.yml +28 -0
  4. data/.rubocop.yml +13 -6
  5. data/.travis.yml +3 -3
  6. data/CHANGELOG.md +51 -0
  7. data/Gemfile +5 -0
  8. data/README.md +79 -41
  9. data/Rakefile +1 -0
  10. data/SECURITY.md +59 -0
  11. data/app/controllers/concerns/shopify_app/authenticated.rb +1 -0
  12. data/app/controllers/concerns/shopify_app/require_known_shop.rb +39 -0
  13. data/app/controllers/shopify_app/authenticated_controller.rb +1 -0
  14. data/app/controllers/shopify_app/callback_controller.rb +41 -10
  15. data/app/controllers/shopify_app/extension_verification_controller.rb +2 -7
  16. data/app/controllers/shopify_app/sessions_controller.rb +9 -6
  17. data/app/controllers/shopify_app/webhooks_controller.rb +6 -5
  18. data/config/locales/fi.yml +1 -1
  19. data/config/locales/nl.yml +7 -7
  20. data/config/routes.rb +1 -0
  21. data/docs/Quickstart.md +7 -17
  22. data/docs/Releasing.md +1 -0
  23. data/lib/generators/shopify_app/add_after_authenticate_job/add_after_authenticate_job_generator.rb +5 -3
  24. data/lib/generators/shopify_app/add_after_authenticate_job/templates/after_authenticate_job.rb +1 -0
  25. data/lib/generators/shopify_app/add_marketing_activity_extension/add_marketing_activity_extension_generator.rb +2 -1
  26. data/lib/generators/shopify_app/add_marketing_activity_extension/templates/marketing_activities_controller.rb +4 -4
  27. data/lib/generators/shopify_app/add_webhook/add_webhook_generator.rb +5 -4
  28. data/lib/generators/shopify_app/add_webhook/templates/{webhook_job.rb → webhook_job.rb.tt} +5 -0
  29. data/lib/generators/shopify_app/app_proxy_controller/app_proxy_controller_generator.rb +4 -3
  30. data/lib/generators/shopify_app/app_proxy_controller/templates/app_proxy_controller.rb +3 -3
  31. data/lib/generators/shopify_app/app_proxy_controller/templates/app_proxy_route.rb +10 -9
  32. data/lib/generators/shopify_app/authenticated_controller/authenticated_controller_generator.rb +1 -1
  33. data/lib/generators/shopify_app/controllers/controllers_generator.rb +1 -0
  34. data/lib/generators/shopify_app/home_controller/home_controller_generator.rb +22 -3
  35. data/lib/generators/shopify_app/home_controller/templates/index.html.erb +67 -17
  36. data/lib/generators/shopify_app/home_controller/templates/unauthenticated_home_controller.rb +10 -0
  37. data/lib/generators/shopify_app/install/install_generator.rb +10 -9
  38. data/lib/generators/shopify_app/install/templates/embedded_app.html.erb +1 -1
  39. data/lib/generators/shopify_app/install/templates/flash_messages.js +0 -2
  40. data/lib/generators/shopify_app/install/templates/omniauth.rb +2 -1
  41. data/lib/generators/shopify_app/install/templates/{shopify_app.rb → shopify_app.rb.tt} +2 -1
  42. data/lib/generators/shopify_app/install/templates/user_agent.rb +2 -1
  43. data/lib/generators/shopify_app/products_controller/products_controller_generator.rb +19 -0
  44. data/lib/generators/shopify_app/products_controller/templates/products_controller.rb +8 -0
  45. data/lib/generators/shopify_app/routes/routes_generator.rb +1 -0
  46. data/lib/generators/shopify_app/routes/templates/routes.rb +10 -9
  47. data/lib/generators/shopify_app/shop_model/shop_model_generator.rb +12 -7
  48. data/lib/generators/shopify_app/shop_model/templates/shop.rb +1 -0
  49. data/lib/generators/shopify_app/shopify_app_generator.rb +4 -3
  50. data/lib/generators/shopify_app/user_model/templates/user.rb +1 -0
  51. data/lib/generators/shopify_app/user_model/user_model_generator.rb +12 -7
  52. data/lib/generators/shopify_app/views/views_generator.rb +1 -0
  53. data/lib/shopify_app/configuration.rb +15 -8
  54. data/lib/shopify_app/controller_concerns/app_proxy_verification.rb +3 -3
  55. data/lib/shopify_app/controller_concerns/csrf_protection.rb +15 -0
  56. data/lib/shopify_app/controller_concerns/embedded_app.rb +3 -2
  57. data/lib/shopify_app/controller_concerns/localization.rb +1 -0
  58. data/lib/shopify_app/controller_concerns/login_protection.rb +60 -15
  59. data/lib/shopify_app/controller_concerns/payload_verification.rb +24 -0
  60. data/lib/shopify_app/controller_concerns/webhook_verification.rb +3 -18
  61. data/lib/shopify_app/engine.rb +5 -0
  62. data/lib/shopify_app/jobs/scripttags_manager_job.rb +1 -1
  63. data/lib/shopify_app/jobs/webhooks_manager_job.rb +1 -1
  64. data/lib/shopify_app/managers/scripttags_manager.rb +4 -3
  65. data/lib/shopify_app/managers/webhooks_manager.rb +4 -3
  66. data/lib/shopify_app/middleware/jwt_middleware.rb +42 -0
  67. data/lib/shopify_app/middleware/same_site_cookie_middleware.rb +2 -1
  68. data/lib/shopify_app/session/in_memory_session_store.rb +7 -3
  69. data/lib/shopify_app/session/in_memory_shop_session_store.rb +10 -0
  70. data/lib/shopify_app/session/in_memory_user_session_store.rb +10 -0
  71. data/lib/shopify_app/session/jwt.rb +61 -0
  72. data/lib/shopify_app/session/null_user_session_store.rb +22 -0
  73. data/lib/shopify_app/session/session_repository.rb +13 -16
  74. data/lib/shopify_app/session/session_storage.rb +1 -0
  75. data/lib/shopify_app/session/shop_session_storage.rb +21 -9
  76. data/lib/shopify_app/session/user_session_storage.rb +19 -8
  77. data/lib/shopify_app/test_helpers/all.rb +2 -0
  78. data/lib/shopify_app/test_helpers/webhook_verification_helper.rb +17 -0
  79. data/lib/shopify_app/utils.rb +6 -5
  80. data/lib/shopify_app/version.rb +2 -1
  81. data/lib/shopify_app.rb +12 -5
  82. data/package-lock.json +10 -78
  83. data/package.json +1 -1
  84. data/shopify_app.gemspec +12 -7
  85. data/yarn.lock +12 -12
  86. metadata +53 -10
data/Rakefile CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'bundler/gem_tasks'
2
3
  require 'rake/testtask'
3
4
 
data/SECURITY.md ADDED
@@ -0,0 +1,59 @@
1
+ # Security Policy
2
+
3
+ ## Supported versions
4
+
5
+ ### New features
6
+
7
+ New features will only be added to the master branch and will not be made available in point releases.
8
+
9
+ ### Bug fixes
10
+
11
+ Only the latest release series will receive bug fixes. When enough bugs are fixed and its deemed worthy to release a new gem, this is the branch it happens from.
12
+
13
+ ### Security issues
14
+
15
+ Only the latest release series will receive patches and new versions in case of a security issue.
16
+
17
+ ### Severe security issues
18
+
19
+ For severe security issues we will provide new versions as above, and also the last major release series will receive patches and new versions. The classification of the security issue is judged by the core team.
20
+
21
+ ### Unsupported Release Series
22
+
23
+ When a release series is no longer supported, it's your own responsibility to deal with bugs and security issues. If you are not comfortable maintaining your own versions, you should upgrade to a supported version.
24
+
25
+ ## Reporting a bug
26
+
27
+ All security bugs in shopify repositories should be reported to [our hackerone program](https://hackerone.com/shopify)
28
+ Shopify's whitehat program is our way to reward security researchers for finding serious security vulnerabilities in the In Scope properties listed at the bottom of this page, including our core application (all functionality associated with a Shopify store, particularly your-store.myshopify.com/admin) and certain ancillary applications.
29
+
30
+ ## Disclosure Policy
31
+
32
+ We look forward to working with all security researchers and strive to be respectful, always assume the best and treat others as peers. We expect the same in return from all participants. To achieve this, our team strives to:
33
+
34
+ - Reply to all reports within one business day and triage within two business days (if applicable)
35
+ - Be as transparent as possible, answering all inquires about our report decisions and adding hackers to duplicate HackerOne reports
36
+ - Award bounties within a week of resolution (excluding extenuating circumstances)
37
+ - Only close reports as N/A when the issue reported is included in Known Issues, Ineligible Vulnerabilities Types or lacks evidence of a vulnerability
38
+
39
+ **The following rules must be followed in order for any rewards to be paid:**
40
+
41
+ - You may only test against shops you have created which include your HackerOne YOURHANDLE @ wearehackerone.com registered email address.
42
+ - You must not attempt to gain access to, or interact with, any shops other than those created by you.
43
+ - The use of commercial scanners is prohibited (e.g., Nessus).
44
+ - Rules for reporting must be followed.
45
+ - Do not disclose any issues publicly before they have been resolved.
46
+ - Shopify reserves the right to modify the rules for this program or deem any submissions invalid at any time. Shopify may cancel the whitehat program without notice at any time.
47
+ - Contacting Shopify Support over chat, email or phone about your HackerOne report is not allowed. We may disqualify you from receiving a reward, or from participating in the program altogether.
48
+ - You are not an employee of Shopify; employees should report bugs to the internal bug bounty program.
49
+ - You hereby represent, warrant and covenant that any content you submit to Shopify is an original work of authorship and that you are legally entitled to grant the rights and privileges conveyed by these terms. You further represent, warrant and covenant that the consent of no other person or entity is or will be necessary for Shopify to use the submitted content.
50
+ - By submitting content to Shopify, you irrevocably waive all moral rights which you may have in the content.
51
+ - All content submitted by you to Shopify under this program is licensed under the MIT License.
52
+ - You must report any discovered vulnerability to Shopify as soon as you have validated the vulnerability.
53
+ - Failure to follow any of the foregoing rules will disqualify you from participating in this program.
54
+
55
+ ** Please see our [Hackerone Profile](https://hackerone.com/shopify) for full details
56
+
57
+ ## Receiving Security Updates
58
+
59
+ To recieve all general updates to vulnerabilities, please subscribe to our hackerone [Hacktivity](https://hackerone.com/shopify/hacktivity)
@@ -7,6 +7,7 @@ module ShopifyApp
7
7
  included do
8
8
  include ShopifyApp::Localization
9
9
  include ShopifyApp::LoginProtection
10
+ include ShopifyApp::CsrfProtection
10
11
  include ShopifyApp::EmbeddedApp
11
12
  before_action :login_again_if_different_user_or_shop
12
13
  around_action :activate_shopify_session
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ShopifyApp
4
+ module RequireKnownShop
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ before_action :check_shop_domain
9
+ before_action :check_shop_known
10
+ end
11
+
12
+ def current_shopify_domain
13
+ return if params[:shop].blank?
14
+ @shopify_domain ||= ShopifyApp::Utils.sanitize_shop_domain(params[:shop])
15
+ end
16
+
17
+ private
18
+
19
+ def check_shop_domain
20
+ redirect_to(ShopifyApp.configuration.login_url) unless current_shopify_domain
21
+ end
22
+
23
+ def check_shop_known
24
+ @shop = SessionRepository.retrieve_shop_session_by_shopify_domain(current_shopify_domain)
25
+ redirect_to(shop_login) unless @shop
26
+ end
27
+
28
+ def shop_login
29
+ url = URI(ShopifyApp.configuration.login_url)
30
+
31
+ url.query = URI.encode_www_form(
32
+ shop: params[:shop],
33
+ return_to: request.fullpath,
34
+ )
35
+
36
+ url.to_s
37
+ end
38
+ end
39
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ShopifyApp
2
3
  class AuthenticatedController < ActionController::Base
3
4
  include ShopifyApp::Authenticated
@@ -6,10 +6,22 @@ module ShopifyApp
6
6
  include ShopifyApp::LoginProtection
7
7
 
8
8
  def callback
9
- if auth_hash
10
- login_shop
9
+ unless auth_hash
10
+ return respond_with_error
11
+ end
12
+
13
+ if jwt_request? && !valid_jwt_auth?
14
+ return respond_with_error
15
+ end
16
+
17
+ if jwt_request?
18
+ set_shopify_session
19
+ head(:ok)
20
+ else
21
+ reset_session_options
22
+ set_shopify_session
11
23
 
12
- if ShopifyApp::SessionRepository.user_storage.present? && user_session.blank?
24
+ if redirect_for_user_token?
13
25
  return redirect_to(login_url_with_optional_shop)
14
26
  end
15
27
 
@@ -17,18 +29,31 @@ module ShopifyApp
17
29
  install_scripttags
18
30
  perform_after_authenticate_job
19
31
 
20
- redirect_to return_address
32
+ redirect_to(return_address)
33
+ end
34
+ end
35
+
36
+ private
37
+
38
+ def respond_with_error
39
+ if jwt_request?
40
+ head(:unauthorized)
21
41
  else
22
42
  flash[:error] = I18n.t('could_not_log_in')
23
43
  redirect_to(login_url_with_optional_shop)
24
44
  end
25
45
  end
26
46
 
27
- private
47
+ def redirect_for_user_token?
48
+ ShopifyApp::SessionRepository.user_storage.present? && user_session.blank?
49
+ end
28
50
 
29
- def login_shop
30
- reset_session_options
31
- set_shopify_session
51
+ def jwt_request?
52
+ jwt_shopify_domain || jwt_shopify_user_id
53
+ end
54
+
55
+ def valid_jwt_auth?
56
+ auth_hash && jwt_shopify_domain == shop_name && jwt_shopify_user_id == associated_user_id
32
57
  end
33
58
 
34
59
  def auth_hash
@@ -40,9 +65,13 @@ module ShopifyApp
40
65
  end
41
66
 
42
67
  def associated_user
43
- return unless auth_hash['extra'].present?
68
+ return unless auth_hash.dig('extra', 'associated_user').present?
69
+
70
+ auth_hash['extra']['associated_user'].merge('scope' => auth_hash['extra']['associated_user_scope'])
71
+ end
44
72
 
45
- auth_hash['extra']['associated_user']
73
+ def associated_user_id
74
+ associated_user && associated_user['id']
46
75
  end
47
76
 
48
77
  def token
@@ -63,9 +92,11 @@ module ShopifyApp
63
92
 
64
93
  session[:shopify_user] = associated_user
65
94
  if session[:shopify_user].present?
95
+ session[:shop_id] = nil if shop_session && shop_session.domain != shop_name
66
96
  session[:user_id] = ShopifyApp::SessionRepository.store_user_session(session_store, associated_user)
67
97
  else
68
98
  session[:shop_id] = ShopifyApp::SessionRepository.store_shop_session(session_store)
99
+ session[:user_id] = nil if user_session && user_session.domain != shop_name
69
100
  end
70
101
  session[:shopify_domain] = shop_name
71
102
  session[:user_session] = auth_hash&.extra&.session
@@ -2,19 +2,14 @@
2
2
 
3
3
  module ShopifyApp
4
4
  class ExtensionVerificationController < ActionController::Base
5
+ include ShopifyApp::PayloadVerification
5
6
  protect_from_forgery with: :null_session
6
7
  before_action :verify_request
7
8
 
8
9
  private
9
10
 
10
11
  def verify_request
11
- hmac_header = request.headers['HTTP_X_SHOPIFY_HMAC_SHA256']
12
- request_body = request.body.read
13
- secret = ShopifyApp.configuration.secret
14
- digest = OpenSSL::Digest.new('sha256')
15
-
16
- expected_hmac = Base64.strict_encode64(OpenSSL::HMAC.digest(digest, secret, request_body))
17
- head(:unauthorized) unless ActiveSupport::SecurityUtils.secure_compare(expected_hmac, hmac_header)
12
+ head(:unauthorized) unless hmac_valid?(request.body.read)
18
13
  end
19
14
  end
20
15
  end
@@ -1,5 +1,6 @@
1
+ # frozen_string_literal: true
1
2
  module ShopifyApp
2
- class SessionsController < ActionController::Base # rubocop:disable Metrics/ClassLength
3
+ class SessionsController < ActionController::Base
3
4
  include ShopifyApp::LoginProtection
4
5
 
5
6
  layout false, only: :new
@@ -29,7 +30,7 @@ module ShopifyApp
29
30
  shop: sanitized_shop_name,
30
31
  return_to: params[:return_to]
31
32
  ),
32
- current_shopify_domain: current_shopify_domain
33
+ current_shopify_domain: current_shopify_domain,
33
34
  })
34
35
  end
35
36
 
@@ -91,6 +92,7 @@ module ShopifyApp
91
92
  end
92
93
  end
93
94
 
95
+ # rubocop:disable Lint/SuppressedException
94
96
  def set_user_tokens_option
95
97
  if shop_session.blank?
96
98
  session[:user_tokens] = false
@@ -110,6 +112,7 @@ module ShopifyApp
110
112
  session[:user_tokens] = false
111
113
  rescue StandardError
112
114
  end
115
+ # rubocop:enable Lint/SuppressedException
113
116
 
114
117
  def validate_shop_presence
115
118
  @shop = sanitized_shop_name
@@ -122,12 +125,12 @@ module ShopifyApp
122
125
  end
123
126
 
124
127
  def copy_return_to_param_to_session
125
- session[:return_to] = params[:return_to] if params[:return_to]
128
+ session[:return_to] = RedirectSafely.make_safe(params[:return_to], '/') if params[:return_to]
126
129
  end
127
130
 
128
131
  def render_invalid_shop_error
129
132
  flash[:error] = I18n.t('invalid_shop_url')
130
- redirect_to return_address
133
+ redirect_to(return_address)
131
134
  end
132
135
 
133
136
  def enable_cookie_access
@@ -138,7 +141,7 @@ module ShopifyApp
138
141
  end
139
142
 
140
143
  def authenticate_in_context
141
- redirect_to "#{main_app.root_path}auth/shopify"
144
+ redirect_to("#{main_app.root_path}auth/shopify")
142
145
  end
143
146
 
144
147
  def authenticate_at_top_level
@@ -173,7 +176,7 @@ module ShopifyApp
173
176
  shop: sanitized_shop_name,
174
177
  return_to: session[:return_to]
175
178
  ),
176
- current_shopify_domain: current_shopify_domain
179
+ current_shopify_domain: current_shopify_domain,
177
180
  }
178
181
  )
179
182
  end
@@ -1,14 +1,15 @@
1
+ # frozen_string_literal: true
1
2
  module ShopifyApp
3
+ class MissingWebhookJobError < StandardError; end
4
+
2
5
  class WebhooksController < ActionController::Base
3
6
  include ShopifyApp::WebhookVerification
4
7
 
5
- class ShopifyApp::MissingWebhookJobError < StandardError; end
6
-
7
8
  def receive
8
9
  params.permit!
9
- job_args = {shop_domain: shop_domain, webhook: webhook_params.to_h}
10
+ job_args = { shop_domain: shop_domain, webhook: webhook_params.to_h }
10
11
  webhook_job_klass.perform_later(job_args)
11
- head :no_content
12
+ head(:ok)
12
13
  end
13
14
 
14
15
  private
@@ -18,7 +19,7 @@ module ShopifyApp
18
19
  end
19
20
 
20
21
  def webhook_job_klass
21
- webhook_job_klass_name.safe_constantize or raise ShopifyApp::MissingWebhookJobError
22
+ webhook_job_klass_name.safe_constantize || raise(ShopifyApp::MissingWebhookJobError)
22
23
  end
23
24
 
24
25
  def webhook_job_klass_name(type = webhook_type)
@@ -15,6 +15,6 @@ fi:
15
15
  top_level_interaction_action: Jatka
16
16
  request_storage_access_heading: "%{app} edellyttää evästeiden käyttöä"
17
17
  request_storage_access_body: Näin sovellus voi todentaa sinut tallentamalla henkilötietosi
18
- tilapäisesti. Napsauta Jatka ja salli evästeet sovelluksen käyttämiseksi.
18
+ tilapäisesti. Klikkaa Jatka ja salli evästeet sovelluksen käyttämiseksi.
19
19
  request_storage_access_footer: Evästeet vanhenevat 30 päivän kuluttua.
20
20
  request_storage_access_action: Jatka
@@ -1,20 +1,20 @@
1
1
  ---
2
2
  nl:
3
- logged_out: u bent afgemeld
3
+ logged_out: Je bent afgemeld
4
4
  could_not_log_in: Kon niet aanmelden bij Shopify-winkel
5
5
  invalid_shop_url: Ongeldig winkeldomein
6
6
  enable_cookies_heading: Schakel cookies in van %{app}
7
- enable_cookies_body: U moet cookies in deze browser handmatig inschakelen om %{app}
7
+ enable_cookies_body: Je moet cookies in deze browser handmatig inschakelen om %{app}
8
8
  binnen Shopify te gebruiken.
9
- enable_cookies_footer: Met cookies kan de app u verifiëren door uw voorkeuren en
9
+ enable_cookies_footer: Met cookies kan de app je verifiëren door je voorkeuren en
10
10
  persoonlijke informatie tijdelijk op te slaan. Ze vervallen na 30 dagen.
11
11
  enable_cookies_action: Schakel cookies in
12
- top_level_interaction_heading: Uw browser moet %{app} verifiëren
13
- top_level_interaction_body: Uw browser heeft apps nodig zoals %{app} om u toegang
14
- te vragen tot cookies voordat Shopify het voor u kan openen.
12
+ top_level_interaction_heading: Je browser moet %{app} verifiëren
13
+ top_level_interaction_body: Je browser heeft apps nodig zoals %{app} om je toegang
14
+ te vragen tot cookies voordat Shopify het voor je kan openen.
15
15
  top_level_interaction_action: Doorgaan
16
16
  request_storage_access_heading: "%{app} heeft toegang tot cookies nodig"
17
- request_storage_access_body: Hiermee kan de app u verifiëren door uw persoonlijke
17
+ request_storage_access_body: Hiermee kan de app je verifiëren door je persoonlijke
18
18
  gegevens tijdelijk op te slaan. Klik op Doorgaan en sta cookies toe om de app
19
19
  te gebruiken.
20
20
  request_storage_access_footer: Cookies verlopen na 30 dagen.
data/config/routes.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  ShopifyApp::Engine.routes.draw do
2
3
  controller :sessions do
3
4
  get 'login' => :new, :as => :login
data/docs/Quickstart.md CHANGED
@@ -1,7 +1,8 @@
1
1
  Quickstart
2
2
  ==========
3
3
 
4
- Get started building and deploying a new Shopify App to Heroku in just a few minutes. This guide assumes you have Ruby/Rails installed on your computer already; if you haven't done that already start with [this guide.](https://guides.rubyonrails.org/v5.0/getting_started.html#installing-rails)
4
+ Get started building and deploying a new Shopify App to Heroku in just a few minutes.
5
+ This guide assumes you have Ruby, Rails and PostgreSQL installed on your computer already; if you haven't done that already start with [this guide.](https://guides.rubyonrails.org/v5.0/getting_started.html#installing-rails)
5
6
 
6
7
  1. New Rails App (with postgres)
7
8
  --------------------------------
@@ -26,15 +27,6 @@ Head to the Heroku dashboard and create a new app, or run the following commands
26
27
  CLI:
27
28
  ```sh
28
29
  $ heroku create name
29
- $ heroku git:remote -a name
30
- ```
31
-
32
- Once you have created an app on Heroku, we need to let Git know where the Heroku server is so we can deploy to it later. Copy the app's name from your Heroku dashboard and substitute `appname.git` with the name you chose earlier:
33
-
34
- web:
35
- ```sh
36
- # https://dashboard.heroku.com/new
37
- $ git remote add heroku git@heroku.com:appname.git
38
30
  ```
39
31
 
40
32
  3. Create a new App in the Shopify Partner dashboard
@@ -48,11 +40,10 @@ $ git remote add heroku git@heroku.com:appname.git
48
40
  4. Add ShopifyApp to Gemfile
49
41
  ----------------------------
50
42
 
51
- Run these commands to add the `shopify_app` Gem to your app:
43
+ Run this command to add the `shopify_app` Gem to your app:
52
44
 
53
45
  ```sh
54
- $ echo "gem 'shopify_app'" >> Gemfile
55
- $ bundle install
46
+ $ bundle add shopify_app
56
47
  ```
57
48
 
58
49
  **Note:** we recommend using the latest version of Shopify Gem. Check the [Git tags](https://github.com/Shopify/shopify_app/tags) to see the latest release version and then add it to your Gemfile e.g `gem 'shopify_app', '~> 7.0.0'`
@@ -64,14 +55,13 @@ Generate the code for your app by running these commands:
64
55
 
65
56
  ```sh
66
57
  # Use the keys from your app you created in the partners area
67
- $ rails generate shopify_app --api_key <shopify_api_key> --secret <shopify_api_secret>
58
+ $ rails generate shopify_app
68
59
  $ git add .
69
60
  $ git commit -m 'generated shopify app'
70
61
  ```
71
62
 
72
- If you forget to set your keys or redirect uri above, you will find them in the shopify_app initializer at: `/config/initializers/shopify_app.rb`.
73
-
74
- We recommend adding a gem or utilizing environment variables (`.env`) to handle your keys before releasing your app. [Learn more about using environment variables.](https://www.honeybadger.io/blog/ruby-guide-environment-variables/)
63
+ Your API key and secret are read from environment variables. Refer to the main
64
+ README for further details on how to set this up.
75
65
 
76
66
  6. Deploy your app
77
67
  ---------
data/docs/Releasing.md CHANGED
@@ -3,6 +3,7 @@ Releasing ShopifyApp
3
3
  1. Check the Semantic Versioning page for info on how to version the new release: http://semver.org
4
4
  2. Create a pull request with the following changes:
5
5
  * Update the version of ShopifyApp in lib/shopify_app/version.rb
6
+ * Update the version of shopify_app in package.json
6
7
  * Add a CHANGELOG entry for the new release with the date
7
8
  * Change the title of the PR to something like: "Packaging for release X.Y.Z"
8
9
  3. Merge your pull request
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'rails/generators/base'
2
3
 
3
4
  module ShopifyApp
@@ -6,7 +7,7 @@ module ShopifyApp
6
7
  source_root File.expand_path('../templates', __FILE__)
7
8
 
8
9
  hook_for :test_framework, as: :job, in: :rails do |instance, generator|
9
- instance.invoke generator, [ instance.send(:job_file_name) ]
10
+ instance.invoke(generator, [instance.send(:job_file_name)])
10
11
  end
11
12
 
12
13
  def init_after_authenticate_config
@@ -23,12 +24,13 @@ module ShopifyApp
23
24
  )
24
25
 
25
26
  unless initializer.include?(after_authenticate_job_config)
26
- shell.say("Error adding after_authenticate_job to config. Add this line manually: #{after_authenticate_job_config}", :red)
27
+ shell.say("Error adding after_authenticate_job to config. Add this line manually: "\
28
+ "#{after_authenticate_job_config}", :red)
27
29
  end
28
30
  end
29
31
 
30
32
  def add_after_authenticate_job
31
- template 'after_authenticate_job.rb', "app/jobs/#{job_file_name}_job.rb"
33
+ template('after_authenticate_job.rb', "app/jobs/#{job_file_name}_job.rb")
32
34
  end
33
35
 
34
36
  private