Download the PHP package mr-timofey/laravel-simple-tokens without Composer
On this page you can find all versions of the php package mr-timofey/laravel-simple-tokens. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mr-timofey/laravel-simple-tokens
More information about mr-timofey/laravel-simple-tokens
Files in mr-timofey/laravel-simple-tokens
Package laravel-simple-tokens
Short Description Simple token and cache based user authentication and authorization
License MIT
Informations about the package laravel-simple-tokens
Simple token and cache based user authentication and authorization.
You are tired of the mind-blowing, unnecessarily complex Passport OAuth? You want something configurable, manageable and simple? Then that is just the package you need.
Features
- Fully Eloquent compatible auth driver
- Cache based token authorization with configurable TTL
- Additional query restriction configuration per each provider using simple
where/where in
clauses or model scopes (for example, you can restrict authorization only for particular user roles) - Controller trait to maintain authentication/authorization/logout logic for your application out-of-the-box (but you still have to define controller and routes)
- Multiple independent guards support
Requirements
- PHP 7.1
- Laravel 5
Install
For Laravel <= 5.4 add MrTimofey\LaravelSimpleTokens\ServiceProvider
to your app.providers
config.
Usage
Set your auth.providers.users.driver
(replace users
to other provider if needed) config to simple
.
Any authorized HTTP request must contain Authorization: Bearer {api_token}
header.
Configure a guard (api
by default) if necessary.
Use MrTimofey\LaravelSimpleTokens\AuthenticatesUsers
trait with your auth controller. This trait adds methods:
-
authenticate - authenticates user with login/email/password/remember_token and returns JSON response which includes:
This method generates
api_token
and puts it to cache withcache()->set('prefix:' . $token, $user_id, $ttl)
. Also regenerates userremember_token
. TTL is configured insimple_tokens.ttl
. - logout - deletes
api_token
from cache. - user - returns user data JSON.
Also you can define a $guard
class field to use any guard other than default one (api
).