There is no license information available for the latest version (0.0.3) of this package.

A package by Christian Braybrooke

0.0.3 2023-04-08 11:51 UTC

This package is auto-updated.

Last update: 2024-04-10 18:40:03 UTC


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

  1. Add the ChrisBraybrooke\JWT\Traits\AuthenticatesWithAuthServer trait to your User model, this contains a few methods that help create new users.

  2. In your .env file add an OAUTH_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 a OAUTH_PUBLIC_KEY entry, this is your public key that is being used on the authentication server and will allow us to validate incoming JWTs.

  3. 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