mathewberry / tokenizer
This package is abandoned and no longer maintained.
No replacement package was suggested.
A very lightweight token system for micro-services
0.2.4
2017-08-09 13:16 UTC
Requires (Dev)
- illuminate/console: ^5.4
README
A very lightweight token system for micro-services
Installation Lumen
Service Provider
Remove
$app->register(App\Providers\AuthServiceProvider::class);
Add
$app->register(Mathewberry\Tokenizer\TokenizerServiceProvider::class);
Route Middleware
Remove
'auth' => App\Http\Middleware\Authenticate::class,
Add
'auth' => Mathewberry\Tokenizer\Middleware\Authenticate::class,
Generate a new token
php artisan token:generate
Implement a token
Copy your generated token into a new key in your .env
called API_TOKEN
How to use
When ever your make a call just pass the header api_token
and the value is the value of the token in your .env
.
Make sure your route or controller is using the auth
middleware.
Example
class DomainController extends Controller { public function __construct() { $this->middleware(['auth']); } public function index() { $domains = Domain::get(); return response($domains, 200); } }
It's that simple, your micro-service is now that little bit more secure.