From dfc6a22438c9222e827a8233a8eaaa80ac610fa0 Mon Sep 17 00:00:00 2001 From: Bartosz Juraszewski Date: Mon, 13 Sep 2021 16:44:22 +0200 Subject: [PATCH] WIP JWT Auth --- app/Http/Kernel.php | 3 +- app/Http/Middleware/Authenticate.php | 56 +- app/Http/Middleware/UnauthenticatedUser.php | 47 - app/Models/App.php | 24 +- app/Models/User.php | 18 +- app/Providers/AuthServiceProvider.php | 4 - app/Services/AuthService.php | 29 +- .../Contracts/AuthServiceContract.php | 2 +- composer.json | 6 +- composer.lock | 1023 +++++------------ config/app.php | 1 - config/auth.php | 2 +- config/jwt.php | 305 +++++ database/seeders/AuthSeeder.php | 2 +- docker-compose.yaml | 2 +- heseya/resource/src/JsonResource.php | 2 +- tests/TestCase.php | 14 +- 17 files changed, 724 insertions(+), 816 deletions(-) delete mode 100644 app/Http/Middleware/UnauthenticatedUser.php create mode 100644 config/jwt.php diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index e877066c2..24ca16faf 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -31,7 +31,7 @@ class Kernel extends HttpKernel protected $middlewareGroups = [ 'api' => [ \Illuminate\Routing\Middleware\SubstituteBindings::class, - \App\Http\Middleware\UnauthenticatedUser::class, + \App\Http\Middleware\Authenticate::class, ], ]; @@ -60,7 +60,6 @@ class Kernel extends HttpKernel protected $middlewarePriority = [ \Fruitcake\Cors\HandleCors::class, \Illuminate\Routing\Middleware\SubstituteBindings::class, - \App\Http\Middleware\UnauthenticatedUser::class, \App\Http\Middleware\Authenticate::class, \Illuminate\Auth\Middleware\Authorize::class, \App\Http\Middleware\SecureHeaders::class, diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php index a610e7475..894a1675e 100644 --- a/app/Http/Middleware/Authenticate.php +++ b/app/Http/Middleware/Authenticate.php @@ -2,33 +2,63 @@ namespace App\Http\Middleware; +use App\Enums\RoleType; +use App\Models\Role; +use App\Models\User; use App\Models\App; use Closure; +use Illuminate\Auth\AuthenticationException; use Illuminate\Auth\Middleware\Authenticate as Middleware; -use Illuminate\Support\Facades\Hash; +use Illuminate\Http\Request; +use Illuminate\Support\Facades\Auth; +use Illuminate\Support\Facades\Config; +use Tymon\JWTAuth\Http\Parser\Parser; +use Tymon\JWTAuth\JWT; +use Tymon\JWTAuth\Manager; +use Tymon\JWTAuth\Payload; class Authenticate extends Middleware { /** + * @throws AuthenticationException */ public function handle($request, Closure $next, ...$guards): mixed { - if ( - $request->hasHeader('x-app-id') && - $request->hasHeader('x-app-key') && - $this->authenticateApp($request->header('x-app-id'), $request->header('x-app-key')) - ) { - return $next($request); + if (!Auth::check()) { + if ($request->hasHeader('Authorization')) { + Config::set('auth.providers.users.model', App::class); + Auth::forgetGuards(); + + if (!Auth::check()) { + throw new AuthenticationException(); + } + } else { + $user = User::make([ + 'name' => 'Unauthenticated', + ]); + + $roles = Role::where('type', RoleType::UNAUTHENTICATED)->get(); + $user->setRelation('roles', $roles); + $user->id = 'null'; + + Auth::claims(['typ' => 'access'])->login($user); + } } - return parent::handle($request, $next, ...$guards); - } + if (Auth::payload()->get('typ') !== 'access') { + throw new AuthenticationException(); + } - protected function authenticateApp(string $id, string $key): bool - { - $app = App::findOrFail($id); +//// Token service +// +// $token = Auth::getToken(); +// +// $jwt = new JWT(app(Manager::class), new Parser(new Request())); +// $jwt->setToken($token); +// +// dd($jwt->payload()); - return $app && Hash::check($key, $app->key); + return $next($request); } /** diff --git a/app/Http/Middleware/UnauthenticatedUser.php b/app/Http/Middleware/UnauthenticatedUser.php deleted file mode 100644 index 07aad2646..000000000 --- a/app/Http/Middleware/UnauthenticatedUser.php +++ /dev/null @@ -1,47 +0,0 @@ -hasHeader('Authorization') && !Auth::check()) { - throw new AuthenticationException(); - } - - if (!Auth::check()) { - $user = User::make([ - 'name' => 'Unauthenticated', - ]); - - $roles = Role::where('type', RoleType::UNAUTHENTICATED)->get(); - $user->setRelation('roles', $roles); - - Auth::setUser($user); - } - - return $next($request); - } - - /** - * Get the path the user should be redirected to when they are not authenticated. - * - * @return null - */ - protected function redirectTo($request) - { - return null; - } -} diff --git a/app/Models/App.php b/app/Models/App.php index 4a28fcd7f..157d7e670 100644 --- a/app/Models/App.php +++ b/app/Models/App.php @@ -2,18 +2,38 @@ namespace App\Models; +use Illuminate\Auth\Authenticatable; +use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract; +use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract; use Illuminate\Database\Eloquent\Factories\HasFactory; +use Illuminate\Foundation\Auth\Access\Authorizable; +use Tymon\JWTAuth\Contracts\JWTSubject; /** * @mixin IdeHelperApp */ -class App extends Model +class App extends Model implements + AuthorizableContract, + AuthenticatableContract, + JWTSubject { - use HasFactory; + use HasFactory, + Authorizable, + Authenticatable; protected $fillable = [ 'name', 'key', 'url', ]; + + public function getJWTIdentifier(): string + { + return $this->getKey(); + } + + public function getJWTCustomClaims(): array + { + return []; + } } diff --git a/app/Models/User.php b/app/Models/User.php index 8226afde3..c8418af6d 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -16,10 +16,10 @@ use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Foundation\Auth\Access\Authorizable; use Illuminate\Notifications\Notifiable; -use Laravel\Passport\HasApiTokens; use OwenIt\Auditing\Auditable; use OwenIt\Auditing\Contracts\Auditable as AuditableContract; use Spatie\Permission\Traits\HasRoles; +use Tymon\JWTAuth\Contracts\JWTSubject; /** * @OA\Schema () @@ -30,10 +30,10 @@ class User extends Model implements AuthenticatableContract, AuthorizableContract, CanResetPasswordContract, - AuditableContract + AuditableContract, + JWTSubject { - use HasApiTokens, - Notifiable, + use Notifiable, Authenticatable, Authorizable, CanResetPassword, @@ -108,4 +108,14 @@ public function getAvatarAttribute(): string { return '//www.gravatar.com/avatar/' . md5(strtolower(trim($this->email))) . '?d=mp&s=50x50'; } + + public function getJWTIdentifier(): string + { + return $this->getKey(); + } + + public function getJWTCustomClaims(): array + { + return []; + } } diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php index 021175715..5ba9f9f8b 100644 --- a/app/Providers/AuthServiceProvider.php +++ b/app/Providers/AuthServiceProvider.php @@ -22,10 +22,6 @@ public function boot(): void { $this->registerPolicies(); - Passport::routes(); - Passport::ignoreMigrations(); - Passport::personalAccessTokensExpireIn(now()->addDays(25)); - Password::defaults(function () { return Password::min(10) ->letters() diff --git a/app/Services/AuthService.php b/app/Services/AuthService.php index 212172145..2d20f8823 100644 --- a/app/Services/AuthService.php +++ b/app/Services/AuthService.php @@ -3,6 +3,7 @@ namespace App\Services; use App\Exceptions\AuthException; +use App\Models\App; use App\Models\User; use App\Notifications\ResetPassword; use App\Services\Contracts\AuthServiceContract; @@ -11,27 +12,31 @@ use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Password; -use Laravel\Passport\Passport; -use Laravel\Passport\PersonalAccessTokenResult; class AuthService implements AuthServiceContract { - public function login(string $email, string $password, ?string $ip, ?string $userAgent): PersonalAccessTokenResult + public function login(string $email, string $password, ?string $ip, ?string $userAgent) { - if (!Auth::guard('web')->attempt([ + $token = Auth::claims(['typ' => 'identity'])->attempt([ 'email' => $email, 'password' => $password, - ])) { + ]); + + if ($token === null) { throw new AuthException('Invalid credentials'); } - $user = Auth::guard('web')->user(); - $token = $user->createToken('Admin'); - - $token->token->update([ - 'ip' => $ip, - 'user_agent' => $userAgent, - ]); +// $user = Auth::guard('web')->user(); +// $token = $user->createToken('Admin'); +// +// $token->token->update([ +// 'ip' => $ip, +// 'user_agent' => $userAgent, +// ]); + +// $user = App::factory()->create(); +// +// $token = auth()->login($user); return $token; } diff --git a/app/Services/Contracts/AuthServiceContract.php b/app/Services/Contracts/AuthServiceContract.php index bdbb1cbde..9765090f1 100644 --- a/app/Services/Contracts/AuthServiceContract.php +++ b/app/Services/Contracts/AuthServiceContract.php @@ -8,7 +8,7 @@ interface AuthServiceContract { - public function login(string $email, string $password, ?string $ip, ?string $userAgent): PersonalAccessTokenResult; + public function login(string $email, string $password, ?string $ip, ?string $userAgent); public function logout(User $user): void; diff --git a/composer.json b/composer.json index 6ce761f1d..59e3127a1 100644 --- a/composer.json +++ b/composer.json @@ -12,12 +12,11 @@ "fideloper/proxy": "^4.4", "fruitcake/laravel-cors": "^2.0", "guzzlehttp/guzzle": "^7.3", - "heseya/laravel-searchable": "^1.0", "heseya/demo": "dev-master", + "heseya/laravel-searchable": "^1.0", "heseya/resource": "*", "jenssegers/agent": "^2.6", "laravel/framework": "^8.44", - "laravel/passport": "^10.1", "league/html-to-markdown": "^5.0", "league/omnipay": "^3.1", "omnipay/common": "^3", @@ -28,7 +27,8 @@ "propaganistas/laravel-phone": "^4.3", "sentry/sentry-laravel": "^2.6", "spatie/laravel-permission": "^4.2", - "srmklive/paypal": "^3.0" + "srmklive/paypal": "^3.0", + "tymon/jwt-auth": "^1.0.2" }, "require-dev": { "brianium/paratest": "^6.3", diff --git a/composer.lock b/composer.lock index a392b9dee..f39745fbb 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b11cc34936115b5eba90009e9a809832", + "content-hash": "abc7c540d9d4d4120ca9c5557ac5c1fe", "packages": [ { "name": "asm89/stack-cors", @@ -206,16 +206,16 @@ }, { "name": "bensampo/laravel-enum", - "version": "v3.4.1", + "version": "v3.4.2", "source": { "type": "git", "url": "https://github.com/BenSampo/laravel-enum.git", - "reference": "67e13f8a211d43035146150793a95c4140f7831d" + "reference": "fba54d86b4865e63db3502c4e23bab192fb75314" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/BenSampo/laravel-enum/zipball/67e13f8a211d43035146150793a95c4140f7831d", - "reference": "67e13f8a211d43035146150793a95c4140f7831d", + "url": "https://api.github.com/repos/BenSampo/laravel-enum/zipball/fba54d86b4865e63db3502c4e23bab192fb75314", + "reference": "fba54d86b4865e63db3502c4e23bab192fb75314", "shasum": "" }, "require": { @@ -277,7 +277,7 @@ ], "support": { "issues": "https://github.com/BenSampo/laravel-enum/issues", - "source": "https://github.com/BenSampo/laravel-enum/tree/v3.4.1" + "source": "https://github.com/BenSampo/laravel-enum/tree/v3.4.2" }, "funding": [ { @@ -285,7 +285,7 @@ "type": "github" } ], - "time": "2021-06-17T14:35:14+00:00" + "time": "2021-09-09T17:27:58+00:00" }, { "name": "brick/math", @@ -1032,72 +1032,6 @@ ], "time": "2021-07-12T06:31:40+00:00" }, - { - "name": "defuse/php-encryption", - "version": "v2.3.1", - "source": { - "type": "git", - "url": "https://github.com/defuse/php-encryption.git", - "reference": "77880488b9954b7884c25555c2a0ea9e7053f9d2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/defuse/php-encryption/zipball/77880488b9954b7884c25555c2a0ea9e7053f9d2", - "reference": "77880488b9954b7884c25555c2a0ea9e7053f9d2", - "shasum": "" - }, - "require": { - "ext-openssl": "*", - "paragonie/random_compat": ">= 2", - "php": ">=5.6.0" - }, - "require-dev": { - "phpunit/phpunit": "^4|^5|^6|^7|^8|^9" - }, - "bin": [ - "bin/generate-defuse-key" - ], - "type": "library", - "autoload": { - "psr-4": { - "Defuse\\Crypto\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Taylor Hornby", - "email": "taylor@defuse.ca", - "homepage": "https://defuse.ca/" - }, - { - "name": "Scott Arciszewski", - "email": "info@paragonie.com", - "homepage": "https://paragonie.com" - } - ], - "description": "Secure PHP Encryption Library", - "keywords": [ - "aes", - "authenticated encryption", - "cipher", - "crypto", - "cryptography", - "encrypt", - "encryption", - "openssl", - "security", - "symmetric key cryptography" - ], - "support": { - "issues": "https://github.com/defuse/php-encryption/issues", - "source": "https://github.com/defuse/php-encryption/tree/v2.3.1" - }, - "time": "2021-04-09T23:57:26+00:00" - }, { "name": "dflydev/dot-access-data", "version": "v3.0.1", @@ -2002,63 +1936,6 @@ }, "time": "2020-10-22T13:48:01+00:00" }, - { - "name": "firebase/php-jwt", - "version": "v5.4.0", - "source": { - "type": "git", - "url": "https://github.com/firebase/php-jwt.git", - "reference": "d2113d9b2e0e349796e72d2a63cf9319100382d2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/firebase/php-jwt/zipball/d2113d9b2e0e349796e72d2a63cf9319100382d2", - "reference": "d2113d9b2e0e349796e72d2a63cf9319100382d2", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "require-dev": { - "phpunit/phpunit": ">=4.8 <=9" - }, - "suggest": { - "paragonie/sodium_compat": "Support EdDSA (Ed25519) signatures when libsodium is not present" - }, - "type": "library", - "autoload": { - "psr-4": { - "Firebase\\JWT\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Neuman Vong", - "email": "neuman+pear@twilio.com", - "role": "Developer" - }, - { - "name": "Anant Narayanan", - "email": "anant@php.net", - "role": "Developer" - } - ], - "description": "A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.", - "homepage": "https://github.com/firebase/php-jwt", - "keywords": [ - "jwt", - "php" - ], - "support": { - "issues": "https://github.com/firebase/php-jwt/issues", - "source": "https://github.com/firebase/php-jwt/tree/v5.4.0" - }, - "time": "2021-06-23T19:00:23+00:00" - }, { "name": "fruitcake/laravel-cors", "version": "v2.0.4", @@ -2138,16 +2015,16 @@ }, { "name": "giggsey/libphonenumber-for-php", - "version": "8.12.31", + "version": "8.12.32", "source": { "type": "git", "url": "https://github.com/giggsey/libphonenumber-for-php.git", - "reference": "2d79a2443df5a693286510a24a308a0625a8132c" + "reference": "b13fcfd3ebfef44486fc0bd1f830737047205ae3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/giggsey/libphonenumber-for-php/zipball/2d79a2443df5a693286510a24a308a0625a8132c", - "reference": "2d79a2443df5a693286510a24a308a0625a8132c", + "url": "https://api.github.com/repos/giggsey/libphonenumber-for-php/zipball/b13fcfd3ebfef44486fc0bd1f830737047205ae3", + "reference": "b13fcfd3ebfef44486fc0bd1f830737047205ae3", "shasum": "" }, "require": { @@ -2207,7 +2084,7 @@ "issues": "https://github.com/giggsey/libphonenumber-for-php/issues", "source": "https://github.com/giggsey/libphonenumber-for-php" }, - "time": "2021-08-24T07:02:46+00:00" + "time": "2021-09-10T14:29:11+00:00" }, { "name": "giggsey/locale", @@ -3231,16 +3108,16 @@ }, { "name": "laravel/framework", - "version": "v8.59.0", + "version": "v8.60.0", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "51d4755cc6232e7f8abb437567d713fa37661da2" + "reference": "44f16a31a1d4ac8a51605550d7796e2273984a48" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/51d4755cc6232e7f8abb437567d713fa37661da2", - "reference": "51d4755cc6232e7f8abb437567d713fa37661da2", + "url": "https://api.github.com/repos/laravel/framework/zipball/44f16a31a1d4ac8a51605550d7796e2273984a48", + "reference": "44f16a31a1d4ac8a51605550d7796e2273984a48", "shasum": "" }, "require": { @@ -3395,183 +3272,43 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2021-09-07T13:29:53+00:00" + "time": "2021-09-08T13:37:21+00:00" }, { - "name": "laravel/passport", - "version": "v10.1.3", + "name": "lcobucci/jwt", + "version": "3.2.5", "source": { "type": "git", - "url": "https://github.com/laravel/passport.git", - "reference": "a5e4471dd99b7638ab5ca3ecab6cd87cf37eb410" + "url": "https://github.com/lcobucci/jwt.git", + "reference": "82be04b4753f8b7693b62852b7eab30f97524f9b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/passport/zipball/a5e4471dd99b7638ab5ca3ecab6cd87cf37eb410", - "reference": "a5e4471dd99b7638ab5ca3ecab6cd87cf37eb410", + "url": "https://api.github.com/repos/lcobucci/jwt/zipball/82be04b4753f8b7693b62852b7eab30f97524f9b", + "reference": "82be04b4753f8b7693b62852b7eab30f97524f9b", "shasum": "" }, "require": { - "ext-json": "*", - "firebase/php-jwt": "^5.0", - "illuminate/auth": "^8.2", - "illuminate/console": "^8.2", - "illuminate/container": "^8.2", - "illuminate/contracts": "^8.2", - "illuminate/cookie": "^8.2", - "illuminate/database": "^8.2", - "illuminate/encryption": "^8.2", - "illuminate/http": "^8.2", - "illuminate/support": "^8.2", - "lcobucci/jwt": "^3.4|^4.0", - "league/oauth2-server": "^8.2", - "nyholm/psr7": "^1.3", - "php": "^7.3|^8.0", - "phpseclib/phpseclib": "^2.0|^3.0", - "symfony/psr-http-message-bridge": "^2.0" + "ext-openssl": "*", + "php": ">=5.5" }, "require-dev": { - "mockery/mockery": "^1.0", - "orchestra/testbench": "^6.0", - "phpunit/phpunit": "^9.3" + "mdanter/ecc": "~0.3.1", + "mikey179/vfsstream": "~1.5", + "phpmd/phpmd": "~2.2", + "phpunit/php-invoker": "~1.1", + "phpunit/phpunit": "~4.5", + "squizlabs/php_codesniffer": "~2.3" + }, + "suggest": { + "mdanter/ecc": "Required to use Elliptic Curves based algorithms." }, "type": "library", "extra": { "branch-alias": { - "dev-master": "10.x-dev" - }, - "laravel": { - "providers": [ - "Laravel\\Passport\\PassportServiceProvider" - ] - } - }, - "autoload": { - "psr-4": { - "Laravel\\Passport\\": "src/", - "Laravel\\Passport\\Database\\Factories\\": "database/factories/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Taylor Otwell", - "email": "taylor@laravel.com" - } - ], - "description": "Laravel Passport provides OAuth2 server support to Laravel.", - "keywords": [ - "laravel", - "oauth", - "passport" - ], - "support": { - "issues": "https://github.com/laravel/passport/issues", - "source": "https://github.com/laravel/passport" - }, - "time": "2021-04-06T14:30:45+00:00" - }, - { - "name": "lcobucci/clock", - "version": "2.0.0", - "source": { - "type": "git", - "url": "https://github.com/lcobucci/clock.git", - "reference": "353d83fe2e6ae95745b16b3d911813df6a05bfb3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/lcobucci/clock/zipball/353d83fe2e6ae95745b16b3d911813df6a05bfb3", - "reference": "353d83fe2e6ae95745b16b3d911813df6a05bfb3", - "shasum": "" - }, - "require": { - "php": "^7.4 || ^8.0" - }, - "require-dev": { - "infection/infection": "^0.17", - "lcobucci/coding-standard": "^6.0", - "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "^0.12", - "phpstan/phpstan-deprecation-rules": "^0.12", - "phpstan/phpstan-phpunit": "^0.12", - "phpstan/phpstan-strict-rules": "^0.12", - "phpunit/php-code-coverage": "9.1.4", - "phpunit/phpunit": "9.3.7" - }, - "type": "library", - "autoload": { - "psr-4": { - "Lcobucci\\Clock\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Luís Cobucci", - "email": "lcobucci@gmail.com" - } - ], - "description": "Yet another clock abstraction", - "support": { - "issues": "https://github.com/lcobucci/clock/issues", - "source": "https://github.com/lcobucci/clock/tree/2.0.x" - }, - "funding": [ - { - "url": "https://github.com/lcobucci", - "type": "github" - }, - { - "url": "https://www.patreon.com/lcobucci", - "type": "patreon" + "dev-master": "3.1-dev" } - ], - "time": "2020-08-27T18:56:02+00:00" - }, - { - "name": "lcobucci/jwt", - "version": "4.1.4", - "source": { - "type": "git", - "url": "https://github.com/lcobucci/jwt.git", - "reference": "71cf170102c8371ccd933fa4df6252086d144de6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/lcobucci/jwt/zipball/71cf170102c8371ccd933fa4df6252086d144de6", - "reference": "71cf170102c8371ccd933fa4df6252086d144de6", - "shasum": "" - }, - "require": { - "ext-hash": "*", - "ext-json": "*", - "ext-mbstring": "*", - "ext-openssl": "*", - "ext-sodium": "*", - "lcobucci/clock": "^2.0", - "php": "^7.4 || ^8.0" - }, - "require-dev": { - "infection/infection": "^0.21", - "lcobucci/coding-standard": "^6.0", - "mikey179/vfsstream": "^1.6.7", - "phpbench/phpbench": "^1.0@alpha", - "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "^0.12", - "phpstan/phpstan-deprecation-rules": "^0.12", - "phpstan/phpstan-phpunit": "^0.12", - "phpstan/phpstan-strict-rules": "^0.12", - "phpunit/php-invoker": "^3.1", - "phpunit/phpunit": "^9.5" }, - "type": "library", "autoload": { "psr-4": { "Lcobucci\\JWT\\": "src" @@ -3583,7 +3320,7 @@ ], "authors": [ { - "name": "Luís Cobucci", + "name": "Luís Otávio Cobucci Oblonczyk", "email": "lcobucci@gmail.com", "role": "Developer" } @@ -3595,19 +3332,9 @@ ], "support": { "issues": "https://github.com/lcobucci/jwt/issues", - "source": "https://github.com/lcobucci/jwt/tree/4.1.4" + "source": "https://github.com/lcobucci/jwt/tree/3.2" }, - "funding": [ - { - "url": "https://github.com/lcobucci", - "type": "github" - }, - { - "url": "https://www.patreon.com/lcobucci", - "type": "patreon" - } - ], - "time": "2021-03-23T23:53:08+00:00" + "time": "2018-11-11T12:22:26+00:00" }, { "name": "league/commonmark", @@ -3802,60 +3529,6 @@ ], "time": "2021-08-14T12:15:32+00:00" }, - { - "name": "league/event", - "version": "2.2.0", - "source": { - "type": "git", - "url": "https://github.com/thephpleague/event.git", - "reference": "d2cc124cf9a3fab2bb4ff963307f60361ce4d119" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/thephpleague/event/zipball/d2cc124cf9a3fab2bb4ff963307f60361ce4d119", - "reference": "d2cc124cf9a3fab2bb4ff963307f60361ce4d119", - "shasum": "" - }, - "require": { - "php": ">=5.4.0" - }, - "require-dev": { - "henrikbjorn/phpspec-code-coverage": "~1.0.1", - "phpspec/phpspec": "^2.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.2-dev" - } - }, - "autoload": { - "psr-4": { - "League\\Event\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Frank de Jonge", - "email": "info@frenky.net" - } - ], - "description": "Event package", - "keywords": [ - "emitter", - "event", - "listener" - ], - "support": { - "issues": "https://github.com/thephpleague/event/issues", - "source": "https://github.com/thephpleague/event/tree/master" - }, - "time": "2018-11-26T11:52:41+00:00" - }, { "name": "league/flysystem", "version": "1.1.5", @@ -4152,93 +3825,6 @@ ], "time": "2021-01-18T20:58:21+00:00" }, - { - "name": "league/oauth2-server", - "version": "8.3.2", - "source": { - "type": "git", - "url": "https://github.com/thephpleague/oauth2-server.git", - "reference": "0809487d33dd8a2c8c8c04e4a599ba4aadba1ae6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/thephpleague/oauth2-server/zipball/0809487d33dd8a2c8c8c04e4a599ba4aadba1ae6", - "reference": "0809487d33dd8a2c8c8c04e4a599ba4aadba1ae6", - "shasum": "" - }, - "require": { - "defuse/php-encryption": "^2.2.1", - "ext-json": "*", - "ext-openssl": "*", - "lcobucci/jwt": "^3.4 || ^4.0", - "league/event": "^2.2", - "php": "^7.2 || ^8.0", - "psr/http-message": "^1.0.1" - }, - "replace": { - "league/oauth2server": "*", - "lncd/oauth2": "*" - }, - "require-dev": { - "laminas/laminas-diactoros": "^2.4.1", - "phpstan/phpstan": "^0.12.57", - "phpstan/phpstan-phpunit": "^0.12.16", - "phpunit/phpunit": "^8.5.13", - "roave/security-advisories": "dev-master" - }, - "type": "library", - "autoload": { - "psr-4": { - "League\\OAuth2\\Server\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Alex Bilbie", - "email": "hello@alexbilbie.com", - "homepage": "http://www.alexbilbie.com", - "role": "Developer" - }, - { - "name": "Andy Millington", - "email": "andrew@noexceptions.io", - "homepage": "https://www.noexceptions.io", - "role": "Developer" - } - ], - "description": "A lightweight and powerful OAuth 2.0 authorization and resource server library with support for all the core specification grants. This library will allow you to secure your API with OAuth and allow your applications users to approve apps that want to access their data from your API.", - "homepage": "https://oauth2.thephpleague.com/", - "keywords": [ - "Authentication", - "api", - "auth", - "authorisation", - "authorization", - "oauth", - "oauth 2", - "oauth 2.0", - "oauth2", - "protect", - "resource", - "secure", - "server" - ], - "support": { - "issues": "https://github.com/thephpleague/oauth2-server/issues", - "source": "https://github.com/thephpleague/oauth2-server/tree/8.3.2" - }, - "funding": [ - { - "url": "https://github.com/sephster", - "type": "github" - } - ], - "time": "2021-07-27T08:17:08+00:00" - }, { "name": "league/omnipay", "version": "v3.2.1", @@ -4534,17 +4120,84 @@ "issues": "https://github.com/Seldaek/monolog/issues", "source": "https://github.com/Seldaek/monolog/tree/2.3.2" }, - "funding": [ + "funding": [ + { + "url": "https://github.com/Seldaek", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/monolog/monolog", + "type": "tidelift" + } + ], + "time": "2021-07-23T07:42:52+00:00" + }, + { + "name": "namshi/jose", + "version": "7.2.3", + "source": { + "type": "git", + "url": "https://github.com/namshi/jose.git", + "reference": "89a24d7eb3040e285dd5925fcad992378b82bcff" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/namshi/jose/zipball/89a24d7eb3040e285dd5925fcad992378b82bcff", + "reference": "89a24d7eb3040e285dd5925fcad992378b82bcff", + "shasum": "" + }, + "require": { + "ext-date": "*", + "ext-hash": "*", + "ext-json": "*", + "ext-pcre": "*", + "ext-spl": "*", + "php": ">=5.5", + "symfony/polyfill-php56": "^1.0" + }, + "require-dev": { + "phpseclib/phpseclib": "^2.0", + "phpunit/phpunit": "^4.5|^5.0", + "satooshi/php-coveralls": "^1.0" + }, + "suggest": { + "ext-openssl": "Allows to use OpenSSL as crypto engine.", + "phpseclib/phpseclib": "Allows to use Phpseclib as crypto engine, use version ^2.0." + }, + "type": "library", + "autoload": { + "psr-4": { + "Namshi\\JOSE\\": "src/Namshi/JOSE/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ { - "url": "https://github.com/Seldaek", - "type": "github" + "name": "Alessandro Nadalin", + "email": "alessandro.nadalin@gmail.com" }, { - "url": "https://tidelift.com/funding/github/packagist/monolog/monolog", - "type": "tidelift" + "name": "Alessandro Cinelli (cirpo)", + "email": "alessandro.cinelli@gmail.com" } ], - "time": "2021-07-23T07:42:52+00:00" + "description": "JSON Object Signing and Encryption library for PHP.", + "keywords": [ + "JSON Web Signature", + "JSON Web Token", + "JWS", + "json", + "jwt", + "token" + ], + "support": { + "issues": "https://github.com/namshi/jose/issues", + "source": "https://github.com/namshi/jose/tree/master" + }, + "time": "2016-12-05T07:27:31+00:00" }, { "name": "nesbot/carbon", @@ -5228,123 +4881,6 @@ }, "time": "2020-12-15T19:19:43+00:00" }, - { - "name": "paragonie/constant_time_encoding", - "version": "v2.4.0", - "source": { - "type": "git", - "url": "https://github.com/paragonie/constant_time_encoding.git", - "reference": "f34c2b11eb9d2c9318e13540a1dbc2a3afbd939c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/paragonie/constant_time_encoding/zipball/f34c2b11eb9d2c9318e13540a1dbc2a3afbd939c", - "reference": "f34c2b11eb9d2c9318e13540a1dbc2a3afbd939c", - "shasum": "" - }, - "require": { - "php": "^7|^8" - }, - "require-dev": { - "phpunit/phpunit": "^6|^7|^8|^9", - "vimeo/psalm": "^1|^2|^3|^4" - }, - "type": "library", - "autoload": { - "psr-4": { - "ParagonIE\\ConstantTime\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Paragon Initiative Enterprises", - "email": "security@paragonie.com", - "homepage": "https://paragonie.com", - "role": "Maintainer" - }, - { - "name": "Steve 'Sc00bz' Thomas", - "email": "steve@tobtu.com", - "homepage": "https://www.tobtu.com", - "role": "Original Developer" - } - ], - "description": "Constant-time Implementations of RFC 4648 Encoding (Base-64, Base-32, Base-16)", - "keywords": [ - "base16", - "base32", - "base32_decode", - "base32_encode", - "base64", - "base64_decode", - "base64_encode", - "bin2hex", - "encoding", - "hex", - "hex2bin", - "rfc4648" - ], - "support": { - "email": "info@paragonie.com", - "issues": "https://github.com/paragonie/constant_time_encoding/issues", - "source": "https://github.com/paragonie/constant_time_encoding" - }, - "time": "2020-12-06T15:14:20+00:00" - }, - { - "name": "paragonie/random_compat", - "version": "v9.99.100", - "source": { - "type": "git", - "url": "https://github.com/paragonie/random_compat.git", - "reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/paragonie/random_compat/zipball/996434e5492cb4c3edcb9168db6fbb1359ef965a", - "reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a", - "shasum": "" - }, - "require": { - "php": ">= 7" - }, - "require-dev": { - "phpunit/phpunit": "4.*|5.*", - "vimeo/psalm": "^1" - }, - "suggest": { - "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." - }, - "type": "library", - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Paragon Initiative Enterprises", - "email": "security@paragonie.com", - "homepage": "https://paragonie.com" - } - ], - "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", - "keywords": [ - "csprng", - "polyfill", - "pseudorandom", - "random" - ], - "support": { - "email": "info@paragonie.com", - "issues": "https://github.com/paragonie/random_compat/issues", - "source": "https://github.com/paragonie/random_compat" - }, - "time": "2020-10-15T08:29:30+00:00" - }, { "name": "parsedown/laravel", "version": "1.2.1", @@ -6098,117 +5634,6 @@ ], "time": "2021-08-28T21:27:29+00:00" }, - { - "name": "phpseclib/phpseclib", - "version": "3.0.10", - "source": { - "type": "git", - "url": "https://github.com/phpseclib/phpseclib.git", - "reference": "62fcc5a94ac83b1506f52d7558d828617fac9187" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/62fcc5a94ac83b1506f52d7558d828617fac9187", - "reference": "62fcc5a94ac83b1506f52d7558d828617fac9187", - "shasum": "" - }, - "require": { - "paragonie/constant_time_encoding": "^1|^2", - "paragonie/random_compat": "^1.4|^2.0|^9.99.99", - "php": ">=5.6.1" - }, - "require-dev": { - "phing/phing": "~2.7", - "phpunit/phpunit": "^5.7|^6.0|^9.4", - "squizlabs/php_codesniffer": "~2.0" - }, - "suggest": { - "ext-gmp": "Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.", - "ext-libsodium": "SSH2/SFTP can make use of some algorithms provided by the libsodium-php extension.", - "ext-mcrypt": "Install the Mcrypt extension in order to speed up a few other cryptographic operations.", - "ext-openssl": "Install the OpenSSL extension in order to speed up a wide variety of cryptographic operations." - }, - "type": "library", - "autoload": { - "files": [ - "phpseclib/bootstrap.php" - ], - "psr-4": { - "phpseclib3\\": "phpseclib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jim Wigginton", - "email": "terrafrost@php.net", - "role": "Lead Developer" - }, - { - "name": "Patrick Monnerat", - "email": "pm@datasphere.ch", - "role": "Developer" - }, - { - "name": "Andreas Fischer", - "email": "bantu@phpbb.com", - "role": "Developer" - }, - { - "name": "Hans-Jürgen Petrich", - "email": "petrich@tronic-media.com", - "role": "Developer" - }, - { - "name": "Graham Campbell", - "email": "graham@alt-three.com", - "role": "Developer" - } - ], - "description": "PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.", - "homepage": "http://phpseclib.sourceforge.net", - "keywords": [ - "BigInteger", - "aes", - "asn.1", - "asn1", - "blowfish", - "crypto", - "cryptography", - "encryption", - "rsa", - "security", - "sftp", - "signature", - "signing", - "ssh", - "twofish", - "x.509", - "x509" - ], - "support": { - "issues": "https://github.com/phpseclib/phpseclib/issues", - "source": "https://github.com/phpseclib/phpseclib/tree/3.0.10" - }, - "funding": [ - { - "url": "https://github.com/terrafrost", - "type": "github" - }, - { - "url": "https://www.patreon.com/phpseclib", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/phpseclib/phpseclib", - "type": "tidelift" - } - ], - "time": "2021-08-16T04:24:45+00:00" - }, { "name": "propaganistas/laravel-phone", "version": "4.3.1", @@ -7460,16 +6885,16 @@ }, { "name": "swagger-api/swagger-ui", - "version": "v3.52.0", + "version": "v3.52.1", "source": { "type": "git", "url": "https://github.com/swagger-api/swagger-ui.git", - "reference": "b1ccd1f03a77cfd88b76c1cf3e07b6af7f9bbd7b" + "reference": "06a4cdb4274e1b5d754897e7c1e6aca78da119ea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/swagger-api/swagger-ui/zipball/b1ccd1f03a77cfd88b76c1cf3e07b6af7f9bbd7b", - "reference": "b1ccd1f03a77cfd88b76c1cf3e07b6af7f9bbd7b", + "url": "https://api.github.com/repos/swagger-api/swagger-ui/zipball/06a4cdb4274e1b5d754897e7c1e6aca78da119ea", + "reference": "06a4cdb4274e1b5d754897e7c1e6aca78da119ea", "shasum": "" }, "type": "library", @@ -7515,9 +6940,9 @@ ], "support": { "issues": "https://github.com/swagger-api/swagger-ui/issues", - "source": "https://github.com/swagger-api/swagger-ui/tree/v3.52.0" + "source": "https://github.com/swagger-api/swagger-ui/tree/v3.52.1" }, - "time": "2021-08-09T15:14:18+00:00" + "time": "2021-09-10T12:04:46+00:00" }, { "name": "swiftmailer/swiftmailer", @@ -9176,6 +8601,74 @@ ], "time": "2021-05-27T12:26:48+00:00" }, + { + "name": "symfony/polyfill-php56", + "version": "v1.20.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php56.git", + "reference": "54b8cd7e6c1643d78d011f3be89f3ef1f9f4c675" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php56/zipball/54b8cd7e6c1643d78d011f3be89f3ef1f9f4c675", + "reference": "54b8cd7e6c1643d78d011f3be89f3ef1f9f4c675", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "metapackage", + "extra": { + "branch-alias": { + "dev-main": "1.20-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php56/tree/v1.20.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-10-23T14:02:19+00:00" + }, { "name": "symfony/polyfill-php72", "version": "v1.23.0", @@ -10363,6 +9856,92 @@ }, "time": "2020-07-13T06:12:54+00:00" }, + { + "name": "tymon/jwt-auth", + "version": "dev-develop", + "source": { + "type": "git", + "url": "https://github.com/tymondesigns/jwt-auth.git", + "reference": "ab00f2d7cce5f043067aef7849cdc792de2df635" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/tymondesigns/jwt-auth/zipball/ab00f2d7cce5f043067aef7849cdc792de2df635", + "reference": "ab00f2d7cce5f043067aef7849cdc792de2df635", + "shasum": "" + }, + "require": { + "illuminate/auth": "^5.2|^6|^7|^8", + "illuminate/contracts": "^5.2|^6|^7|^8", + "illuminate/http": "^5.2|^6|^7|^8", + "illuminate/support": "^5.2|^6|^7|^8", + "lcobucci/jwt": "<3.4", + "namshi/jose": "^7.0", + "nesbot/carbon": "^1.0|^2.0", + "php": "^7.2|^8.0" + }, + "require-dev": { + "illuminate/console": "^5.2|^6|^7|^8", + "illuminate/database": "^5.2|^6|^7|^8", + "illuminate/routing": "^5.2|^6|^7|^8", + "mockery/mockery": ">=0.9.9", + "phpunit/phpunit": "^8.5|^9.4", + "yoast/phpunit-polyfills": "^0.2.0" + }, + "default-branch": true, + "type": "library", + "extra": { + "branch-alias": { + "dev-develop": "1.0-dev" + }, + "laravel": { + "aliases": { + "JWTAuth": "Tymon\\JWTAuth\\Facades\\JWTAuth", + "JWTFactory": "Tymon\\JWTAuth\\Facades\\JWTFactory" + }, + "providers": [ + "Tymon\\JWTAuth\\Providers\\LaravelServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Tymon\\JWTAuth\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Sean Tymon", + "email": "tymon148@gmail.com", + "homepage": "https://tymon.xyz", + "role": "Developer" + } + ], + "description": "JSON Web Token Authentication for Laravel and Lumen", + "homepage": "https://github.com/tymondesigns/jwt-auth", + "keywords": [ + "Authentication", + "JSON Web Token", + "auth", + "jwt", + "laravel" + ], + "support": { + "issues": "https://github.com/tymondesigns/jwt-auth/issues", + "source": "https://github.com/tymondesigns/jwt-auth" + }, + "funding": [ + { + "url": "https://www.patreon.com/seantymon", + "type": "patreon" + } + ], + "time": "2021-02-02T14:44:28+00:00" + }, { "name": "vlucas/phpdotenv", "version": "v5.3.0", @@ -10948,16 +10527,16 @@ }, { "name": "facade/ignition", - "version": "2.12.0", + "version": "2.12.1", "source": { "type": "git", "url": "https://github.com/facade/ignition.git", - "reference": "74dcc32a2895a126d1e5f2cd3bbab499cac66db1" + "reference": "567b0a4ab04367603e61729b0ca133fb7b4819db" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/facade/ignition/zipball/74dcc32a2895a126d1e5f2cd3bbab499cac66db1", - "reference": "74dcc32a2895a126d1e5f2cd3bbab499cac66db1", + "url": "https://api.github.com/repos/facade/ignition/zipball/567b0a4ab04367603e61729b0ca133fb7b4819db", + "reference": "567b0a4ab04367603e61729b0ca133fb7b4819db", "shasum": "" }, "require": { @@ -11020,7 +10599,7 @@ "issues": "https://github.com/facade/ignition/issues", "source": "https://github.com/facade/ignition" }, - "time": "2021-08-24T09:53:54+00:00" + "time": "2021-09-10T07:19:07+00:00" }, { "name": "facade/ignition-contracts", @@ -12241,33 +11820,33 @@ }, { "name": "phpspec/prophecy", - "version": "1.13.0", + "version": "1.14.0", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "be1996ed8adc35c3fd795488a653f4b518be70ea" + "reference": "d86dfc2e2a3cd366cee475e52c6bb3bbc371aa0e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/be1996ed8adc35c3fd795488a653f4b518be70ea", - "reference": "be1996ed8adc35c3fd795488a653f4b518be70ea", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/d86dfc2e2a3cd366cee475e52c6bb3bbc371aa0e", + "reference": "d86dfc2e2a3cd366cee475e52c6bb3bbc371aa0e", "shasum": "" }, "require": { "doctrine/instantiator": "^1.2", - "php": "^7.2 || ~8.0, <8.1", + "php": "^7.2 || ~8.0, <8.2", "phpdocumentor/reflection-docblock": "^5.2", "sebastian/comparator": "^3.0 || ^4.0", "sebastian/recursion-context": "^3.0 || ^4.0" }, "require-dev": { - "phpspec/phpspec": "^6.0", + "phpspec/phpspec": "^6.0 || ^7.0", "phpunit/phpunit": "^8.0 || ^9.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.11.x-dev" + "dev-master": "1.x-dev" } }, "autoload": { @@ -12302,22 +11881,22 @@ ], "support": { "issues": "https://github.com/phpspec/prophecy/issues", - "source": "https://github.com/phpspec/prophecy/tree/1.13.0" + "source": "https://github.com/phpspec/prophecy/tree/1.14.0" }, - "time": "2021-03-17T13:42:18+00:00" + "time": "2021-09-10T09:02:12+00:00" }, { "name": "phpstan/phpdoc-parser", - "version": "0.5.5", + "version": "0.5.6", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "ea0b17460ec38e20d7eb64e7ec49b5d44af5d28c" + "reference": "fac86158ffc7392e49636f77e63684c026df43b8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/ea0b17460ec38e20d7eb64e7ec49b5d44af5d28c", - "reference": "ea0b17460ec38e20d7eb64e7ec49b5d44af5d28c", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/fac86158ffc7392e49636f77e63684c026df43b8", + "reference": "fac86158ffc7392e49636f77e63684c026df43b8", "shasum": "" }, "require": { @@ -12351,9 +11930,9 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/0.5.5" + "source": "https://github.com/phpstan/phpdoc-parser/tree/0.5.6" }, - "time": "2021-06-11T13:24:46+00:00" + "time": "2021-08-31T08:08:22+00:00" }, { "name": "phpunit/php-code-coverage", @@ -13818,32 +13397,32 @@ }, { "name": "slevomat/coding-standard", - "version": "7.0.14", + "version": "7.0.15", "source": { "type": "git", "url": "https://github.com/slevomat/coding-standard.git", - "reference": "15b2b4630c148775debea8e412bc7e128d9868a3" + "reference": "cc80e59f9b4ca642f02dc1b615c37a9afc2a0f80" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/15b2b4630c148775debea8e412bc7e128d9868a3", - "reference": "15b2b4630c148775debea8e412bc7e128d9868a3", + "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/cc80e59f9b4ca642f02dc1b615c37a9afc2a0f80", + "reference": "cc80e59f9b4ca642f02dc1b615c37a9afc2a0f80", "shasum": "" }, "require": { "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7", "php": "^7.1 || ^8.0", - "phpstan/phpdoc-parser": "0.5.1 - 0.5.5", + "phpstan/phpdoc-parser": "0.5.1 - 0.5.6", "squizlabs/php_codesniffer": "^3.6.0" }, "require-dev": { - "phing/phing": "2.16.4", + "phing/phing": "2.17.0", "php-parallel-lint/php-parallel-lint": "1.3.1", - "phpstan/phpstan": "0.12.96", + "phpstan/phpstan": "0.12.98", "phpstan/phpstan-deprecation-rules": "0.12.6", "phpstan/phpstan-phpunit": "0.12.22", "phpstan/phpstan-strict-rules": "0.12.11", - "phpunit/phpunit": "7.5.20|8.5.5|9.5.8" + "phpunit/phpunit": "7.5.20|8.5.5|9.5.9" }, "type": "phpcodesniffer-standard", "extra": { @@ -13863,7 +13442,7 @@ "description": "Slevomat Coding Standard for PHP_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.", "support": { "issues": "https://github.com/slevomat/coding-standard/issues", - "source": "https://github.com/slevomat/coding-standard/tree/7.0.14" + "source": "https://github.com/slevomat/coding-standard/tree/7.0.15" }, "funding": [ { @@ -13875,7 +13454,7 @@ "type": "tidelift" } ], - "time": "2021-08-26T12:17:56+00:00" + "time": "2021-09-09T10:29:09+00:00" }, { "name": "squizlabs/php_codesniffer", diff --git a/config/app.php b/config/app.php index 514aaa104..0ed3c0654 100644 --- a/config/app.php +++ b/config/app.php @@ -176,7 +176,6 @@ * PackageTemplate Service Providers... */ L5Swagger\L5SwaggerServiceProvider::class, - Laravel\Passport\PassportServiceProvider::class, Parsedown\Providers\ParsedownServiceProvider::class, Jenssegers\Agent\AgentServiceProvider::class, Spatie\Permission\PermissionServiceProvider::class, diff --git a/config/auth.php b/config/auth.php index 872798e93..4f1a131b4 100644 --- a/config/auth.php +++ b/config/auth.php @@ -37,7 +37,7 @@ 'guards' => [ 'api' => [ - 'driver' => 'passport', + 'driver' => 'jwt', 'provider' => 'users', ], diff --git a/config/jwt.php b/config/jwt.php new file mode 100644 index 000000000..8b25ad693 --- /dev/null +++ b/config/jwt.php @@ -0,0 +1,305 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +return [ + + /* + |-------------------------------------------------------------------------- + | JWT Authentication Secret + |-------------------------------------------------------------------------- + | + | Don't forget to set this in your .env file, as it will be used to sign + | your tokens. A helper command is provided for this: + | `php artisan jwt:secret` + | + | Note: This will be used for Symmetric algorithms only (HMAC), + | since RSA and ECDSA use a private/public key combo (See below). + | + */ + + 'secret' => env('JWT_SECRET'), + + /* + |-------------------------------------------------------------------------- + | JWT Authentication Keys + |-------------------------------------------------------------------------- + | + | The algorithm you are using, will determine whether your tokens are + | signed with a random string (defined in `JWT_SECRET`) or using the + | following public & private keys. + | + | Symmetric Algorithms: + | HS256, HS384 & HS512 will use `JWT_SECRET`. + | + | Asymmetric Algorithms: + | RS256, RS384 & RS512 / ES256, ES384 & ES512 will use the keys below. + | + */ + + 'keys' => [ + + /* + |-------------------------------------------------------------------------- + | Public Key + |-------------------------------------------------------------------------- + | + | A path or resource to your public key. + | + | E.g. 'file://path/to/public/key' + | + */ + + 'public' => env('JWT_PUBLIC_KEY'), + + /* + |-------------------------------------------------------------------------- + | Private Key + |-------------------------------------------------------------------------- + | + | A path or resource to your private key. + | + | E.g. 'file://path/to/private/key' + | + */ + + 'private' => env('JWT_PRIVATE_KEY'), + + /* + |-------------------------------------------------------------------------- + | Passphrase + |-------------------------------------------------------------------------- + | + | The passphrase for your private key. Can be null if none set. + | + */ + + 'passphrase' => env('JWT_PASSPHRASE'), + + ], + + /* + |-------------------------------------------------------------------------- + | JWT time to live + |-------------------------------------------------------------------------- + | + | Specify the length of time (in minutes) that the token will be valid for. + | Defaults to 1 hour. + | + | You can also set this to null, to yield a never expiring token. + | Some people may want this behaviour for e.g. a mobile app. + | This is not particularly recommended, so make sure you have appropriate + | systems in place to revoke the token if necessary. + | Notice: If you set this to null you should remove 'exp' element from 'required_claims' list. + | + */ + + 'ttl' => env('JWT_TTL', 5), + + /* + |-------------------------------------------------------------------------- + | Refresh time to live + |-------------------------------------------------------------------------- + | + | Specify the length of time (in minutes) that the token can be refreshed + | within. I.E. The user can refresh their token within a 2 week window of + | the original token being created until they must re-authenticate. + | Defaults to 2 weeks. + | + | You can also set this to null, to yield an infinite refresh time. + | Some may want this instead of never expiring tokens for e.g. a mobile app. + | This is not particularly recommended, so make sure you have appropriate + | systems in place to revoke the token if necessary. + | + */ + + 'refresh_ttl' => env('JWT_REFRESH_TTL', 20160), + + /* + |-------------------------------------------------------------------------- + | JWT hashing algorithm + |-------------------------------------------------------------------------- + | + | Specify the hashing algorithm that will be used to sign the token. + | + | See here: https://github.com/namshi/jose/tree/master/src/Namshi/JOSE/Signer/OpenSSL + | for possible values. + | + */ + + 'algo' => env('JWT_ALGO', 'HS256'), + + /* + |-------------------------------------------------------------------------- + | Required Claims + |-------------------------------------------------------------------------- + | + | Specify the required claims that must exist in any token. + | A TokenInvalidException will be thrown if any of these claims are not + | present in the payload. + | + */ + + 'required_claims' => [ + 'iss', + 'iat', + 'exp', + 'nbf', + 'sub', + 'jti', + 'typ', + ], + + /* + |-------------------------------------------------------------------------- + | Persistent Claims + |-------------------------------------------------------------------------- + | + | Specify the claim keys to be persisted when refreshing a token. + | `sub` and `iat` will automatically be persisted, in + | addition to the these claims. + | + | Note: If a claim does not exist then it will be ignored. + | + */ + + 'persistent_claims' => [ + // 'foo', + // 'bar', + ], + + /* + |-------------------------------------------------------------------------- + | Lock Subject + |-------------------------------------------------------------------------- + | + | This will determine whether a `prv` claim is automatically added to + | the token. The purpose of this is to ensure that if you have multiple + | authentication models e.g. `App\User` & `App\OtherPerson`, then we + | should prevent one authentication request from impersonating another, + | if 2 tokens happen to have the same id across the 2 different models. + | + | Under specific circumstances, you may want to disable this behaviour + | e.g. if you only have one authentication model, then you would save + | a little on token size. + | + */ + + 'lock_subject' => true, + + /* + |-------------------------------------------------------------------------- + | Leeway + |-------------------------------------------------------------------------- + | + | This property gives the jwt timestamp claims some "leeway". + | Meaning that if you have any unavoidable slight clock skew on + | any of your servers then this will afford you some level of cushioning. + | + | This applies to the claims `iat`, `nbf` and `exp`. + | + | Specify in seconds - only if you know you need it. + | + */ + + 'leeway' => env('JWT_LEEWAY', 0), + + /* + |-------------------------------------------------------------------------- + | Blacklist Enabled + |-------------------------------------------------------------------------- + | + | In order to invalidate tokens, you must have the blacklist enabled. + | If you do not want or need this functionality, then set this to false. + | + */ + + 'blacklist_enabled' => env('JWT_BLACKLIST_ENABLED', true), + + /* + | ------------------------------------------------------------------------- + | Blacklist Grace Period + | ------------------------------------------------------------------------- + | + | When multiple concurrent requests are made with the same JWT, + | it is possible that some of them fail, due to token regeneration + | on every request. + | + | Set grace period in seconds to prevent parallel request failure. + | + */ + + 'blacklist_grace_period' => env('JWT_BLACKLIST_GRACE_PERIOD', 0), + + /* + |-------------------------------------------------------------------------- + | Cookies encryption + |-------------------------------------------------------------------------- + | + | By default Laravel encrypt cookies for security reason. + | If you decide to not decrypt cookies, you will have to configure Laravel + | to not encrypt your cookie token by adding its name into the $except + | array available in the middleware "EncryptCookies" provided by Laravel. + | see https://laravel.com/docs/master/responses#cookies-and-encryption + | for details. + | + | Set it to true if you want to decrypt cookies. + | + */ + + 'decrypt_cookies' => false, + + /* + |-------------------------------------------------------------------------- + | Providers + |-------------------------------------------------------------------------- + | + | Specify the various providers used throughout the package. + | + */ + + 'providers' => [ + + /* + |-------------------------------------------------------------------------- + | JWT Provider + |-------------------------------------------------------------------------- + | + | Specify the provider that is used to create and decode the tokens. + | + */ + + 'jwt' => Tymon\JWTAuth\Providers\JWT\Lcobucci::class, + + /* + |-------------------------------------------------------------------------- + | Authentication Provider + |-------------------------------------------------------------------------- + | + | Specify the provider that is used to authenticate users. + | + */ + + 'auth' => Tymon\JWTAuth\Providers\Auth\Illuminate::class, + + /* + |-------------------------------------------------------------------------- + | Storage Provider + |-------------------------------------------------------------------------- + | + | Specify the provider that is used to store tokens in the blacklist. + | + */ + + 'storage' => Tymon\JWTAuth\Providers\Storage\Illuminate::class, + + ], + +]; diff --git a/database/seeders/AuthSeeder.php b/database/seeders/AuthSeeder.php index 388c427f7..7fdb1d741 100644 --- a/database/seeders/AuthSeeder.php +++ b/database/seeders/AuthSeeder.php @@ -14,6 +14,6 @@ class AuthSeeder extends Seeder */ public function run() { - Artisan::call('passport:install'); +// Artisan::call('passport:install'); } } diff --git a/docker-compose.yaml b/docker-compose.yaml index c263c7c8f..98e294a96 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -16,7 +16,7 @@ services: php artisan key:generate sleep 15 php artisan migrate --seed - php artisan passport:install + php artisan jwt:secret --always-no touch /usr/src/init fi exec apache2-foreground diff --git a/heseya/resource/src/JsonResource.php b/heseya/resource/src/JsonResource.php index 3b9c7d0e9..db3d6262d 100644 --- a/heseya/resource/src/JsonResource.php +++ b/heseya/resource/src/JsonResource.php @@ -35,7 +35,7 @@ public function toArray($request): array } if (is_array($this->resource)) { - return $this->resource; + $this->resource = (object) $this->resource; } if ($this->baseOnly) { diff --git a/tests/TestCase.php b/tests/TestCase.php index 42b6c146f..568dbb405 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -5,9 +5,11 @@ use App\Models\Role; use App\Models\User; use Database\Seeders\PermissionSeeder; +use Illuminate\Contracts\Auth\Authenticatable; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Foundation\Testing\TestCase as BaseTestCase; use Illuminate\Support\Facades\Artisan; +use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Hash; abstract class TestCase extends BaseTestCase @@ -21,7 +23,6 @@ public function setUp(): void { parent::setUp(); - Artisan::call('passport:install'); $this->seed(PermissionSeeder::class); Role::query()->delete(); @@ -29,4 +30,15 @@ public function setUp(): void 'password' => Hash::make($this->password), ]); } + public function actingAs(Authenticatable $user, $guard = null) + { + $token = Auth::claims(['typ' => 'access'])->login($user); + + $this->withHeaders( + $this->defaultHeaders + ['Authorization' => 'Bearer ' . $token], + ); + + return $this; + } + }