wivaku
146
5
Laravel

skip auth when using certain route prefixes

Posted 1 month ago by wivaku

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}', '[email protected]')
    ->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}', '[email protected]')
    ->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.

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.