Join GitHub today
Middleware: JWT Auth #1
Trying to implement the Slim JWT Auth as middleware but really struggling getting this work with your skeleton.
Creating a route for generating a token is fine. The only problem is adding the middleware correctly in order so validate route requests.
All Slim JWT auth tutorials and documentations are using a different approach of setting up middlewares. That’s why I have no idea how to solve this with your skeleton, especially the part inside the Authentication Middleware class: https://gist.github.com/flowdee/799203ac858e060826892541bc0110f5
Any idea how to get this working?
Sorry for the delay...
You need to call the JWT Class directly from the
--- slim3/config/middlewares.php --- <?php return [ \App\Middlewares\CorsMiddleware::class, (new Tuupola\Middleware\JwtAuthentication([ "secure" => false, "path" => "/api", "secret" => "supersecretkeyyoushouldnotcommittogithub", ])), ];
In this example, all the routes beginning with
Please, try it and give some feedback.