https://odan.github.io/2019/12/02/slim4-oauth2-jwt.html
If you like the article, please click on the ⭐ button.
https://odan.github.io/2019/12/02/slim4-oauth2-jwt.html
If you like the article, please click on the ⭐ button.
@odan that's very pertinent! I think easily worth mentioning in the article. Below where you link to tuupola/slim-jwt-auth
or somewhere near.
@samuelgfeller Yes, thanks. I will add it to the article.
Hi @samuelgfeller My approach is more Middleware and Routing based while the
tuupola/slim-jwt-auth
approach uses an array to configure the different routes. For me the array based protection is not so good to maintain in the long run, for example when you add or change route paths you may miss some routes and suddenly it's unprotected. I prefer to explicitly add theJwtAuthMiddleware
to specific routes or route groups inroutes.php
. You can open theroutes.php
file see what is protected. My approach also makes it easier to fetch users from the database (see TokenCreateAction) instead of loading it from a fixed array. I think you have to decide what's better for your specific use case.