app/Providers/AuthServiceProvider.php
/**
     * Boot the authentication services for the application.
     *
     * @return void
     */
Boot the authentication services for the application.
@return void
Boot the authentication services for the application . @return void
public function boot()
    {
        $this->app['auth']->viaRequest('api', function ($request) {
            if ( getallheaders()['Authorization']) {
                $key = getallheaders()['Authorization'];
                try {
                    $user = User::where('key', $key)->first();
                } catch (\Illuminate\Database\Eloquent\ModelNotFoundException $e) {
                    $user = null;
                }
                return $user;
            }
        });
    }
public function boot ( ) { $ this -> app [ 'auth' ] -> viaRequest ( 'api' , function ( $ request ) { if ( getallheaders ( ) [ 'Authorization' ] ) { $ key = getallheaders ( ) [ 'Authorization' ] ; try { $ user = User :: where ( 'key' , $ key ) -> first ( ) ; } catch ( \ Illuminate \ Database \ Eloquent \ ModelNotFoundException $ e ) { $ user = null ; } return $ user ; } } ) ; }
Boot the authentication services for the application.
Boot the authentication services for the application .
// Here you may define how you wish users to be authenticated for your Lumen // application. The callback which receives the incoming request instance // should return either a User instance or null. You're free to obtain // the User instance via an API token or any other method necessary.