Package Data | |
---|---|
Maintainer Username: | ArronKing |
Maintainer Contact: | arron.king@arrow-web.dev (Arron King) |
Package Create Date: | 2016-03-03 |
Package Last Update: | 2024-07-08 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-23 03:00:10 |
Package Statistics | |
---|---|
Total Downloads: | 3,158 |
Monthly Downloads: | 87 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 3 |
Total Forks: | 0 |
Total Open Issues: | 1 |
A simple method to authorise users in Laravel via a JWT - http://jwt.io
This package is in early development, you are more than welcome to use it. But expect rough edges.
The package doesn't implement a lot of the stuff provided by core Laravel auth - such as registration, password recovery and remember me tokens. Just because it's not applicable to JWT.
composer require arrow-web-sol/laravel-jwt-auth
After updating composer, add the ServiceProvider to the providers array in config/app.php:
Arrow\JwtAuth\ServiceProvider::class,
Then run
php artisan vendor:publish --provider="Arrow\JwtAuth\ServiceProvider"
That creates a jwt-config.php config file, in here you can change the signing method used, hash used, key (hmac only) and the public key (rsa and ecdsa). The key or public key is used to verify the JWT.
Let's then change the default auth method, edit config/auth.php
'defaults' => [
'guard' => 'jwt',
Finally, in your controller / routes, you can now call:
$this->middleware('auth');
This will take a JWT from the request header, if it's signature is verified then the user is 'authenticated'.
jwt-config.php
contains the same signature/hash/key as used on http://jwt.io