A package by Christian Braybrooke
Requires
- firebase/php-jwt: ^5.4
Requires (Dev)
- laravel/framework: ^8
- orchestra/canvas: ^6.4
README
For use with an authentication server using Laravel Passport. This package will read the incoming JWT and authenticate the user.
Installation
composer require chrisbraybrooke/jwt
Setup
-
Add the
ChrisBraybrooke\JWT\Traits\AuthenticatesWithAuthServer
trait to yourUser
model, this contains a few methods that help create new users. -
In your
.env
file add anOAUTH_AUTH_SERVER_API_ENDPOINT
entry, this is the base api url on your authentication server, and will be used to pull the users information in when creating a new user. You also need aOAUTH_PUBLIC_KEY
entry, this is your public key that is being used on the authentication server and will allow us to validate incoming JWTs. -
Finally, you will need to change the api guard driver in your
config/auth.php
file - see below.
'api' => [
'driver' => 'jwt', // --> We have created a driver called jwt, make sure your driver is set to this.
'provider' => 'users',
'hash' => false,
]
Config
You can publish the config file be running php artisan vendor:publish --tag=jwt-config