diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..7b35d68 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false + +[*.{scss,css,ts,js,cjs,html,json,vue,yml,yaml}] +indent_size = 2 diff --git a/.gitattributes b/.gitattributes index b5c162d..66c3a8b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,6 +1,16 @@ +* text=auto + +*.blade.php diff=html +*.css diff=css +*.html diff=html +*.md diff=markdown +*.php diff=php + /.github export-ignore /.gitattributes export-ignore /.gitignore export-ignore /.styleci.yml export-ignore +/.editorconfig export-ignore +/CHANGELOG.md export-ignore /phpunit.xml.dist export-ignore /tests export-ignore diff --git a/CONTRIBUTING.md b/.github/CONTRIBUTING.md similarity index 54% rename from CONTRIBUTING.md rename to .github/CONTRIBUTING.md index 1ea49f8..2372ac0 100644 --- a/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -8,13 +8,19 @@ Please read and understand the contribution guide before creating an issue or pu If the project maintainer has any additional requirements, you will find them listed here. - -- **[PSR-2 Coding Standard.](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** The easiest way to apply the conventions is to install [PHP CS Fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer). +- **[PSR-2 Coding Standard.](https://www.php-fig.org/psr/psr-2/)** + - The easiest way to apply the conventions is to + install [PHP CS Fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer). - **Add tests!** Your patch won't be accepted if it doesn't have tests. -- **Document any change in behaviour.** Make sure the `README.md` and any other relevant documentation are kept up-to-date. -- **Consider our release cycle.** We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option. +- **Document any change in behaviour.** Make sure the `README.md` and any other relevant documentation are kept + up-to-date. +- **Consider our release cycle.** We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is + not an option. - **Create feature branches.** Don't ask us to pull from your master branch. - **One pull request per feature.** If you want to do more than one thing, send multiple pull requests. -- **Send coherent history.** Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting. +- **Send coherent history.** Make sure each individual commit in your pull request is meaningful. If you had to make + multiple intermediate commits while developing, + please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) + before submitting. **Happy coding!** diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e2a35fe..f8df75e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -17,7 +17,7 @@ jobs: strategy: fail-fast: false matrix: - php: [8.0, 8.1] + php: [8.1, 8.2] name: php v${{ matrix.php }} @@ -30,11 +30,11 @@ jobs: with: php-version: ${{ matrix.php }} extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv + ini-values: error_reporting=E_ALL coverage: pcov - name: Install dependencies - run: composer update --prefer-dist --no-interaction --no-progress + run: composer update --prefer-dist --no-interaction --no-progress - name: Execute tests - run: composer test -- --coverage-clover=coverage.xml - + run: composer test -- --coverage-clover=coverage.xml \ No newline at end of file diff --git a/.gitignore b/.gitignore index 708b377..50b321e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ vendor composer.lock -.phpunit.result.cache \ No newline at end of file +.phpunit.result.cache diff --git a/CHANGELOG.md b/CHANGELOG.md index 706d67d..e668055 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ # Changelog -All notable changes to `laravel-passport-social-grant` will be documented in this file: +All notable changes to this package will be documented in this file: + +## 3.1.0 + +* Drop php 8.0 support +* Test on php 8.2 and Laravel 10 ## 3.0.0 diff --git a/LICENSE.md b/LICENSE.md index be9ca0a..97791db 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2018 Ilya Sakovich +Copyright (c) 2023 Ilya Sakovich Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 72b88b4..2847c4a 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,8 @@ The package will automatically register itself. As the first step, you need to implement `SocialUserResolverInterface`: +Here is an example using [Socialite](https://laravel.com/docs/9.x/socialite) - + ```php userFromToken($accessToken); + + return $this->findOrCreateUser($provider, $providerUser);; + } + + protected function findOrCreateUser(string $provider, ProviderUser $providerUser): ?Authenticatable + { + // todo your logic here + // $email = $providerUser->getEmail(); } } ``` @@ -70,7 +77,7 @@ use Illuminate\Support\ServiceProvider; class AppServiceProvider extends ServiceProvider { /** - * All of the container bindings that should be registered. + * All the container bindings that should be registered. * * @var array */ @@ -113,7 +120,7 @@ axios.post('/oauth/token', { }); ``` -Example of usage with `guzzle`: +Example of usage with `guzzlehttp/guzzle`: ```php resolver = $resolver; $this->setRefreshTokenRepository($refreshTokenRepository); - $this->refreshTokenTTL = new \DateInterval('P1M'); + $this->refreshTokenTTL = new DateInterval('P1M'); } /** @@ -42,7 +35,7 @@ public function __construct( public function respondToAccessTokenRequest( ServerRequestInterface $request, ResponseTypeInterface $responseType, - \DateInterval $accessTokenTTL + DateInterval $accessTokenTTL ): ResponseTypeInterface { // Validate request $client = $this->validateClient($request); @@ -70,11 +63,7 @@ public function respondToAccessTokenRequest( /** * Validate server request and get the user entity. * - * @param ServerRequestInterface $request - * - * @throw OAuthServerException - * - * @return UserEntity + * @throws OAuthServerException */ public function validateUser(ServerRequestInterface $request): UserEntity { diff --git a/src/Providers/SocialGrantServiceProvider.php b/src/Providers/SocialGrantServiceProvider.php index f56f67a..2c7bc07 100644 --- a/src/Providers/SocialGrantServiceProvider.php +++ b/src/Providers/SocialGrantServiceProvider.php @@ -11,21 +11,6 @@ class SocialGrantServiceProvider extends ServiceProvider { - /** - * Bootstrap the application services. - * - * @return void - */ - public function boot(): void - { - // - } - - /** - * Register the application services. - * - * @return void - */ public function register(): void { $this->app->resolving(AuthorizationServer::class, function (AuthorizationServer $server) { @@ -36,11 +21,6 @@ public function register(): void }); } - /** - * Create and configure a Social grant instance. - * - * @return SocialGrant - */ protected function makeSocialGrant(): SocialGrant { $grant = new SocialGrant( @@ -52,4 +32,4 @@ protected function makeSocialGrant(): SocialGrant return $grant; } -} +} \ No newline at end of file diff --git a/src/Resolvers/SocialUserResolverInterface.php b/src/Resolvers/SocialUserResolverInterface.php index 522bd75..5664a50 100644 --- a/src/Resolvers/SocialUserResolverInterface.php +++ b/src/Resolvers/SocialUserResolverInterface.php @@ -8,11 +8,6 @@ interface SocialUserResolverInterface { /** * Resolve user by provider credentials. - * - * @param string $provider - * @param string $accessToken - * - * @return Authenticatable|null */ public function resolveUserByProviderCredentials(string $provider, string $accessToken): ?Authenticatable; }