Basic JWT auth middleware

Rocky Dhawan
Sep 5, 2018 · 1 min read

Sometime we don’t want to use built in middleware for authenticate our route and validate if it is having valid authorization bearer or not.To solve this problem i have created a very basic middleware to serve my purpose of not depending on the default one rather use my own customized one.

We can add middleware class in our controller like this way or we can add in the route also:

public function __construct()
{
$this->middleware(JWTauth::class);
}
Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade