laravel / passport

Laravel Passport provides OAuth2 server support to Laravel.
https://laravel.com/docs/passport
MIT License
3.28k stars 777 forks source link

Passport install prompt #1729

Closed Tahiaji closed 6 months ago

Tahiaji commented 6 months ago

Passport Version

12.0.0

Laravel Version

11.0.5

PHP Version

8.2

Database Driver & Version

8.0

Description

After updating the package, the command passport:install now has two prompts for user input.

image

This command is used in deployments and tests and there is no possibility of a manual response. This change is not mentioned in the upgrade guide.

How can I now execute this command without user interaction?

Steps To Reproduce

php artisan passport:install
Tahiaji commented 6 months ago

Example case of usage in tests https://stackoverflow.com/a/50243105/1202097

nunomaduro commented 6 months ago

The passport:install command was not meant to be run multiple times. Meaning, it should not be part of a deployment process or run before tests.

Typically, that command should run only once per project locally (because it publishes migrations, etc). This change, of adding prompts to this install command is not mentioned in the upgrade guide because that command only serves 'fresh' new Laravel applications.

Tahiaji commented 6 months ago

Even if such behavior was not intended - there are many places where it can be used without user interaction.

And even if this is expected behavior, the change in the operating logic is extremely significant and it would be nice to at least mention it in the change history

MarcEspiard commented 4 months ago

Hey, just thought I'd mention that this also broke my tests during the upgrade from 10 to 11. It would be nice to at least mention it in the upgrade guide or the changelog.

Fixed it by publishing the passport migrations and replacing the passport:install call in my test seeder by:

Artisan::call('passport:keys');
Artisan::call('passport:client', ['--personal' => true, '--name' => config('app.name') . ' Personal Access Client']);
$provider = in_array('users', array_keys(config('auth.providers'))) ? 'users' : null;
Artisan::call('passport:client', ['--password' => true, '--name' => config('app.name') . ' Password Grant Client', '--provider' => $provider]);