diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 59e26240..d85577fa 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -43,6 +43,7 @@ body: label: SDK Version description: What version of our SDK are you using? (`composer show | grep auth0/login`) options: + - 7.13 - 7.12 - 7.11 - 7.10 @@ -68,7 +69,6 @@ body: options: - PHP 8.3 - PHP 8.2 - - PHP 8.1 - Other (specify below) validations: required: true diff --git a/.github/workflows/matrix.json b/.github/workflows/matrix.json index a38b5ef5..68634def 100644 --- a/.github/workflows/matrix.json +++ b/.github/workflows/matrix.json @@ -1,6 +1,6 @@ { "include": [ - { "php": "8.1" }, - { "php": "8.2" } + { "php": "8.2" }, + { "php": "8.3" } ] } diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d81f137c..3004afa4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -118,10 +118,10 @@ jobs: php: ${{ matrix.php }} coverage: pcov - - if: matrix.php == '8.1' + - if: matrix.php == '8.2' run: composer pest:coverage - - if: matrix.php == '8.1' + - if: matrix.php == '8.2' uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # pin@3.1.4 with: directory: ./coverage/ diff --git a/README.md b/README.md index 9a0bba98..7dfa40d1 100644 --- a/README.md +++ b/README.md @@ -11,30 +11,29 @@ **The Auth0 Laravel SDK is a PHP package that integrates [Auth0](https://auth0.com) into your Laravel application.** It includes no-code user authentication, extensive Management API support, permissions-based routing access control, and more. -- [Requirements](#requirements) -- [Getting Started](#getting-started) - - [1. Install the SDK](#1-install-the-sdk) - - [2. Install the CLI](#2-install-the-cli) - - [3. Configure the SDK](#3-configure-the-sdk) - - [4. Run the Application](#4-run-the-application) -- [Documentation](#documentation) -- [QuickStarts](#quickstarts) -- [Contributing](#contributing) -- [Code of Conduct](#code-of-conduct) -- [Security](#security) -- [License](#license) +- [Requirements](#requirements) +- [Getting Started](#getting-started) + - [1. Install the SDK](#1-install-the-sdk) + - [2. Install the CLI](#2-install-the-cli) + - [3. Configure the SDK](#3-configure-the-sdk) + - [4. Run the Application](#4-run-the-application) +- [Documentation](#documentation) +- [QuickStarts](#quickstarts) +- [Contributing](#contributing) +- [Code of Conduct](#code-of-conduct) +- [Security](#security) +- [License](#license) ## Requirements -Your application must use a [supported Laravel version](https://laravelversions.com/en), and your host environment must be running a [supported PHP version](https://www.php.net/supported-versions.php). Please review [our support policy](./docs/Support.md) for more information. +Your application must use the [latest supported Laravel version](https://endoflife.date/laravel), and your host environment must be running a [supported PHP version](https://www.php.net/supported-versions.php). Please review [our support policy](./docs/Support.md) for more information. -| SDK | Laravel | PHP | Supported Until | -| ---- | ---------------------------------------------- | ----------------------------------------------- | --------------- | -| 7.5+ | [10.x](https://laravel.com/docs/10.x/releases) | [8.3](https://www.php.net/releases/8.2/en.php) | Feb 2025 | -| | | [8.2](https://www.php.net/releases/8.1/en.php) | Feb 2025 | -| | | [8.1](https://www.php.net/releases/8.1/en.php) | Nov 2024 | -| 7.0+ | [9.x](https://laravel.com/docs/9.x/releases) | [8.2](https://www.php.net/releases/8.2/en.php) | Feb 2024 | -| | | [8.1](https://www.php.net/releases/8.1/en.php) | Feb 2024 | +| SDK | Laravel | PHP | Supported Until | +| ----- | ---------------------------------------------- | ---------------------------------------------- | --------------- | +| 7.13+ | [11.x](https://laravel.com/docs/11.x/releases) | [8.3](https://www.php.net/releases/8.3/en.php) | ~Sep 2025 | +| | | [8.2](https://www.php.net/releases/8.2/en.php) | ~Sep 2025 | + +Due to breaking changes in Laravel 11, SDK 7.12 was the last version to support Laravel 9 and 10. You will also need [Composer](https://getcomposer.org/) and an [Auth0 account](https://auth0.com/signup). @@ -44,16 +43,16 @@ The following is our recommended approach to getting started with the SDK. Alter ### 1. Install the SDK -- For **new applications**, we offer a quickstart template — a version of the default Laravel 9 starter project pre-configured for use with the Auth0 SDK. +- For **new applications**, we offer a quickstart template — a version of the default Laravel 9 starter project pre-configured for use with the Auth0 SDK. ```shell composer create-project auth0-samples/laravel auth0-laravel-app && cd auth0-laravel-app ``` -- For **existing applications**, you can install the SDK using Composer. +- For **existing applications**, you can install the SDK using Composer. ```shell - composer require auth0/login:^7.9 --update-with-all-dependencies + composer require auth0/login:^7 --update-with-all-dependencies ``` In this case, you will also need to generate an SDK configuration file for your application. @@ -170,11 +169,11 @@ php artisan serve Direct your browser to [http://localhost:8000](http://localhost:8000) to experiment with the application. -- **Authentication** - Users can log in or out of the application by visiting the [`/login`](http://localhost:8000/login) or [`/logout`](http://localhost:8000/logout) routes, respectively. +- **Authentication** + Users can log in or out of the application by visiting the [`/login`](http://localhost:8000/login) or [`/logout`](http://localhost:8000/logout) routes, respectively. -- **API Authorization** - For simplicity sake, generate a test token using the CLI. +- **API Authorization** + For simplicity sake, generate a test token using the CLI. ```shell auth0 test token \ @@ -182,9 +181,9 @@ Direct your browser to [http://localhost:8000](http://localhost:8000) to experim --scopes "read:messages" ``` -

Substitute %IDENTIFIER% with the identifier of the API you created in step 3 above.

+

Substitute %IDENTIFIER% with the identifier of the API you created in step 3 above.

- Now you can send requests to the `/api` endpoints of the application, including the token as a header. + Now you can send requests to the `/api` endpoints of the application, including the token as a header. ```shell curl --request GET \ @@ -193,18 +192,18 @@ Direct your browser to [http://localhost:8000](http://localhost:8000) to experim --header 'Authorization: Bearer %TOKEN%' ``` -

Substitute %TOKEN% with the test token returned in the previous step.

+

Substitute %TOKEN% with the test token returned in the previous step.

-
- Using Windows PowerShell -   +
+ Using Windows PowerShell +   ```powershell Invoke-WebRequest http://localhost:8000/api/example ` -Headers @{'Accept' = 'application/json'; 'Authorization' = 'Bearer %TOKEN%'} ``` -
+
When you're ready to deploy your application to production, review [our deployment guide](./docs/Deployment.md) for best practices and advice on securing Laravel. @@ -354,33 +353,33 @@ All the SDK's Management API methods are [documented here](./docs/Management.md) ## Documentation -- [Installation](./docs/Installation.md) — Installing the SDK and generating configuration files. -- [Configuration](./docs/Configuration.md) — Configuring the SDK using JSON files or environment variables. -- [Sessions](./docs/Sessions.md) — Guidance on deciding which Laravel Session API driver to use. -- [Cookies](./docs/Cookies.md) — Important notes about using Laravel's Cookie session driver, and alternative options. -- [Management API](./docs/Management.md) — Using the SDK to work with the [Auth0 Management API](https://auth0.com/docs/api/management/v2). -- [Users](./docs/Users.md) — Extending the SDK to support persistent storage and [Eloquent](https://laravel.com/docs/eloquent) models. -- [Events](./docs/Events.md) — Hooking into SDK [events](https://laravel.com/docs/events) to respond to specific actions. -- [Deployment](./docs/Deployment.md) — Deploying your application to production. +- [Installation](./docs/Installation.md) — Installing the SDK and generating configuration files. +- [Configuration](./docs/Configuration.md) — Configuring the SDK using JSON files or environment variables. +- [Sessions](./docs/Sessions.md) — Guidance on deciding which Laravel Session API driver to use. +- [Cookies](./docs/Cookies.md) — Important notes about using Laravel's Cookie session driver, and alternative options. +- [Management API](./docs/Management.md) — Using the SDK to work with the [Auth0 Management API](https://auth0.com/docs/api/management/v2). +- [Users](./docs/Users.md) — Extending the SDK to support persistent storage and [Eloquent](https://laravel.com/docs/eloquent) models. +- [Events](./docs/Events.md) — Hooking into SDK [events](https://laravel.com/docs/events) to respond to specific actions. +- [Deployment](./docs/Deployment.md) — Deploying your application to production. You may find the following integration guidance useful: -- [Laravel Eloquent](./docs/Eloquent.md) — [Eloquent ORM](https://laravel.com/docs/eloquent) is supported. -- [Laravel Octane](./docs/Octane.md) — [Octane](https://laravel.com/docs/octane) is not supported at this time. -- [Laravel Telescope](./docs/Telescope.md) — [Telescope](https://laravel.com/docs/telescope) is compatible as of SDK v7.11.0. +- [Laravel Eloquent](./docs/Eloquent.md) — [Eloquent ORM](https://laravel.com/docs/eloquent) is supported. +- [Laravel Octane](./docs/Octane.md) — [Octane](https://laravel.com/docs/octane) is not supported at this time. +- [Laravel Telescope](./docs/Telescope.md) — [Telescope](https://laravel.com/docs/telescope) is compatible as of SDK v7.11.0. You may also find the following resources helpful: -- [Auth0 Documentation Hub](https://www.auth0.com/docs) -- [Auth0 Management API Explorer](https://auth0.com/docs/api/management/v2) -- [Auth0 Authentication API Explorer](https://auth0.com/docs/api/authentication) +- [Auth0 Documentation Hub](https://www.auth0.com/docs) +- [Auth0 Management API Explorer](https://auth0.com/docs/api/management/v2) +- [Auth0 Authentication API Explorer](https://auth0.com/docs/api/authentication) Contributions to improve our documentation [are welcomed](https://github.com/auth0/laravel-auth0/pull). ## QuickStarts -- [Session-based Authentication](https://auth0.com/docs/quickstart/webapp/laravel) ([GitHub](https://github.com/auth0-samples/laravel)) -- [Token-based Authorization](https://auth0.com/docs/quickstart/backend/laravel) ([GitHub](https://github.com/auth0-samples/laravel)) +- [Session-based Authentication](https://auth0.com/docs/quickstart/webapp/laravel) ([GitHub](https://github.com/auth0-samples/laravel)) +- [Token-based Authorization](https://auth0.com/docs/quickstart/backend/laravel) ([GitHub](https://github.com/auth0-samples/laravel)) ## Community diff --git a/composer.json b/composer.json index 98a4f4d1..cba51bd6 100644 --- a/composer.json +++ b/composer.json @@ -34,31 +34,37 @@ "forum": "https://community.auth0.com", "source": "https://github.com/auth0/laravel-auth0" }, + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/asbiin/psalm-plugin-laravel.git" + } + ], "require": { - "php": "^8.1", + "php": "^8.2", "ext-json": "*", "auth0/auth0-php": "^8.10", - "illuminate/contracts": "^9 || ^10", - "illuminate/http": "^9 || ^10", - "illuminate/support": "^9 || ^10", + "illuminate/contracts": "^11", + "illuminate/http": "^11", + "illuminate/support": "^11", "psr-discovery/all": "^1", "psr/cache": "^2 || ^3" }, "require-dev": { "ergebnis/composer-normalize": "^2", "friendsofphp/php-cs-fixer": "^3", + "larastan/larastan": "^2", "mockery/mockery": "^1", - "nunomaduro/larastan": "^2", - "orchestra/testbench": "^7 || ^8", - "pestphp/pest": "^2", + "orchestra/testbench": "^9.x-dev", "pestphp/pest-plugin-laravel": "^2", - "phpstan/phpstan": "^1", + "pestphp/pest": "^2", "phpstan/phpstan-strict-rules": "^1", - "psalm/plugin-laravel": "^2", + "phpstan/phpstan": "^1", + "psalm/plugin-laravel": "dev-laravel11#b93c8f21c18e3355dcdae797c6af266f7aab93f6", "psr-mock/http": "^1", - "rector/rector": "0.17.0", + "rector/rector": "^1", "squizlabs/php_codesniffer": "^3", - "symfony/cache": "^6", + "symfony/cache": "^6 || ^7", "vimeo/psalm": "^5", "wikimedia/composer-merge-plugin": "^2" }, diff --git a/deprecated/Model/User.php b/deprecated/Model/User.php index fc56cdfc..6851a8bb 100644 --- a/deprecated/Model/User.php +++ b/deprecated/Model/User.php @@ -4,7 +4,7 @@ namespace Auth0\Laravel\Model; -use Auth0\Laravel\Users\{UserAbstract, UserContract}; +use Auth0\Laravel\Users\UserAbstract; /** * @deprecated 7.8.0 Use Auth0\Laravel\Users\UserAbstract instead. diff --git a/docs/Deployment.md b/docs/Deployment.md index 9dd6160a..66ebdaee 100644 --- a/docs/Deployment.md +++ b/docs/Deployment.md @@ -2,28 +2,28 @@ When you're preparing to deploy your application to production, there are some basic steps you can take to make sure your application is running as smoothly and securely as possible. In this guide, we'll cover some starting points for making sure your application is deployed properly. -- [Auth0 Configuration](#auth0-configuration) -- [TLS / HTTPS](#tls--https) -- [Cookies](#cookies) -- [Server Configuration](#server-configuration) - - [Caddy](#caddy) - - [Nginx](#nginx) - - [Apache](#apache) -- [Optimization](#optimization) - - [Autoloader](#autoloader) - - [Dependencies](#dependencies) - - [Caching Configuration](#caching-configuration) - - [Caching Events](#caching-events) - - [Caching Routes](#caching-routes) - - [Caching Views](#caching-views) - - [Debug Mode](#debug-mode) +- [Auth0 Configuration](#auth0-configuration) +- [TLS / HTTPS](#tls--https) +- [Cookies](#cookies) +- [Server Configuration](#server-configuration) + - [Caddy](#caddy) + - [Nginx](#nginx) + - [Apache](#apache) +- [Optimization](#optimization) + - [Autoloader](#autoloader) + - [Dependencies](#dependencies) + - [Caching Configuration](#caching-configuration) + - [Caching Events](#caching-events) + - [Caching Routes](#caching-routes) + - [Caching Views](#caching-views) + - [Debug Mode](#debug-mode) ## Auth0 Configuration When migrating your Laravel application from local development to production, you will need to update your Auth0 application's configuration to reflect the new URLs for your application. You can do this by logging into the [Auth0 Dashboard](https://manage.auth0.com/) and updating the following fields: -- **Allowed Callback URLs**: The URL that Auth0 will redirect to after the user authenticates. This should be set to the Internet-accessible URL of your application's `/callback` route. -- **Allowed Logout URLs**: The URL that Auth0 will redirect to after the user logs out. This should be set to an appropriate Internet-accessible URL of your application. +- **Allowed Callback URLs**: The URL that Auth0 will redirect to after the user authenticates. This should be set to the Internet-accessible URL of your application's `/callback` route. +- **Allowed Logout URLs**: The URL that Auth0 will redirect to after the user logs out. This should be set to an appropriate Internet-accessible URL of your application. Note that you can include multiple URLs in these fields by separating them with commas, for example `https://example.com/callback,http://localhost:8000/callback`. @@ -64,7 +64,7 @@ example.com { X-Frame-Options "SAMEORIGIN" } - php_fastcgi unix//var/run/php/php8.1-fpm.sock + php_fastcgi unix//var/run/php/php8.2-fpm.sock } ``` @@ -76,32 +76,32 @@ server { listen [::]:80; server_name example.com; root /var/www/example.com/public; - + add_header X-XSS-Protection "1; mode=block"; add_header X-Content-Type-Options "nosniff"; add_header X-Frame-Options "SAMEORIGIN"; large_client_header_buffers 4 32k; - + index index.php; - + charset utf-8; - + location / { try_files $uri $uri/ /index.php?$query_string; } - + location = /favicon.ico { access_log off; log_not_found off; } location = /robots.txt { access_log off; log_not_found off; } - + error_page 404 /index.php; - + location ~ \.php$ { - fastcgi_pass unix:/var/run/php/php8.1-fpm.sock; + fastcgi_pass unix:/var/run/php/php8.2-fpm.sock; fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; include fastcgi_params; } - + location ~ /\.(?!well-known).* { deny all; } diff --git a/docs/Installation.md b/docs/Installation.md index 4cabac86..7b537ed9 100644 --- a/docs/Installation.md +++ b/docs/Installation.md @@ -1,28 +1,27 @@ # Installation -- [Prerequisites](#prerequisites) -- [Install the SDK](#install-the-sdk) - - [Using Quickstart (Recommended)](#using-quickstart-recommended) - - [Installation with Composer](#installation-with-composer) - - [Create a Laravel Application](#create-a-laravel-application) - - [Install the SDK](#install-the-sdk-1) -- [Install the CLI](#install-the-cli) - - [Authenticate the CLI](#authenticate-the-cli) -- [Configure the SDK](#configure-the-sdk) - - [Using JSON (Recommended)](#using-json-recommended) - - [Using Environment Variables](#using-environment-variables) +- [Prerequisites](#prerequisites) +- [Install the SDK](#install-the-sdk) + - [Using Quickstart (Recommended)](#using-quickstart-recommended) + - [Installation with Composer](#installation-with-composer) + - [Create a Laravel Application](#create-a-laravel-application) + - [Install the SDK](#install-the-sdk-1) +- [Install the CLI](#install-the-cli) + - [Authenticate the CLI](#authenticate-the-cli) +- [Configure the SDK](#configure-the-sdk) + - [Using JSON (Recommended)](#using-json-recommended) + - [Using Environment Variables](#using-environment-variables) ## Prerequisites -To integrate our SDK, your application must use a [supported Laravel version](https://laravelversions.com/en), and your environment must run a [supported PHP version](https://www.php.net/supported-versions.php). We do not support versions of either that are no longer supported by their maintainers. Please review [our support policy](./Support.md) for more information. +Your application must use the [latest supported Laravel version](https://endoflife.date/laravel), and your host environment must be running a [supported PHP version](https://www.php.net/supported-versions.php). Please review [our support policy](./docs/Support.md) for more information. -| SDK | Laravel | PHP | Supported Until | -| ---- | ------- | --- | --------------- | -| 7.5+ | 10 | 8.3 | Feb 2025 | -| | | 8.2 | Feb 2025 | -| | | 8.1 | Nov 2024 | -| 7.0+ | 9 | 8.2 | Feb 2024 | -| | | 8.1 | Feb 2024 | +| SDK | Laravel | PHP | Supported Until | +| ----- | ---------------------------------------------- | ---------------------------------------------- | --------------- | +| 7.13+ | [11.x](https://laravel.com/docs/11.x/releases) | [8.3](https://www.php.net/releases/8.3/en.php) | ~Sep 2025 | +| | | [8.2](https://www.php.net/releases/8.2/en.php) | ~Sep 2025 | + +Due to breaking changes in Laravel 11, SDK 7.12 was the last version to support Laravel 9 and 10. You will also need [Composer 2.0+](https://getcomposer.org/) and an [Auth0 account](https://auth0.com/signup). @@ -32,7 +31,7 @@ Ensure that your development environment has [supported versions](#prerequisites ### Using Quickstart (Recommended) -- Create a new Laravel 9 project pre-configured with the SDK: +- Create a new Laravel 9 project pre-configured with the SDK: ```shell composer create-project auth0-samples/laravel auth0-laravel-app @@ -42,7 +41,7 @@ Ensure that your development environment has [supported versions](#prerequisites #### Create a Laravel Application -- If you do not already have one, you can Create a new Laravel 9 application with the following command: +- If you do not already have one, you can Create a new Laravel 9 application with the following command: ```shell composer create-project laravel/laravel:^9.0 auth0-laravel-app @@ -66,20 +65,20 @@ Ensure that your development environment has [supported versions](#prerequisites Install the [Auth0 CLI](https://github.com/auth0/auth0-cli) to create and manage Auth0 resources from the command line. -- macOS with [Homebrew](https://brew.sh/): +- macOS with [Homebrew](https://brew.sh/): ```shell brew tap auth0/auth0-cli && brew install auth0 ``` -- Linux or macOS: +- Linux or macOS: ```shell curl -sSfL https://raw.githubusercontent.com/auth0/auth0-cli/main/install.sh | sh -s -- -b . sudo mv ./auth0 /usr/local/bin ``` -- Windows with [Scoop](https://scoop.sh/): +- Windows with [Scoop](https://scoop.sh/): ```cmd scoop bucket add auth0 https://github.com/auth0/scoop-auth0-cli.git @@ -88,7 +87,7 @@ Install the [Auth0 CLI](https://github.com/auth0/auth0-cli) to create and manage ### Authenticate the CLI -- Authenticate the CLI with your Auth0 account. Choose "as a user," and follow the prompts. +- Authenticate the CLI with your Auth0 account. Choose "as a user," and follow the prompts. ```shell auth0 login diff --git a/docs/Support.md b/docs/Support.md index 92a3607d..97352be1 100644 --- a/docs/Support.md +++ b/docs/Support.md @@ -1,14 +1,13 @@ # Support -To integrate our SDK, your application must use a [supported Laravel version](https://laravelversions.com/en), and your environment must run a [supported PHP version](https://www.php.net/supported-versions.php). We do not support versions of either that are no longer supported by their maintainers. +To integrate our SDK, your application must use the [latest supported Laravel version](https://endoflife.date/laravel), and your environment must run a [supported PHP version](https://www.php.net/supported-versions.php). We do not support versions of either that are no longer supported by their maintainers. -| SDK | Laravel | PHP | Supported Until | -| ---- | ------- | ---- | --------------- | -| 7.5+ | 10 | 8.2+ | Feb 2025 | -| | | 8.1+ | Nov 2024 | -| 7.0+ | 9 | 8.2+ | Feb 2024 | -| | | 8.1+ | Feb 2024 | -| | | 8.0+ | Nov 2023 | +| SDK | Laravel | PHP | Supported Until | +| ----- | ---------------------------------------------- | ---------------------------------------------- | --------------- | +| 7.13+ | [11.x](https://laravel.com/docs/11.x/releases) | [8.3](https://www.php.net/releases/8.3/en.php) | ~Sep 2025 | +| | | [8.2](https://www.php.net/releases/8.2/en.php) | ~Sep 2025 | + +Due to breaking changes in Laravel 11, SDK 7.12 was the last version to support Laravel 9 and 10. You will also need [Composer 2.0+](https://getcomposer.org/) and an [Auth0 account](https://auth0.com/signup). @@ -18,7 +17,7 @@ The SDK follows the [Laravel support policy](https://laravel.com/docs/master/rel ## Getting Support -- If you believe you've found a bug, please [create an issue on GitHub](https://github.com/auth0/laravel-auth0). -- For questions and community support, please [join the Auth0 Community](https://community.auth0.com/). -- For paid support plans, please [contact us directly](https://auth0.com/contact-us). -- For more information about Auth0 Support, please visit our [Support Center](https://support.auth0.com/). +- If you believe you've found a bug, please [create an issue on GitHub](https://github.com/auth0/laravel-auth0). +- For questions and community support, please [join the Auth0 Community](https://community.auth0.com/). +- For paid support plans, please [contact us directly](https://auth0.com/contact-us). +- For more information about Auth0 Support, please visit our [Support Center](https://support.auth0.com/). diff --git a/phpstan.neon.dist b/phpstan.neon.dist index e12af232..4b604cc9 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,6 +1,6 @@ includes: - ./vendor/phpstan/phpstan-strict-rules/rules.neon - - ./vendor/nunomaduro/larastan/extension.neon + - ./vendor/larastan/larastan/extension.neon parameters: level: max diff --git a/rector.php b/rector.php index 7c84d382..0ce41546 100644 --- a/rector.php +++ b/rector.php @@ -96,7 +96,6 @@ use Rector\CodingStyle\Rector\Plus\UseIncrementAssignRector; use Rector\CodingStyle\Rector\PostInc\PostIncDecToPreIncDecRector; use Rector\CodingStyle\Rector\Property\{AddFalseDefaultToBoolPropertyRector, SplitGroupedPropertiesRector}; -use Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector; use Rector\CodingStyle\Rector\String_\{SymplifyQuoteEscapeRector, UseClassKeywordForClassNameResolutionRector}; use Rector\CodingStyle\Rector\Switch_\BinarySwitchToIfElseRector; use Rector\CodingStyle\Rector\Ternary\TernaryConditionVariableAssignmentRector; @@ -107,18 +106,14 @@ RemoveUnusedVariableAssignRector}; use Rector\DeadCode\Rector\BinaryOp\RemoveDuplicatedInstanceOfRector; use Rector\DeadCode\Rector\BooleanAnd\RemoveAndTrueRector; -use Rector\DeadCode\Rector\Cast\RecastingRemovalRector; use Rector\DeadCode\Rector\ClassConst\RemoveUnusedPrivateClassConstantRector; use Rector\DeadCode\Rector\ClassMethod\{RemoveDelegatingParentCallRector, RemoveEmptyClassMethodRector, RemoveLastReturnRector, RemoveUnusedConstructorParamRector, RemoveUnusedPrivateMethodParameterRector, - RemoveUnusedPrivateMethodRector, RemoveUnusedPromotedPropertyRector, - RemoveUselessParamTagRector, RemoveUselessReturnTagRector}; -use Rector\DeadCode\Rector\Concat\RemoveConcatAutocastRector; use Rector\DeadCode\Rector\Expression\{RemoveDeadStmtRector, SimplifyMirrorAssignRector}; use Rector\DeadCode\Rector\For_\{RemoveDeadContinueRector, @@ -127,8 +122,7 @@ use Rector\DeadCode\Rector\Foreach_\RemoveUnusedForeachKeyRector; use Rector\DeadCode\Rector\FunctionLike\{RemoveDeadReturnRector, RemoveDuplicatedIfReturnRector}; -use Rector\DeadCode\Rector\If_\{RemoveAlwaysTrueIfConditionRector, - RemoveDeadInstanceOfRector, +use Rector\DeadCode\Rector\If_\{ RemoveUnusedNonEmptyArrayBeforeForeachRector, SimplifyIfElseWithSameContentRector, UnwrapFutureCompatibleIfPhpVersionRector}; @@ -148,24 +142,19 @@ use Rector\DeadCode\Rector\TryCatch\RemoveDeadTryCatchRector; use Rector\DependencyInjection\Rector\Class_\ActionInjectionToConstructorInjectionRector; use Rector\EarlyReturn\Rector\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector; -use Rector\EarlyReturn\Rector\If_\{ChangeAndIfToEarlyReturnRector, +use Rector\EarlyReturn\Rector\If_\{ ChangeIfElseValueAssignToEarlyReturnRector, ChangeNestedIfsToEarlyReturnRector, ChangeOrIfContinueToMultiContinueRector, - ChangeOrIfReturnToEarlyReturnRector, RemoveAlwaysElseRector}; -use Rector\EarlyReturn\Rector\Return_\{PreparedValueToEarlyReturnRector, +use Rector\EarlyReturn\Rector\Return_\{ ReturnBinaryAndToEarlyReturnRector, ReturnBinaryOrToEarlyReturnRector}; use Rector\EarlyReturn\Rector\StmtsAwareInterface\ReturnEarlyIfVariableRector; -use Rector\Naming\Rector\Assign\RenameVariableToMatchMethodCallReturnTypeRector; -use Rector\Naming\Rector\Class_\RenamePropertyToMatchTypeRector; -use Rector\Naming\Rector\ClassMethod\{RenameParamToMatchTypeRector, - RenameVariableToMatchNewTypeRector}; + use Rector\Naming\Rector\Foreach_\{RenameForeachValueVariableToMatchExprVariableRector, RenameForeachValueVariableToMatchMethodCallReturnTypeRector}; use Rector\Php52\Rector\Property\VarToPublicPropertyRector; -use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector; use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector; use Rector\Php80\Rector\Catch_\RemoveUnusedVariableInCatchRector; use Rector\Php80\Rector\Class_\{ClassPropertyAssignToConstructorPromotionRector, @@ -177,8 +166,7 @@ use Rector\Php80\Rector\FuncCall\{ClassOnObjectRector, Php8ResourceReturnToObjectRector, TokenGetAllToObjectRector}; -use Rector\Php80\Rector\FunctionLike\{MixedTypeRector, - UnionTypesRector}; + use Rector\Php80\Rector\Identical\{StrEndsWithRector, StrStartsWithRector}; use Rector\Php80\Rector\NotIdentical\StrContainsRector; @@ -189,7 +177,6 @@ ChangeReadOnlyVariableWithDefaultValueToConstantRector, FinalizeClassesWithoutChildrenRector}; use Rector\Privatization\Rector\ClassMethod\PrivatizeFinalClassMethodRector; -use Rector\Privatization\Rector\MethodCall\PrivatizeLocalGetterToPropertyRector; use Rector\Privatization\Rector\Property\{ChangeReadOnlyPropertyWithDefaultValueToConstantRector, PrivatizeFinalClassPropertyRector}; use Rector\PSR4\Rector\FileWithoutNamespace\NormalizeNamespaceByPSR4ComposerAutoloadRector; @@ -203,7 +190,6 @@ ReturnTypeFromStrictTernaryRector}; use Rector\TypeDeclaration\Rector\ClassMethod\{AddMethodCallBasedStrictParamTypeRector, AddParamTypeBasedOnPHPUnitDataProviderRector, - AddParamTypeFromPropertyTypeRector, AddReturnTypeDeclarationBasedOnParentClassMethodRector, AddVoidReturnTypeWhereNoReturnRector, ArrayShapeFromConstantArrayReturnRector, @@ -240,27 +226,27 @@ $rectorConfig->ruleWithConfiguration( RenameFunctionRector::class, [ - 'chop' => 'rtrim', - 'doubleval' => 'floatval', - 'fputs' => 'fwrite', - 'gzputs' => 'gzwrites', - 'ini_alter' => 'ini_set', - 'is_double' => 'is_float', - 'is_integer' => 'is_int', - 'is_long' => 'is_int', - 'is_real' => 'is_float', + 'chop' => 'rtrim', + 'doubleval' => 'floatval', + 'fputs' => 'fwrite', + 'gzputs' => 'gzwrites', + 'ini_alter' => 'ini_set', + 'is_double' => 'is_float', + 'is_integer' => 'is_int', + 'is_long' => 'is_int', + 'is_real' => 'is_float', 'is_writeable' => 'is_writable', - 'join' => 'implode', - 'key_exists' => 'array_key_exists', - 'mbstrcut' => 'mb_strcut', - 'mbstrlen' => 'mb_strlen', - 'mbstrpos' => 'mb_strpos', - 'mbstrrpos' => 'mb_strrpos', - 'mbsubstr' => 'mb_substr', - 'pos' => 'current', - 'sizeof' => 'count', - 'split' => 'explode', - 'strchr' => 'strstr', + 'join' => 'implode', + 'key_exists' => 'array_key_exists', + 'mbstrcut' => 'mb_strcut', + 'mbstrlen' => 'mb_strlen', + 'mbstrpos' => 'mb_strpos', + 'mbstrrpos' => 'mb_strrpos', + 'mbsubstr' => 'mb_substr', + 'pos' => 'current', + 'sizeof' => 'count', + 'split' => 'explode', + 'strchr' => 'strstr', ], ); @@ -281,30 +267,30 @@ $rectorConfig->ruleWithConfiguration( RenameFunctionRector::class, [ - 'pg_clientencoding' => 'pg_client_encoding', - 'pg_cmdtuples' => 'pg_affected_rows', - 'pg_errormessage' => 'pg_last_error', - 'pg_fieldisnull' => 'pg_field_is_null', - 'pg_fieldname' => 'pg_field_name', - 'pg_fieldnum' => 'pg_field_num', - 'pg_fieldprtlen' => 'pg_field_prtlen', - 'pg_fieldsize' => 'pg_field_size', - 'pg_fieldtype' => 'pg_field_type', - 'pg_freeresult' => 'pg_free_result', - 'pg_getlastoid' => 'pg_last_oid', - 'pg_loclose' => 'pg_lo_close', - 'pg_locreate' => 'pg_lo_create', - 'pg_loexport' => 'pg_lo_export', - 'pg_loimport' => 'pg_lo_import', - 'pg_loopen' => 'pg_lo_open', - 'pg_loread' => 'pg_lo_read', - 'pg_loreadall' => 'pg_lo_read_all', - 'pg_lounlink' => 'pg_lo_unlink', - 'pg_lowrite' => 'pg_lo_write', - 'pg_numfields' => 'pg_num_fields', - 'pg_numrows' => 'pg_num_rows', - 'pg_result' => 'pg_fetch_result', - 'pg_setclientencoding' => 'pg_set_client_encoding' + 'pg_clientencoding' => 'pg_client_encoding', + 'pg_cmdtuples' => 'pg_affected_rows', + 'pg_errormessage' => 'pg_last_error', + 'pg_fieldisnull' => 'pg_field_is_null', + 'pg_fieldname' => 'pg_field_name', + 'pg_fieldnum' => 'pg_field_num', + 'pg_fieldprtlen' => 'pg_field_prtlen', + 'pg_fieldsize' => 'pg_field_size', + 'pg_fieldtype' => 'pg_field_type', + 'pg_freeresult' => 'pg_free_result', + 'pg_getlastoid' => 'pg_last_oid', + 'pg_loclose' => 'pg_lo_close', + 'pg_locreate' => 'pg_lo_create', + 'pg_loexport' => 'pg_lo_export', + 'pg_loimport' => 'pg_lo_import', + 'pg_loopen' => 'pg_lo_open', + 'pg_loread' => 'pg_lo_read', + 'pg_loreadall' => 'pg_lo_read_all', + 'pg_lounlink' => 'pg_lo_unlink', + 'pg_lowrite' => 'pg_lo_write', + 'pg_numfields' => 'pg_num_fields', + 'pg_numrows' => 'pg_num_rows', + 'pg_result' => 'pg_fetch_result', + 'pg_setclientencoding' => 'pg_set_client_encoding', ], ); @@ -319,7 +305,7 @@ new ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'l', 'lt'), new ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'gte', 'ge'), new ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'lte', 'le'), - new ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'n', 'ne') + new ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'n', 'ne'), ], ); @@ -327,16 +313,16 @@ FuncCallToConstFetchRector::class, [ 'php_sapi_name' => 'PHP_SAPI', - 'pi' => 'M_PI' + 'pi' => 'M_PI', ], ); $rectorConfig->rules([ AbsolutizeRequireAndIncludePathRector::class, // ActionInjectionToConstructorInjectionRector::class, - AddArrayDefaultToArrayPropertyRector::class, + // AddArrayDefaultToArrayPropertyRector::class, AddArrowFunctionReturnTypeRector::class, - AddClosureReturnTypeRector::class, + // AddClosureReturnTypeRector::class, // AddFalseDefaultToBoolPropertyRector::class, AddMethodCallBasedStrictParamTypeRector::class, AddParamBasedOnParentClassMethodRector::class, @@ -351,7 +337,7 @@ // ArrayKeysAndInArrayToArrayKeyExistsRector::class, ArrayMergeOfNonArraysToSimpleArrayRector::class, // ArrayShapeFromConstantArrayReturnRector::class, - BinarySwitchToIfElseRector::class, + // BinarySwitchToIfElseRector::class, BooleanNotIdenticalToNotIdenticalRector::class, BoolvalToTypeCastRector::class, CallableThisArrayToAnonymousFunctionRector::class, @@ -384,7 +370,7 @@ EncapsedStringsToSprintfRector::class, ExplicitBoolCompareRector::class, // ExplicitMethodCallOverMagicGetSetRector::class, - FinalizeClassesWithoutChildrenRector::class, + // FinalizeClassesWithoutChildrenRector::class, FinalPrivateToPrivateVisibilityRector::class, FlipTypeControlToUseExclusiveTypeRector::class, FloatvalToTypeCastRector::class, @@ -415,7 +401,7 @@ // ParamAnnotationIncorrectNullableRector::class, ParamTypeByMethodCallTypeRector::class, ParamTypeByParentCallTypeRector::class, - ParamTypeFromStrictTypedPropertyRector::class, + // ParamTypeFromStrictTypedPropertyRector::class, // Php8ResourceReturnToObjectRector::class, PostIncDecToPreIncDecRector::class, PrivatizeFinalClassMethodRector::class, @@ -444,7 +430,7 @@ // RemoveEmptyTestMethodRector::class, RemoveExtraParametersRector::class, RemoveFinalFromConstRector::class, - RemoveJustPropertyFetchForAssignRector::class, + // RemoveJustPropertyFetchForAssignRector::class, // RemoveJustVariableAssignRector::class, // RemoveLastReturnRector::class, // RemoveNonExistingVarAnnotationRector::class, @@ -466,7 +452,7 @@ RenameForeachValueVariableToMatchExprVariableRector::class, RenameForeachValueVariableToMatchMethodCallReturnTypeRector::class, ReplaceMultipleBooleanNotRector::class, - ReturnAnnotationIncorrectNullableRector::class, + // ReturnAnnotationIncorrectNullableRector::class, // ReturnBinaryAndToEarlyReturnRector::class, ReturnBinaryOrToEarlyReturnRector::class, ReturnEarlyIfVariableRector::class, @@ -477,7 +463,7 @@ ReturnTypeFromStrictConstantReturnRector::class, ReturnTypeFromStrictNativeCallRector::class, ReturnTypeFromStrictNewArrayRector::class, - ReturnTypeFromStrictScalarReturnExprRector::class, + // ReturnTypeFromStrictScalarReturnExprRector::class, ReturnTypeFromStrictTernaryRector::class, ReturnTypeFromStrictTypedCallRector::class, ReturnTypeFromStrictTypedPropertyRector::class, @@ -532,10 +518,10 @@ // TokenGetAllToObjectRector::class, TypedPropertyFromAssignsRector::class, TypedPropertyFromStrictConstructorRector::class, - TypedPropertyFromStrictGetterMethodReturnTypeRector::class, + // TypedPropertyFromStrictGetterMethodReturnTypeRector::class, TypedPropertyFromStrictSetUpRector::class, UnnecessaryTernaryExpressionRector::class, - UnSpreadOperatorRector::class, + // UnSpreadOperatorRector::class, UnusedForeachValueToArrayKeysRector::class, UnwrapFutureCompatibleIfPhpVersionRector::class, UnwrapSprintfOneArgumentRector::class, diff --git a/src/Auth/Guard.php b/src/Auth/Guard.php index 0c8c0008..8469ee1d 100644 --- a/src/Auth/Guard.php +++ b/src/Auth/Guard.php @@ -171,10 +171,10 @@ public function setImpersonating( public function setUser( Authenticatable $user, - ): void { + ): self { if ($this->isImpersonating()) { if ($this->getImposter()?->getUser() === $user) { - return; + return $this; } $this->stopImpersonating(); @@ -189,6 +189,8 @@ public function setUser( if (null === $source || self::SOURCE_SESSION === $source) { $this->getAuthenticationGuard()->setUser($user); } + + return $this; } public function user(): ?Authenticatable diff --git a/src/Entities/InstanceEntityTrait.php b/src/Entities/InstanceEntityTrait.php index 43faa890..3c4de02a 100644 --- a/src/Entities/InstanceEntityTrait.php +++ b/src/Entities/InstanceEntityTrait.php @@ -36,7 +36,7 @@ public function setConfiguration( $this->configuration = $configuration; - if ($this->configuration instanceof \Auth0\SDK\Configuration\SdkConfiguration && $this->sdk instanceof Auth0Interface) { + if ($this->configuration instanceof SdkConfiguration && $this->sdk instanceof Auth0Interface) { $this->sdk->setConfiguration($this->configuration); } diff --git a/src/Guards/AuthenticationGuard.php b/src/Guards/AuthenticationGuard.php index 559e0c70..dc362f75 100644 --- a/src/Guards/AuthenticationGuard.php +++ b/src/Guards/AuthenticationGuard.php @@ -253,10 +253,10 @@ public function setImpersonating( public function setUser( Authenticatable $user, - ): void { + ): self { if ($this->isImpersonating()) { if ($this->getImposter()?->getUser() === $user) { - return; + return $this; } $this->stopImpersonating(); @@ -267,6 +267,8 @@ public function setUser( $this->setCredential($credential); $this->pushState($credential); + + return $this; } public function user(): ?Authenticatable diff --git a/src/Guards/AuthorizationGuard.php b/src/Guards/AuthorizationGuard.php index 55d43f98..0172038c 100644 --- a/src/Guards/AuthorizationGuard.php +++ b/src/Guards/AuthorizationGuard.php @@ -190,10 +190,10 @@ public function setImpersonating( public function setUser( Authenticatable $user, - ): void { + ): self { if ($this->isImpersonating()) { if ($this->getImposter()?->getUser() === $user) { - return; + return $this; } $this->stopImpersonating(); @@ -203,6 +203,8 @@ public function setUser( $credential->setUser($user); $this->setCredential($credential); + + return $this; } public function user(): ?Authenticatable diff --git a/src/Guards/GuardAbstract.php b/src/Guards/GuardAbstract.php index 096373f8..f5cf935b 100644 --- a/src/Guards/GuardAbstract.php +++ b/src/Guards/GuardAbstract.php @@ -299,7 +299,7 @@ abstract public function setImpersonating( abstract public function setUser( Authenticatable $user, - ): void; + ): self; abstract public function user(): ?Authenticatable; diff --git a/src/Guards/GuardContract.php b/src/Guards/GuardContract.php index 6b44fcf2..26030567 100644 --- a/src/Guards/GuardContract.php +++ b/src/Guards/GuardContract.php @@ -190,7 +190,7 @@ public function setImpersonating( */ public function setUser( Authenticatable $user, - ): void; + ): self; /** * Stop impersonating a user. diff --git a/src/Middleware/AuthenticateMiddlewareAbstract.php b/src/Middleware/AuthenticateMiddlewareAbstract.php index 555efc76..de1b64b7 100644 --- a/src/Middleware/AuthenticateMiddlewareAbstract.php +++ b/src/Middleware/AuthenticateMiddlewareAbstract.php @@ -7,7 +7,7 @@ use Auth0\Laravel\Entities\CredentialEntityContract; use Auth0\Laravel\Events; use Auth0\Laravel\Events\Middleware\StatefulMiddlewareRequest; -use Auth0\Laravel\Guards\{AuthenticationGuardContract, GuardContract}; +use Auth0\Laravel\Guards\GuardContract; use Closure; use Illuminate\Http\Request; use Symfony\Component\HttpFoundation\Response; diff --git a/src/Middleware/AuthenticateOptionalMiddlewareAbstract.php b/src/Middleware/AuthenticateOptionalMiddlewareAbstract.php index 15585cfd..7dd6345d 100644 --- a/src/Middleware/AuthenticateOptionalMiddlewareAbstract.php +++ b/src/Middleware/AuthenticateOptionalMiddlewareAbstract.php @@ -7,7 +7,7 @@ use Auth0\Laravel\Entities\CredentialEntityContract; use Auth0\Laravel\Events; use Auth0\Laravel\Events\Middleware\StatefulMiddlewareRequest; -use Auth0\Laravel\Guards\{AuthenticationGuardContract, GuardContract}; +use Auth0\Laravel\Guards\GuardContract; use Closure; use Illuminate\Http\Request; use Symfony\Component\HttpFoundation\Response; diff --git a/src/Middleware/AuthorizeMiddlewareAbstract.php b/src/Middleware/AuthorizeMiddlewareAbstract.php index c23b6d4d..2e8aec9b 100644 --- a/src/Middleware/AuthorizeMiddlewareAbstract.php +++ b/src/Middleware/AuthorizeMiddlewareAbstract.php @@ -7,7 +7,7 @@ use Auth0\Laravel\Entities\CredentialEntityContract; use Auth0\Laravel\Events; use Auth0\Laravel\Events\Middleware\StatelessMiddlewareRequest; -use Auth0\Laravel\Guards\{AuthorizationGuardContract, GuardContract}; +use Auth0\Laravel\Guards\GuardContract; use Closure; use Illuminate\Http\Request; use Symfony\Component\HttpFoundation\Response; diff --git a/src/Middleware/AuthorizeOptionalMiddlewareAbstract.php b/src/Middleware/AuthorizeOptionalMiddlewareAbstract.php index 091d270b..cca15c4e 100644 --- a/src/Middleware/AuthorizeOptionalMiddlewareAbstract.php +++ b/src/Middleware/AuthorizeOptionalMiddlewareAbstract.php @@ -7,7 +7,7 @@ use Auth0\Laravel\Entities\CredentialEntityContract; use Auth0\Laravel\Events; use Auth0\Laravel\Events\Middleware\StatelessMiddlewareRequest; -use Auth0\Laravel\Guards\{AuthenticationGuardContract, GuardContract}; +use Auth0\Laravel\Guards\GuardContract; use Closure; use Illuminate\Http\Request; use Symfony\Component\HttpFoundation\Response; diff --git a/src/UserProviderAbstract.php b/src/UserProviderAbstract.php index c2fd21be..5dcbb97d 100644 --- a/src/UserProviderAbstract.php +++ b/src/UserProviderAbstract.php @@ -4,9 +4,7 @@ namespace Auth0\Laravel; -use Auth0\Laravel\Events\{TokenVerificationAttempting, TokenVerificationFailed, TokenVerificationSucceeded}; -use Auth0\Laravel\Guards\{AuthorizationGuardContract, GuardContract}; -use Auth0\Laravel\{UserRepository, UserRepositoryContract}; +use Auth0\Laravel\Guards\GuardContract; use Illuminate\Contracts\Auth\Authenticatable; use Illuminate\Contracts\Container\BindingResolutionException; use Illuminate\Support\Facades\Cache; @@ -39,6 +37,18 @@ final public function getRepository(): UserRepositoryContract return $this->repository ?? $this->resolveRepository(); } + /** + * @phpcsSuppress SlevomatCodingStandard.Functions.UnusedParameter + * + * @param Authenticatable $user + * @param array $credentials + * @param bool $force + */ + final public function rehashPasswordIfRequired(Authenticatable $user, array $credentials, bool $force = false): void + { + + } + /** * @phpcsSuppress SlevomatCodingStandard.Functions.UnusedParameter * diff --git a/src/Users/UserAbstract.php b/src/Users/UserAbstract.php index d07055b8..eb593f25 100644 --- a/src/Users/UserAbstract.php +++ b/src/Users/UserAbstract.php @@ -50,6 +50,11 @@ final public function getAuthPassword(): string return ''; } + final public function getAuthPasswordName(): string + { + return 'password'; + } + final public function getRememberToken(): string { return '';