laravel

Laravel Sanctum optional route authentication and guard selection

Posted by Danny Herran on Jan 18, 2022 in Backend | No comments
Laravel Sanctum Logo

By default, Laravel Sanctum token authentication will either completely block access to protected routes or allow it at the expense of not being able to detect if the user is logged in. However, there are valid scenarios whereby a route should be accessible to guests and at the same time allow bearer token authentication. One of the many ways to achieve this is by changing the default guard assigned to the /api route group.

Laravel reCAPTCHA v2 Middleware in 3 minutes

Posted by Danny Herran on Nov 5, 2020 in Backend | No comments
Laravel reCAPTCHA

I needed to add reCAPTCHA v2 to a couple of forms and most of the results on Google pointed to these large Composer packages that were simply too much.

This article will cover how to do create a new Laravel Middleware to validate reCAPTCHA v2 requests with just a few lines of code.

Time to read, implement, QA and deploy to production: 3.141592 minutes.

Laravel Fractal pagination with simplePaginate

Posted by Danny Herran on Mar 8, 2019 in Backend | No comments
Laravel Fractal

By default Fractal has native support for Laravel::paginate. Those using simplePaginate() have to resort to either using Fractal Cursors or build their own adapter. In this post, we are going to quickly build an adapter that fully supports Laravel::simplePaginate.