Skip to content

[11.x] Rewrite Laravel Passport installation #9457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 5 additions & 21 deletions passport.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,17 @@ However, if you are attempting to authenticate a single-page application, mobile
<a name="installation"></a>
## Installation

To get started, install Passport via the Composer package manager:
You may install Laravel Passport via the `install:api` Artisan command:

```shell
composer require laravel/passport
php artisan install:api --passport
```

Next, you should execute the `passport:install` Artisan command. This command will publish and run the database migrations necessary for creating the tables your application needs to store OAuth2 clients and access tokens:
This command will publish and run the database migrations necessary for creating the tables your application needs to store OAuth2 clients and access tokens. The command will also create the encryption keys required to generate secure access tokens.

```shell
php artisan passport:install
```

Additionally, the `passport:install` command will create the encryption keys required to generate secure access tokens, as well as the "personal access" and "password grant" clients, which will be used to generate access tokens.

> [!NOTE]
> If you would like to use UUIDs as the primary key value of the Passport `Client` model instead of auto-incrementing integers, please install Passport using [the `uuids` option](#client-uuids).
Additionally, this command will ask if you would like to use UUIDs as the primary key value of the Passport `Client` model instead of auto-incrementing integers.

After running the `passport:install` command, add the `Laravel\Passport\HasApiTokens` trait to your `App\Models\User` model. This trait will provide a few helper methods to your model which allow you to inspect the authenticated user's token and scopes. If your model is already using the `Laravel\Sanctum\HasApiTokens` trait, you may remove that trait:
After running the `install:api` command, add the `Laravel\Passport\HasApiTokens` trait to your `App\Models\User` model. This trait will provide a few helper methods to your model which allow you to inspect the authenticated user's token and scopes:

<?php

Expand Down Expand Up @@ -108,15 +101,6 @@ Finally, in your application's `config/auth.php` configuration file, you should
],
],

<a name="client-uuids"></a>
#### Client UUIDs

You may also run the `passport:install` command with the `--uuids` option present. This option will instruct Passport that you would like to use UUIDs instead of auto-incrementing integers as the Passport `Client` model's primary key values. After running the `passport:install` command with the `--uuids` option, you will be given additional instructions regarding disabling Passport's default migrations:

```shell
php artisan passport:install --uuids
```

<a name="deploying-passport"></a>
### Deploying Passport

Expand Down