You can extend the AuthenticateWithBasicAuth and use your desired field:
<?php namespace App\Http\Middleware;
use Closure;
use Illuminate\Contracts\Routing\Middleware;
use Illuminate\Auth\Middleware\AuthenticateWithBasicAuth;
class MyBasicAuth extends AuthenticateWithBasicAuth implements Middleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
// pass the desired field as the argument
return $this->auth->basic('username') ?: $next($request);
}
}
And then update you app\Http\Kernel.php file:
protected $routeMiddleware = [
'auth' => 'App\Http\Middleware\Authenticate',
'auth.basic' => 'App\Http\Middleware\MyBasicAuth', // UPDATED!!!
'guest' => 'App\Http\Middleware\RedirectIfAuthenticated',
];
EDIT: corrected the extends in the middleware