A package by Christian Braybrooke
Requires
- firebase/php-jwt: ^5.4
Requires (Dev)
- laravel/framework: ^8
- orchestra/canvas: ^6.4
Suggests
None
Provides
None
Conflicts
None
Replaces
None
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\AuthenticatesWithAuthServertrait to yourUsermodel, this contains a few methods that help create new users. -
In your
.envfile add anOAUTH_AUTH_SERVER_API_ENDPOINTentry, 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_KEYentry, 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.phpfile - 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