Seems like you're searching for this: https://laravel.com/docs/6.x/authentication#adding-custom-user-providers
Here is the example of how it could look: https://github.com/cesg/api-user-provider/blob/master/src/ApiUserProvider.php
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi,
I'm building a Laravel 5.8 application to be the front-end to an external API written in Go. I POST a user/pass to the API which then responds with either HTTP/200 and a JSON Token (JWT) or an HTTP/401 to signal the credentials are invalid.
I would like to use Laravel's built-in auth mechanism (or anything which makes this work really) to be able to create pages and routes only for logged in users. It seems a lot of work to reinvent the wheel.
Any idea how I go about doing that? I guess I need a custom auth driver but can't find much reliable information for that.
[TLDR] Basically I need some code which checks if the API returns an HTTP/200, stores the token somewhere (session/cookie [but not database]) and then provide's some way to easily (virtually) log users into the Laravel app. That way I can create pages for logged in users only.
Thanks!
Please or to participate in this conversation.