HTTP Basic Authentication: Stateless HTTP Basic Authentication

<?php

namespace App\Http\Middleware;

use Illuminate\Support\Facades\Auth;

class AuthenticateOnceWithBasicAuth
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, $next)
    {
        return Auth::onceBasic() ?: $next($request);
    }

}
Route::get('api/user', function () {
    // Only authenticated users may enter...
})->middleware('auth.basic.once');

HTTP Basic Authentication: Stateless HTTP Basic Authentication — Structure map

Clickable & Draggable!

HTTP Basic Authentication: Stateless HTTP Basic Authentication — Related pages: