That's what auth means, logged in.
Any routes not requiring it just don't group under that middleware.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Pretty new to Laravel (5.8).
Is it possible to disable authentication for specific (signed) routes / route groups? The use case: create+use share links that don't require login.
I would like to have signed routes with prefix (e.g. "share/order/1234?signature=xyz") that can be accessed without logging in.
My controller has __construct() with $this->middleware('auth');
And I grouped the share routes:
// regular route (login required)
Route::get('timeline/{date}', 'MapController@timelineDate')
->name('timeline.date')
...
// route group for shared versions of the route --- should not require login
Route::prefix('share')->name('share.')->group(function() {
// http://.../share/timeline/2019-04-21?signature=xyz --> share.timeline.date
Route::get('timeline/{date}', 'MapController@timelineDate')
->name('timeline.date');
...
});
Suggestions on how to achieve this?
I looked at adding except to the controller construct, but was not sure what to put there. Was looking if I can / need to modify the route group.
Update: expanded the routes details with more complete example of current situation.
And the other solution. Here I let the controller check the request's route prefix to decide if auth middleware is needed.
Http/Controllers/MapController.php
public function __construct() {
if (request()->route()->getPrefix() !== '/share') $this->middleware('auth');
}
public function timelineDate($date) {
...
}
routes/web.php
// regular route (login required)
Route::get('timeline/{date}', 'MapController@timelineDate')
->name('timeline.date')
// route group for shared versions of the route
// middleware: make sure they are correctly signed
// calling regular version of the method (timelineDate)
Route::prefix('share')->name('share.')->middleware(['signed'])->group(function() {
Route::get('timeline/{date}', 'MapController@timelineDate')
->name('timeline.date');
});
// in blade, e.g.:
// app('url')->signedRoute('share.timeline.date',['2019-04-21']);
// http://.../share/timeline/2019-04-21?signature=xyz --> share.timeline.date --> MapController@timelineDate
Please or to participate in this conversation.