Skip to content
This repository was archived by the owner on Oct 19, 2020. It is now read-only.

mathewberry/tokenizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tokenizer

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.

About

A very lightweight token system for micro-services

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages