middleware hasValidSignature
<?php
//app/Http/Middleware/HasValidSignature.php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
class HasValidSignature
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle(Request $request, Closure $next)
{
if (! $request->hasValidSignature())
{
abort(401);
}
return $next($request);
}
}
//--------------------------------------------------------
//app/Http/Kernel.php
protected $routeMiddleware = [
//...
'signed_url' => \App\Http\Middleware\HasValidSignature::class,
];
//--------------------------------------------------------
//routes/web.php
Route::prefix('signed_url')->middleware(['signed_url'])->group(function () {
Route::get('/my_email_url', [MyController::class, 'methodEmailUrl'])->name('my_email_url');
});