Please review the changes and suggest feedback. I am still pending resolving one issue with how to dynamically provide the isOnline flag 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:
Upgrading from Laravel 8 to Laravel 10: Laravel 8 has reached end of life https://laravel.com/docs/10.x/releases#support-policy. Upgrading the framework to Laravel 10 makes sure we're using a secure and reliable version of Laravel.
Custom auth guard 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.php is 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).
Enable testing: Currently the project has no tests directory 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?
Creates a custom auth guard called ShopifyGuard to return the currently authenticated session.
\App\Models\Session model extends \Illuminate\Foundation\Auth\User and implements missing getAuthIdentifierName and getAuthPassword methods.
Recreates the tests directory commonly found in fresh Laravel installations. The tests/TestCase.php class contains an overridden actingAs method 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\Session instance.
Adds Shopify API key and secret to config/services.php.
Upgrades from Laravel 8 to the latest version of Laravel 10.
Checklist
Note: once this PR is merged, it becomes a new release for this template.
[ ] I have added/updated tests for this change
[ ] I have made changes to the README.md file and other related documentation, if applicable
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
isOnline
flag 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.php
is 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).tests
directory 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?
ShopifyGuard
to return the currently authenticated session.\App\Models\Session
model extends\Illuminate\Foundation\Auth\User
and implements missinggetAuthIdentifierName
andgetAuthPassword
methods.tests
directory commonly found in fresh Laravel installations. Thetests/TestCase.php
class contains an overriddenactingAs
method 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\Session
instance.config/services.php
.Checklist
Note: once this PR is merged, it becomes a new release for this template.
README.md
file and other related documentation, if applicable