shopify_app 14.4.4 → 18.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/.github/CODEOWNERS +1 -0
  3. data/.github/ISSUE_TEMPLATE/bug-report.md +63 -0
  4. data/.github/ISSUE_TEMPLATE/config.yml +1 -0
  5. data/.github/ISSUE_TEMPLATE/feature-request.md +33 -0
  6. data/.github/PULL_REQUEST_TEMPLATE.md +17 -1
  7. data/.github/workflows/build.yml +41 -0
  8. data/.github/workflows/release.yml +24 -0
  9. data/.github/workflows/rubocop.yml +1 -7
  10. data/.gitignore +0 -2
  11. data/CHANGELOG.md +75 -0
  12. data/CONTRIBUTING.md +76 -0
  13. data/Gemfile.lock +268 -0
  14. data/README.md +73 -572
  15. data/app/assets/images/storage_access.svg +1 -2
  16. data/app/assets/javascripts/shopify_app/post_redirect.js +9 -0
  17. data/app/controllers/concerns/shopify_app/ensure_authenticated_links.rb +26 -0
  18. data/app/controllers/concerns/shopify_app/shop_access_scopes_verification.rb +32 -0
  19. data/app/controllers/shopify_app/callback_controller.rb +34 -10
  20. data/app/controllers/shopify_app/sessions_controller.rb +19 -20
  21. data/app/views/shopify_app/partials/_button_styles.html.erb +41 -36
  22. data/app/views/shopify_app/partials/_card_styles.html.erb +3 -3
  23. data/app/views/shopify_app/partials/_empty_state_styles.html.erb +28 -59
  24. data/app/views/shopify_app/partials/_form_styles.html.erb +56 -0
  25. data/app/views/shopify_app/partials/_layout_styles.html.erb +16 -1
  26. data/app/views/shopify_app/partials/_typography_styles.html.erb +6 -6
  27. data/app/views/shopify_app/sessions/enable_cookies.html.erb +1 -1
  28. data/app/views/shopify_app/sessions/new.html.erb +38 -110
  29. data/app/views/shopify_app/sessions/request_storage_access.html.erb +1 -1
  30. data/app/views/shopify_app/sessions/top_level_interaction.html.erb +20 -15
  31. data/app/views/shopify_app/shared/post_redirect_to_auth_shopify.html.erb +13 -0
  32. data/config/locales/de.yml +11 -11
  33. data/config/locales/nl.yml +1 -1
  34. data/config/locales/vi.yml +22 -0
  35. data/config/locales/zh-CN.yml +1 -1
  36. data/docs/Quickstart.md +15 -77
  37. data/docs/Releasing.md +9 -6
  38. data/docs/Troubleshooting.md +147 -4
  39. data/docs/Upgrading.md +126 -0
  40. data/docs/shopify_app/authentication.md +124 -0
  41. data/docs/shopify_app/engine.md +82 -0
  42. data/docs/shopify_app/generators.md +127 -0
  43. data/docs/shopify_app/handling-access-scopes-changes.md +14 -0
  44. data/docs/shopify_app/script-tags.md +28 -0
  45. data/docs/shopify_app/session-repository.md +88 -0
  46. data/docs/shopify_app/testing.md +38 -0
  47. data/docs/shopify_app/webhooks.md +72 -0
  48. data/lib/generators/shopify_app/home_controller/home_controller_generator.rb +16 -7
  49. data/lib/generators/shopify_app/home_controller/templates/home_controller.rb +10 -0
  50. data/lib/generators/shopify_app/home_controller/templates/index.html.erb +11 -11
  51. data/lib/generators/shopify_app/home_controller/templates/unauthenticated_home_controller.rb +2 -0
  52. data/lib/generators/shopify_app/install/install_generator.rb +36 -2
  53. data/lib/generators/shopify_app/install/templates/embedded_app.html.erb +2 -1
  54. data/lib/generators/shopify_app/install/templates/omniauth.rb +1 -0
  55. data/lib/generators/shopify_app/install/templates/shopify_app.js +1 -1
  56. data/lib/generators/shopify_app/install/templates/shopify_app.rb.tt +13 -4
  57. data/lib/generators/shopify_app/install/templates/shopify_provider.rb.tt +8 -0
  58. data/lib/generators/shopify_app/shop_model/shop_model_generator.rb +27 -0
  59. data/lib/generators/shopify_app/shop_model/templates/db/migrate/add_shop_access_scopes_column.erb +5 -0
  60. data/lib/generators/shopify_app/shop_model/templates/shop.rb +1 -1
  61. data/lib/generators/shopify_app/shopify_app_generator.rb +1 -1
  62. data/lib/generators/shopify_app/user_model/templates/db/migrate/add_user_access_scopes_column.erb +5 -0
  63. data/lib/generators/shopify_app/user_model/templates/user.rb +1 -1
  64. data/lib/generators/shopify_app/user_model/user_model_generator.rb +27 -0
  65. data/lib/shopify_app/access_scopes/noop_strategy.rb +13 -0
  66. data/lib/shopify_app/access_scopes/shop_strategy.rb +24 -0
  67. data/lib/shopify_app/access_scopes/user_strategy.rb +41 -0
  68. data/lib/shopify_app/configuration.rb +25 -0
  69. data/lib/shopify_app/controller_concerns/itp.rb +0 -2
  70. data/lib/shopify_app/controller_concerns/login_protection.rb +14 -17
  71. data/lib/shopify_app/engine.rb +1 -0
  72. data/lib/shopify_app/middleware/same_site_cookie_middleware.rb +1 -1
  73. data/lib/shopify_app/omniauth/omniauth_configuration.rb +64 -0
  74. data/lib/shopify_app/session/in_memory_shop_session_store.rb +9 -7
  75. data/lib/shopify_app/session/in_memory_user_session_store.rb +9 -7
  76. data/lib/shopify_app/session/jwt.rb +3 -1
  77. data/lib/shopify_app/session/shop_session_storage_with_scopes.rb +58 -0
  78. data/lib/shopify_app/session/user_session_storage_with_scopes.rb +58 -0
  79. data/lib/shopify_app/utils.rb +12 -0
  80. data/lib/shopify_app/version.rb +1 -1
  81. data/lib/shopify_app.rb +11 -0
  82. data/package.json +1 -1
  83. data/service.yml +1 -4
  84. data/shopify_app.gemspec +5 -4
  85. data/translation.yml +1 -1
  86. data/yarn.lock +92 -123
  87. metadata +62 -16
  88. data/.github/ISSUE_TEMPLATE.md +0 -19
  89. data/.travis.yml +0 -27
  90. data/docs/install-on-dev-shop.png +0 -0
  91. data/docs/test-your-app.png +0 -0
  92. data/lib/generators/shopify_app/install/templates/shopify_provider.rb +0 -20
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ShopifyApp
4
+ module AccessScopes
5
+ class UserStrategy
6
+ class InvalidInput < StandardError; end
7
+
8
+ class << self
9
+ def update_access_scopes?(user_id: nil, shopify_user_id: nil)
10
+ return update_access_scopes_for_user_id?(user_id) if user_id
11
+ return update_access_scopes_for_shopify_user_id?(shopify_user_id) if shopify_user_id
12
+ raise(InvalidInput, '#update_access_scopes? requires user_id or shopify_user_id parameter inputs')
13
+ end
14
+
15
+ private
16
+
17
+ def update_access_scopes_for_user_id?(user_id)
18
+ user_access_scopes = user_access_scopes_by_user_id(user_id)
19
+ configuration_access_scopes != user_access_scopes
20
+ end
21
+
22
+ def update_access_scopes_for_shopify_user_id?(shopify_user_id)
23
+ user_access_scopes = user_access_scopes_by_shopify_user_id(shopify_user_id)
24
+ configuration_access_scopes != user_access_scopes
25
+ end
26
+
27
+ def user_access_scopes_by_user_id(user_id)
28
+ ShopifyApp::SessionRepository.retrieve_user_session(user_id)&.access_scopes
29
+ end
30
+
31
+ def user_access_scopes_by_shopify_user_id(shopify_user_id)
32
+ ShopifyApp::SessionRepository.retrieve_user_session_by_shopify_user_id(shopify_user_id)&.access_scopes
33
+ end
34
+
35
+ def configuration_access_scopes
36
+ ShopifyAPI::ApiAccess.new(ShopifyApp.configuration.user_access_scopes)
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -9,6 +9,8 @@ module ShopifyApp
9
9
  attr_accessor :secret
10
10
  attr_accessor :old_secret
11
11
  attr_accessor :scope
12
+ attr_writer :shop_access_scopes
13
+ attr_writer :user_access_scopes
12
14
  attr_accessor :embedded_app
13
15
  alias_method :embedded_app?, :embedded_app
14
16
  attr_accessor :webhooks
@@ -16,6 +18,8 @@ module ShopifyApp
16
18
  attr_accessor :after_authenticate_job
17
19
  attr_accessor :api_version
18
20
 
21
+ attr_accessor :reauth_on_access_scope_changes
22
+
19
23
  # customise urls
20
24
  attr_accessor :root_url
21
25
  attr_writer :login_url
@@ -39,12 +43,15 @@ module ShopifyApp
39
43
  # allow enabling jwt headers for authentication
40
44
  attr_accessor :allow_jwt_authentication
41
45
 
46
+ attr_accessor :allow_cookie_authentication
47
+
42
48
  def initialize
43
49
  @root_url = '/'
44
50
  @myshopify_domain = 'myshopify.com'
45
51
  @scripttags_manager_queue_name = Rails.application.config.active_job.queue_name
46
52
  @webhooks_manager_queue_name = Rails.application.config.active_job.queue_name
47
53
  @disable_webpacker = ENV['SHOPIFY_APP_DISABLE_WEBPACKER'].present?
54
+ @allow_cookie_authentication = true
48
55
  end
49
56
 
50
57
  def login_url
@@ -67,6 +74,16 @@ module ShopifyApp
67
74
  ShopifyApp::SessionRepository.shop_storage
68
75
  end
69
76
 
77
+ def shop_access_scopes_strategy
78
+ return ShopifyApp::AccessScopes::NoopStrategy unless reauth_on_access_scope_changes
79
+ ShopifyApp::AccessScopes::ShopStrategy
80
+ end
81
+
82
+ def user_access_scopes_strategy
83
+ return ShopifyApp::AccessScopes::NoopStrategy unless reauth_on_access_scope_changes
84
+ ShopifyApp::AccessScopes::UserStrategy
85
+ end
86
+
70
87
  def has_webhooks?
71
88
  webhooks.present?
72
89
  end
@@ -78,6 +95,14 @@ module ShopifyApp
78
95
  def enable_same_site_none
79
96
  !Rails.env.test? && (@enable_same_site_none.nil? ? embedded_app? : @enable_same_site_none)
80
97
  end
98
+
99
+ def shop_access_scopes
100
+ @shop_access_scopes || scope
101
+ end
102
+
103
+ def user_access_scopes
104
+ @user_access_scopes || scope
105
+ end
81
106
  end
82
107
 
83
108
  def self.configuration
@@ -13,12 +13,10 @@ 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...")
17
16
  session['shopify.top_level_oauth'] = true
18
17
  end
19
18
 
20
19
  def clear_top_level_oauth_cookie
21
- Rails.logger.debug("[ShopifyApp::Itp] Clearing top level oauth cookie...")
22
20
  session.delete('shopify.top_level_oauth')
23
21
  end
24
22
 
@@ -9,6 +9,8 @@ module ShopifyApp
9
9
 
10
10
  class ShopifyDomainNotFound < StandardError; end
11
11
 
12
+ class ShopifyHostNotFound < StandardError; end
13
+
12
14
  included do
13
15
  after_action :set_test_cookie
14
16
  rescue_from ActiveResource::UnauthorizedAccess, with: :close_session
@@ -18,24 +20,18 @@ module ShopifyApp
18
20
 
19
21
  def activate_shopify_session
20
22
  if user_session_expected? && user_session.blank?
21
- Rails.logger.debug("[ShopifyApp::LoginProtection] User session required. Redirecting to login...")
22
23
  signal_access_token_required
23
24
  return redirect_to_login
24
25
  end
25
26
 
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
27
+ return redirect_to_login if current_shopify_session.blank?
30
28
 
31
29
  clear_top_level_oauth_cookie
32
30
 
33
31
  begin
34
- Rails.logger.debug("[ShopifyApp::LoginProtection] Activating session...")
35
32
  ShopifyAPI::Base.activate_session(current_shopify_session)
36
33
  yield
37
34
  ensure
38
- Rails.logger.debug("[ShopifyApp::LoginProtection] Clearing session...")
39
35
  ShopifyAPI::Base.clear_session
40
36
  end
41
37
  end
@@ -57,6 +53,7 @@ module ShopifyApp
57
53
  end
58
54
 
59
55
  def user_session_by_cookie
56
+ return unless ShopifyApp.configuration.allow_cookie_authentication
60
57
  return unless session[:user_id].present?
61
58
  ShopifyApp::SessionRepository.retrieve_user_session(session[:user_id])
62
59
  end
@@ -72,18 +69,14 @@ module ShopifyApp
72
69
  end
73
70
 
74
71
  def shop_session_by_cookie
72
+ return unless ShopifyApp.configuration.allow_cookie_authentication
75
73
  return unless session[:shop_id].present?
76
74
  ShopifyApp::SessionRepository.retrieve_shop_session(session[:shop_id])
77
75
  end
78
76
 
79
77
  def login_again_if_different_user_or_shop
80
78
  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.")
82
79
  clear_session = session[:user_session] != params[:session] # current user is different from stored user
83
- if clear_session
84
- Rails.logger.debug("[ShopifyApp::LoginProtection] Current user is different from stored user.")
85
- end
86
- clear_session
87
80
  end
88
81
 
89
82
  if current_shopify_session &&
@@ -93,14 +86,13 @@ module ShopifyApp
93
86
  end
94
87
 
95
88
  if clear_session
96
- Rails.logger.debug("[ShopifyApp::LoginProtection] Clearing shopify session and redirecting to login...")
97
89
  clear_shopify_session
98
90
  redirect_to_login
99
91
  end
100
92
  end
101
93
 
102
94
  def signal_access_token_required
103
- response.set_header(ACCESS_TOKEN_REQUIRED_HEADER, true)
95
+ response.set_header(ACCESS_TOKEN_REQUIRED_HEADER, "true")
104
96
  end
105
97
 
106
98
  protected
@@ -113,6 +105,12 @@ module ShopifyApp
113
105
  request.env['jwt.shopify_user_id']
114
106
  end
115
107
 
108
+ def host
109
+ return params[:host] if params[:host].present?
110
+
111
+ raise ShopifyHostNotFound
112
+ end
113
+
116
114
  def redirect_to_login
117
115
  if request.xhr?
118
116
  head(:unauthorized)
@@ -225,9 +223,8 @@ module ShopifyApp
225
223
  end
226
224
 
227
225
  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
226
+ return_address_with_params(shop: current_shopify_domain, host: host)
227
+ rescue ShopifyDomainNotFound, ShopifyHostNotFound
231
228
  base_return_address
232
229
  end
233
230
 
@@ -17,6 +17,7 @@ module ShopifyApp
17
17
  initializer "shopify_app.assets.precompile" do |app|
18
18
  app.config.assets.precompile += %w[
19
19
  shopify_app/redirect.js
20
+ shopify_app/post_redirect.js
20
21
  shopify_app/top_level.js
21
22
  shopify_app/enable_cookies.js
22
23
  shopify_app/request_storage_access.js
@@ -21,7 +21,7 @@ module ShopifyApp
21
21
  .compact
22
22
  .map do |cookie|
23
23
  cookie << '; Secure' unless cookie =~ /;\s*secure/i
24
- cookie << '; SameSite=None' unless cookie =~ /;\s*samesite=/i
24
+ cookie << '; SameSite=None' if ShopifyApp.configuration.embedded_app?
25
25
  cookie
26
26
  end
27
27
 
@@ -0,0 +1,64 @@
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
@@ -1,14 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
  module ShopifyApp
3
3
  class InMemoryShopSessionStore < InMemorySessionStore
4
- def self.store(session, *args)
5
- id = super
6
- repo[session.domain] = session
7
- id
8
- end
4
+ class << self
5
+ def store(session, *args)
6
+ id = super
7
+ repo[session.domain] = session
8
+ id
9
+ end
9
10
 
10
- def self.retrieve_by_shopify_domain(shopify_domain)
11
- repo[shopify_domain]
11
+ def retrieve_by_shopify_domain(shopify_domain)
12
+ repo[shopify_domain]
13
+ end
12
14
  end
13
15
  end
14
16
  end
@@ -1,14 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
  module ShopifyApp
3
3
  class InMemoryUserSessionStore < InMemorySessionStore
4
- def self.store(session, user)
5
- id = super
6
- repo[user.shopify_user_id] = session
7
- id
8
- end
4
+ class << self
5
+ def store(session, user)
6
+ id = super
7
+ repo[user.shopify_user_id] = session
8
+ id
9
+ end
9
10
 
10
- def self.retrieve_by_shopify_user_id(user_id)
11
- repo[user_id]
11
+ def retrieve_by_shopify_user_id(user_id)
12
+ repo[user_id]
13
+ end
12
14
  end
13
15
  end
14
16
  end
@@ -2,7 +2,9 @@
2
2
  module ShopifyApp
3
3
  class JWT
4
4
  class InvalidDestinationError < StandardError; end
5
+
5
6
  class MismatchedHostsError < StandardError; end
7
+
6
8
  class InvalidAudienceError < StandardError; end
7
9
 
8
10
  WARN_EXCEPTIONS = [
@@ -25,7 +27,7 @@ module ShopifyApp
25
27
  end
26
28
 
27
29
  def shopify_user_id
28
- @payload && @payload['sub']
30
+ @payload['sub'].to_i if @payload && @payload['sub']
29
31
  end
30
32
 
31
33
  private
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ShopifyApp
4
+ module ShopSessionStorageWithScopes
5
+ extend ActiveSupport::Concern
6
+ include ::ShopifyApp::SessionStorage
7
+
8
+ included do
9
+ validates :shopify_domain, presence: true, uniqueness: { case_sensitive: false }
10
+ end
11
+
12
+ class_methods do
13
+ def store(auth_session, *_args)
14
+ shop = find_or_initialize_by(shopify_domain: auth_session.domain)
15
+ shop.shopify_token = auth_session.token
16
+ shop.access_scopes = auth_session.access_scopes
17
+
18
+ shop.save!
19
+ shop.id
20
+ end
21
+
22
+ def retrieve(id)
23
+ shop = find_by(id: id)
24
+ construct_session(shop)
25
+ end
26
+
27
+ def retrieve_by_shopify_domain(domain)
28
+ shop = find_by(shopify_domain: domain)
29
+ construct_session(shop)
30
+ end
31
+
32
+ private
33
+
34
+ def construct_session(shop)
35
+ return unless shop
36
+
37
+ ShopifyAPI::Session.new(
38
+ domain: shop.shopify_domain,
39
+ token: shop.shopify_token,
40
+ api_version: shop.api_version,
41
+ access_scopes: shop.access_scopes
42
+ )
43
+ end
44
+ end
45
+
46
+ def access_scopes=(scopes)
47
+ super(scopes)
48
+ rescue NotImplementedError, NoMethodError
49
+ raise NotImplementedError, "#access_scopes= must be defined to handle storing access scopes: #{scopes}"
50
+ end
51
+
52
+ def access_scopes
53
+ super
54
+ rescue NotImplementedError, NoMethodError
55
+ raise NotImplementedError, "#access_scopes= must be defined to hook into stored access scopes"
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+ module ShopifyApp
3
+ module UserSessionStorageWithScopes
4
+ extend ActiveSupport::Concern
5
+ include ::ShopifyApp::SessionStorage
6
+
7
+ included do
8
+ validates :shopify_domain, presence: true
9
+ end
10
+
11
+ class_methods do
12
+ def store(auth_session, user)
13
+ user = find_or_initialize_by(shopify_user_id: user[:id])
14
+ user.shopify_token = auth_session.token
15
+ user.shopify_domain = auth_session.domain
16
+ user.access_scopes = auth_session.access_scopes
17
+
18
+ user.save!
19
+ user.id
20
+ end
21
+
22
+ def retrieve(id)
23
+ user = find_by(id: id)
24
+ construct_session(user)
25
+ end
26
+
27
+ def retrieve_by_shopify_user_id(user_id)
28
+ user = find_by(shopify_user_id: user_id)
29
+ construct_session(user)
30
+ end
31
+
32
+ private
33
+
34
+ def construct_session(user)
35
+ return unless user
36
+
37
+ ShopifyAPI::Session.new(
38
+ domain: user.shopify_domain,
39
+ token: user.shopify_token,
40
+ api_version: user.api_version,
41
+ access_scopes: user.access_scopes
42
+ )
43
+ end
44
+ end
45
+
46
+ def access_scopes=(scopes)
47
+ super(scopes)
48
+ rescue NotImplementedError, NoMethodError
49
+ raise NotImplementedError, "#access_scopes= must be defined to handle storing access scopes: #{scopes}"
50
+ end
51
+
52
+ def access_scopes
53
+ super
54
+ rescue NotImplementedError, NoMethodError
55
+ raise NotImplementedError, "#access_scopes= must be defined to hook into stored access scopes"
56
+ end
57
+ end
58
+ end
@@ -20,5 +20,17 @@ module ShopifyApp
20
20
  rescue ActiveResource::ConnectionError
21
21
  logger.error("[ShopifyAPI::ApiVersion] Unable to fetch api_versions from Shopify")
22
22
  end
23
+
24
+ def self.shop_login_url(shop:, return_to:)
25
+ return ShopifyApp.configuration.login_url unless shop
26
+ url = URI(ShopifyApp.configuration.login_url)
27
+
28
+ url.query = URI.encode_www_form(
29
+ shop: shop,
30
+ return_to: return_to,
31
+ )
32
+
33
+ url.to_s
34
+ end
23
35
  end
24
36
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module ShopifyApp
3
- VERSION = '14.4.4'
3
+ VERSION = '18.0.2'
4
4
  end
data/lib/shopify_app.rb CHANGED
@@ -3,6 +3,7 @@ require 'shopify_app/version'
3
3
 
4
4
  # deps
5
5
  require 'shopify_api'
6
+ require 'omniauth/rails_csrf_protection'
6
7
  require 'omniauth-shopify-oauth2'
7
8
  require 'redirect_safely'
8
9
 
@@ -57,5 +58,15 @@ module ShopifyApp
57
58
  require 'shopify_app/session/session_repository'
58
59
  require 'shopify_app/session/session_storage'
59
60
  require 'shopify_app/session/shop_session_storage'
61
+ require 'shopify_app/session/shop_session_storage_with_scopes'
60
62
  require 'shopify_app/session/user_session_storage'
63
+ require 'shopify_app/session/user_session_storage_with_scopes'
64
+
65
+ # access scopes strategies
66
+ require 'shopify_app/access_scopes/shop_strategy'
67
+ require 'shopify_app/access_scopes/user_strategy'
68
+ require 'shopify_app/access_scopes/noop_strategy'
69
+
70
+ # omniauth_configuration
71
+ require 'shopify_app/omniauth/omniauth_configuration'
61
72
  end
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shopify_app",
3
- "version": "14.4.4",
3
+ "version": "18.0.2",
4
4
  "repository": "git@github.com:Shopify/shopify_app.git",
5
5
  "author": "Shopify",
6
6
  "license": "MIT",
data/service.yml CHANGED
@@ -1,7 +1,4 @@
1
1
  audience: partner
2
2
  classification: library
3
- org_line: App & Partner Platform
4
- owners:
5
- - Shopify/platform-dev-tools-education
6
3
  slack_channels:
7
- - dev-tools-education
4
+ - shopify_app_gem
data/shopify_app.gemspec CHANGED
@@ -14,10 +14,11 @@ Gem::Specification.new do |s|
14
14
  s.metadata['allowed_push_host'] = 'https://rubygems.org'
15
15
 
16
16
  s.add_runtime_dependency('browser_sniffer', '~> 1.2.2')
17
- s.add_runtime_dependency('rails', '> 5.2.1')
18
- s.add_runtime_dependency('shopify_api', '~> 9.1')
19
- s.add_runtime_dependency('omniauth-shopify-oauth2', '~> 2.2.2')
20
- s.add_runtime_dependency('jwt', '~> 2.2.1')
17
+ s.add_runtime_dependency('omniauth-rails_csrf_protection')
18
+ s.add_runtime_dependency('rails', '> 5.2.1', '< 6.2')
19
+ s.add_runtime_dependency('shopify_api', '~> 9.4')
20
+ s.add_runtime_dependency('omniauth-shopify-oauth2', '~> 2.3')
21
+ s.add_runtime_dependency('jwt', '>= 2.2.3')
21
22
  s.add_runtime_dependency('redirect_safely', '~> 1.0')
22
23
 
23
24
  s.add_development_dependency('rake')
data/translation.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  source_language: en
2
- target_languages: [cs, da, de, es, fi, fr, hi, it, ja, ko, ms, nb, nl, pl, pt-BR, pt-PT, sv, th, tr, zh-CN, zh-TW]
2
+ target_languages: [cs, da, de, es, fi, fr, hi, it, ja, ko, ms, nb, nl, pl, pt-BR, pt-PT, sv, th, tr, vi, zh-CN, zh-TW]
3
3
  components:
4
4
  - name: 'merchant'
5
5
  paths: