I'm attempting to integrate some authentication into my Lumen API and reading through the documentation it seems that you need a DB and a User model as stated below;
Auth::viaRequest('api', function ($request) {
// Return User or null...
});
But what if I just want to return true after performing a check of the API token?
This is a grab from AuthServiceProvider.php
Auth::viaRequest('api', function ($request) {
if ($request->input('api_token')) {
return User::where('api_token', $request->input('api_token'))->first();
}
});
Here they are performing a DB query on the User model to determine if the api_token matches what the User has in their DB row.
How can I do something like this;
Auth::viaRequest('api', function ($request) {
if ($request->input('api_token') == env('APP_KEY')) {
// what should i return here?
} else {
return null;
}
});
Also here they're checking a parameter passed with the request. How can I check the request header because that's how I'll be sending the api_token