3 namespace App\Providers;
6 use Illuminate\Support\Facades\Auth;
7 use Illuminate\Support\Facades\Gate;
8 use Illuminate\Support\ServiceProvider;
10 class AuthServiceProvider extends ServiceProvider
13 * Register any application services.
17 public function register()
23 * Boot the authentication services for the application.
27 public function boot()
29 // Here you may define how you wish users to be authenticated for your Lumen
30 // application. The callback which receives the incoming request instance
31 // should return either a User instance or null. You're free to obtain
32 // the User instance via an API token or any other method necessary.
34 Auth::viaRequest('api', function ($request) {
35 if ($request->input('api_token')) {
36 return User::where('api_token', $request->input('api_token'))->first();