hans-thomas / sphinx
JSON web token driver for laravel
v1.1.2
2024-09-21 08:55 UTC
Requires
- php: ^8.1
- lcobucci/jwt: ^4.1
- matomo/device-detector: ^6.0
Requires (Dev)
- hans-thomas/horus: ^1.0
- nunomaduro/collision: ^7.0
- orchestra/testbench: ^8.0
README
Sphinx is a feature reach Jwt-based authentication system that make zero queries to database during authorization.
- Customizable
- Integration support with Horus
- Based on Jwt
- Two layers of encryption
- Refresh token support
- Logged-in users in one account limitation
Installation
Install the package via composer.
composer require hans-thomas/sphinx
Then, publish config file.
php artisan vendor:publish --tag sphinx-config
Setting up
Model
First, use Hans\Sphinx\Traits\SphinxTrait
trait on your model and then implement the abstract methods. Next, inside
your model, make sure to call the hooks
method in your booted
method.
use SphinxTrait, SphinxTrait {
SphinxTrait::hooks as private sphinxHooks;
}
protected static function booted() {
self::sphinxHooks();
}
Auth configuration
First of all, define the provider.
'providers' => [
// ...
'sphinxUsers' => [
'driver' => 'sphinx',
'model' => App\Models\User::class,
],
// ...
],
Then, add your guard.
'guards' => [
// ...
'jwt' => [
'driver' => 'sphinxJwt',
'provider' => 'sphinxUsers',
],
// ...
],
And finally, you can set the jwt
guard as default.
'defaults' => [
// ...
'guard' => 'jwt',
// ...
],
All sets. enjoy!
Read more about Sphinx in documentation website.
Contributing
- Fork it!
- Create your feature branch: git checkout -b my-new-feature
- Commit your changes: git commit -am 'Add some feature'
- Push to the branch: git push origin my-new-feature
- Submit a pull request ❤️