Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Fix partners ability to login to external shops #1873

Merged
merged 8 commits into from
Jan 13, 2022
Merged

Conversation

molly-yu
Copy link
Contributor

@molly-yu molly-yu commented Dec 21, 2021

WHY are these changes introduced?

Fixes #1833, #1652 (related).
Partners were able to log into stores that were not their own, through shopify login --store=STORE, where STORE is not supposed to be accessible by the Partners account.

WHAT is this pull request doing?

Previously, the login command was checking the store validity first, then dealing with the user authentication. I changed the code so that it checks that the store belongs to the Partner, after authentication.

How to test your changes?

  1. Find a store that does not belong to your Partners account
  2. Run shopify-dev login --store=STORE
  3. It should fail and show an error message (this is the same message shown when STORE is an invalid store)
    ** when STORE belongs to the Partners account, login should succeed.

Post-release steps

Update checklist

  • I've added a CHANGELOG entry for this PR (if the change is public-facing)
  • I've considered possible cross-platform impacts (Mac, Linux, Windows).
  • I've left the version number as is (we'll handle incrementing this when releasing).
  • I've included any post-release steps in the section above.

@molly-yu molly-yu requested review from a team, hannachen, jesalerno84 and MeredithCastile and removed request for a team December 21, 2021 16:30
@@ -415,7 +415,7 @@ module Messages
Usage: {{command:%s login [--store=STORE]}}
HELP
invalid_shop: <<~MESSAGE,
Invalid store provided (%s). Please provide the store in the following format: my-store.myshopify.com
Invalid store provided (%s). Please make sure that the store belongs to your partner organization, and provide the store in the following format: my-store.myshopify.com
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@MeredithCastile This is the error message shown when either: the store is invalid, or the store doesn't belong to the partners account. I'm not entirely sure if it would be better to separate the cases into two error messages... Open to any suggestions!

Choose a reason for hiding this comment

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

@molly-yu It would probably be better to separate it into two specific error messages. I am getting this error since upgrading to 2.9.0 even though I have been granted partner access to a store, and I don't know how to fix it.

end

def self.help
ShopifyCLI::Context.message("core.login.help", ShopifyCLI::TOOL_NAME)
end

def self.validate_shop(shop, context:)
def self.validate_shop(shop, org, context:)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: I'd use keyed arguments to make it clear from the caller what every argument means.

def self.validate_shop(shop:, org:, context:)

Copy link
Contributor

@pepicrft pepicrft left a comment

Choose a reason for hiding this comment

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

Great job @molly-yu 👏🏼. I'd also update the CHANGELOG to include this improvement.

@molly-yu molly-yu merged commit 419e952 into main Jan 13, 2022
@molly-yu molly-yu deleted the partners-login-security branch January 13, 2022 16:22
@molly-yu molly-yu restored the partners-login-security branch January 13, 2022 16:33
molly-yu added a commit that referenced this pull request Jan 13, 2022
Fix test for #1873: Fix partners ability to login to external shops
@stephszeto
Copy link
Contributor

Molly, does this comment feel like a related error (shopify store all says you're logged in when it seems like you're actually not)?

@molly-yu molly-yu deleted the partners-login-security branch January 14, 2022 15:34
@molly-yu
Copy link
Contributor Author

Molly, does this comment feel like a related error (shopify store all says you're logged in when it seems like you're actually not)?

Hmm interesting, this is definitely related to the other auth/login issues. It seems like there are a lot of commands that are affected by the wonky login. I'll check this out too. Thanks for catching this Steph!

@molly-yu
Copy link
Contributor Author

Maybe we can create a separate issue for this, and put it under authentication-related issues

@stephszeto
Copy link
Contributor

Tracking it in this new issue.

@shopify-shipit shopify-shipit bot temporarily deployed to rubygems January 17, 2022 17:34 Inactive
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bonkers Security
4 participants