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

Create OmniAuthConfiguration object to build future OmniAuth strategies #1190

Merged

Conversation

NabeelAhsen
Copy link
Contributor

@NabeelAhsen NabeelAhsen commented Feb 19, 2021

This PR introduces the following:

  1. A new OmniAuthConfiguration object
  2. New configurations for ShopifyApp.configuration
  • shop_access_scopes: These default to the old ShopifyApp.configuration.scope config
  • user_access_scopes: These default to the old ShopifyApp.configuration.scope config

The intent is to use this object in the future to help us define and build omniauth strategies. This will be especially important in upcoming changes related to scope changes.

Here's how partners can use this in their omniauth.rb files:

Rails.application.config.middleware.use(OmniAuth::Builder) do
  provider :foo
      api_key,
      secret,
      scope: 'read_products',
      setup: lambda { |env|
        configuration = ShopifyApp::OmniauthConfiguration.new(env['omniauth.strategy'], Rack::Request.new(env))
        configuration.build_options
      }
end

For now, this class is not being used anywhere else in the library. A future PR will introduce default strategies for partners who use offline access tokens saved in their Shop records and online access tokens saved in their User records.

Based on the parent branch: https://github.com/Shopify/shopify_app/compare/scope-strategies

Before submitting the PR, please consider if any of the following are needed:

  • Update CHANGELOG.md if the changes would impact users
  • Update README.md, if appropriate.
  • Update any relevant pages in docs/, if necessary
  • For security fixes, the Disclosure Policy must be followed.

@NabeelAhsen NabeelAhsen requested a review from a team as a code owner February 19, 2021 13:36
@NabeelAhsen NabeelAhsen self-assigned this Feb 19, 2021
@NabeelAhsen NabeelAhsen force-pushed the scope-changes/create-omniauth-configuration-object branch from aa98f9e to 20b69c3 Compare February 19, 2021 14:53
Copy link
Contributor

@rezaansyed rezaansyed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍞

@NabeelAhsen NabeelAhsen requested a review from ragalie February 19, 2021 18:38
@NabeelAhsen NabeelAhsen force-pushed the scope-changes/create-omniauth-configuration-object branch 2 times, most recently from f53d0d8 to 20b69c3 Compare February 19, 2021 19:37
@@ -81,6 +83,14 @@ def has_scripttags?
def enable_same_site_none
!Rails.env.test? && (@enable_same_site_none.nil? ? embedded_app? : @enable_same_site_none)
end

def shop_access_scopes
@shop_access_scopes || scope
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems a little odd to return a singular item scope when the method name implies a collection.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed! However, the scope attribute has been used to define a collection of scopes stored in a string for a while now. Changing this will be a breaking change for shopify_app developers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, we can mark this as future work to update scope to scopes.

@NabeelAhsen NabeelAhsen merged commit ca9f6a1 into master Feb 22, 2021
@NabeelAhsen NabeelAhsen deleted the scope-changes/create-omniauth-configuration-object branch February 22, 2021 18:08
@rezaansyed rezaansyed mentioned this pull request Mar 4, 2021
4 tasks
@rezaansyed rezaansyed temporarily deployed to rubygems March 5, 2021 15:45 Inactive
@jmndoza
Copy link

jmndoza commented Feb 24, 2023

is this implementation still valid? I can't find any reference to OmniAuthConfiguration, I would like to modify ShopifyApp.configuration (and ShopifyAPI::Context.setup) in runtime

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants