[WIP] [Feature] Implement custom auth guard for Shopify sessions and enable unit and feature testing.#469
Draft
grahamsutton wants to merge 4 commits intoShopify:mainfrom
Draft
[WIP] [Feature] Implement custom auth guard for Shopify sessions and enable unit and feature testing.#469grahamsutton wants to merge 4 commits intoShopify:mainfrom
grahamsutton wants to merge 4 commits intoShopify:mainfrom
Conversation
…nable "web" auth guard to use custom ShopifyGuard implementation for authenticating sessions.
grahamsutton
commented
Sep 5, 2023
| $shopifySession = Utils::loadCurrentSession( | ||
| $request->header(), | ||
| $request->cookie(), | ||
| false |
Author
There was a problem hiding this comment.
This is the isOnline flag. Any suggestions on how to dynamically populate this are welcome.
Author
|
I have signed the CLA! |
darrynten
reviewed
Nov 5, 2023
| 'shopify' => [ | ||
| 'key' => env('SHOPIFY_API_KEY'), | ||
| 'secret' => env('SHOPIFY_API_SECRET'), | ||
| ] |
There was a problem hiding this comment.
I think it makes more sense for this to be in web/config/shopify.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WHY are these changes introduced?
Fixes #466
Please review the changes and suggest feedback. I am still pending resolving one issue with how to dynamically provide the
isOnlineflag when loading the current Shopify session from the Shopify PHP library. I wanted to submit this now to incorporate feedback sooner before I remove this from being WIP.Here's why I've decided to introduce these changes:
ShopifyGuard: Laravel provides many conveniences around when handling authentication through the framework, but the project in its current state bypasses Laravel's authentication (config/auth.phpis completely commented out). Not being able to leverage framework benefits hurts developer productivity, causes a lot of code redundancy, and makes testing a pain (if not impossible).testsdirectory despite having PHPUnit configured. Developers need to be able to write unit and feature tests. Developers should not have to resort to 100% manual testing. Enabling automated testing would decrease the number of bugs escaping into deployed Shopify apps and result in a better overall brand image.WHAT is this pull request doing?
ShopifyGuardto return the currently authenticated session.\App\Models\Sessionmodel extends\Illuminate\Foundation\Auth\Userand implements missinggetAuthIdentifierNameandgetAuthPasswordmethods.testsdirectory commonly found in fresh Laravel installations. Thetests/TestCase.phpclass contains an overriddenactingAsmethod that additionally injects a mock Authorization Bearer token. It also disables the Shopify middleware to allow requests in feature tests to reach the controller while still returning an authenticated\App\Models\Sessioninstance.config/services.php.Checklist
Note: once this PR is merged, it becomes a new release for this template.
README.mdfile and other related documentation, if applicable