Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new configuration flag for token exchange #1778

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/shopify_app/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ class Configuration
# takes a ShopifyApp::BillingConfiguration object
attr_accessor :billing

# Work in Progress: enables token exchange authentication flow
attr_accessor :wip_new_embedded_auth_strategy

def initialize
@root_url = "/"
@myshopify_domain = "myshopify.com"
Expand Down Expand Up @@ -118,6 +121,10 @@ def shop_access_scopes
def user_access_scopes
@user_access_scopes || scope
end

def use_new_embedded_auth_strategy?
wip_new_embedded_auth_strategy && embedded_app?
end
end

class BillingConfiguration
Expand Down
26 changes: 26 additions & 0 deletions test/shopify_app/configuration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -228,4 +228,30 @@ class ConfigurationTest < ActiveSupport::TestCase
end
assert_equal "Invalid user access scopes strategy - expected a string", error.message
end

test "#use_new_embedded_auth_strategy? is true when wip_new_embedded_auth_strategy is on for embedded apps" do
ShopifyApp.configure do |config|
config.embedded_app = true
config.wip_new_embedded_auth_strategy = true
end

assert ShopifyApp.configuration.use_new_embedded_auth_strategy?
end

test "#use_new_embedded_auth_strategy? is false for non-embedded apps even if wip_new_embedded_auth_strategy is configured" do
ShopifyApp.configure do |config|
config.embedded_app = false
config.wip_new_embedded_auth_strategy = true
end

refute ShopifyApp.configuration.use_new_embedded_auth_strategy?
end

test "#use_new_embedded_auth_strategy? is false when wip_new_embedded_auth_strategy is off" do
ShopifyApp.configure do |config|
config.wip_new_embedded_auth_strategy = false
end

refute ShopifyApp.configuration.use_new_embedded_auth_strategy?
end
end