mathewberry / tokenizer
A very lightweight token system for micro-services
Installs: 770
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 1
Open Issues: 0
pkg:composer/mathewberry/tokenizer
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.