Signed URLs let Laravel prove a link was issued by your app and optionally expires after a few minutes. They are ideal for “confirm unsubscribe”, “download this export”, or “finish setup” flows sent by email.
When they help
- You email a user a one-off action (verify, unsubscribe, reset step) and don’t want a guessable ID.
- You expose a short-lived download URL without a login wall.
- You need idempotent GET links (still validate side effects in the controller).
1. Named route
// routes/web.php
Route::get('/exports/{export}', [ExportController::class, 'download'])
->middleware('signed')
->name('exports.download');
2. Generate a signed URL
use Illuminate\Support\Facades\URL;
$url = URL::temporarySignedRoute(
'exports.download',
now()->addMinutes(30),
['export' => $export->id]
);
Mail or JSON this $url. After 30 minutes Laravel’s signed middleware returns 403 automatically.
3. Permanent signature (no expiry)
$url = URL::signedRoute('exports.download', ['export' => $export->id]);
Use sparingly—time-bounded links reduce leak risk if the message is forwarded.
4. Validate inside the controller
Signing proves integrity, not authorization. Still check the logged-in user (if any) or record state: e.g. export belongs to this account, not consumed twice, etc.
5. APP_KEY warning
Signatures are derived from APP_KEY. Rotating the key invalidates every outstanding signed URL. Plan key rotation with that in mind.
Takeaway
For “click this link once in the next hour” workflows, temporarySignedRoute plus ->middleware('signed') is the simplest Laravel-native pattern—no extra token table unless you need revocation before expiry.