tymondesigns / jwt-auth

🔐 JSON Web Token Authentication for Laravel & Lumen
https://jwt-auth.com
MIT License
11.31k stars 1.54k forks source link

Upgrade to v2.0 with lcobucci/jwt 4.3.0 crash with package:discover #2221

Open KhaledLela opened 1 year ago

KhaledLela commented 1 year ago

Subject of the issue

Describe your issue here.

Your environment

Q A
Bug? yes
New Feature? no
Framework Laravel
Framework version 9.52.4
Package version 2.0
PHP version 8.2.6

Steps to reproduce

Tell us how to reproduce this issue. $ composer install

 - Upgrading lcobucci/jwt (4.2.1 => 4.3.0): Extracting archive
  - Installing tymon/jwt-auth (2.0.0): Extracting archive
Generating autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover

   Tymon\JWTAuth\Exceptions\JWTException 

  Secret is not set.

  at vendor/tymon/jwt-auth/src/Providers/JWT/Lcobucci.php:244
    240▕             return $this->getKey($privateKey, $this->getPassphrase() ?? '');
    241▕         }
    242▕ 
    243▕         if (! $secret = $this->getSecret()) {
  ➜ 244▕             throw new JWTException('Secret is not set.');
    245▕         }
    246▕ 
    247▕         return $this->getKey($secret);
    248▕     }

      +35 vendor frames 
  36  app/Exceptions/Handler.php:72
      Illuminate\Auth\AuthManager::__call()

      +3 vendor frames 
  40  [internal]:0
      Illuminate\Foundation\Bootstrap\HandleExceptions::Illuminate\Foundation\Bootstrap\{closure}()
Script @php artisan package:discover handling the post-autoload-dump event returned with error code 1

Expected behaviour

Tell us what should happen

Actual behaviour

Tell us what happens instead

trinvh commented 1 year ago

Same issue

KhaledLela commented 1 year ago

This issue was php artisan package:discover requires existence of .env, That fix the issue for me.

But for me it doesn’t make sense specially during pipeline deployment!

jonkerw85 commented 1 year ago

This probably won't get fixed. You can solve this by running composer as follow (on Linux) JWT_SECRET=DummySecret composer install