Laravel JWT Redis allows JWT-authenticated users to be stored and managed in Redis with their roles, permissions, statuses, and other data. It works together with tymondesigns/jwt-auth and spatie/laravel-permission package under the hood.
At the core of the package is the model
JWTRedisHasRoles and works in the background—it functions almost identically to Laravel session authentication. Check out the readme for nuances in how this package handles auth.
You configure auth with the following guard and provider provided by the package:
'guards' => [ 'api' => [ 'driver' => 'jwt_redis_guard', 'provider' => 'users' ], ], 'providers' => [ 'users' => [ 'driver' => 'jwt_redis_user_provider', 'model' => App\User::class, /* Your User Model */ ], ],
Here’s a few examples of route usage:
Route::get("/example", "ExampleController@example")->middleware('role:admin|user'); Route::get("/example", "ExampleController@example")->middleware('permissions:get-user|set-user'); Route::get("/example", "ExampleController@example")->middleware('role_or_permission:admin|get-user');
At the time of writing, this package is new, so I’d encourage you to check out the source code and contribute if you see anything you’d like to help. Be sure to consider all the typical tradeoffs of using a package before verifying its usage, especially around something like authentication.
You can learn more about this package, get full installation instructions, and view the source code on GitHub at sametsahindogan/laravel-jwtredis.Filed in: News / packages
- Senior Full Stack Engineer - Laravel
- Laravel partner seeks Lead Developer
Kirschbaum Development Group
- Senior Programmer **Immediate Opening** (send resume to firstname.lastname@example.org)
- Senior Developer/Team Leader
- Senior Backend Software Engineer- Laravel
Join 31,000+ others and never miss out on new tips, tutorials, and more.
Laravel Jobs and Queue 101: How to run your workers on your production server
In this tutorial, we will explore how we are going to deploy our analytics app in two different ways, the first one a…
Collision PHPUnit Listener With Laravel
Let’s look at enabling Collision’s PHPUnit listener in Laravel.