Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

amk's avatar
Level 4

How to change authorization in UniSharp/laravel-filemanager?

I have been change lfm.php

'middlewares'              => ['auth:admin'],

But it does't not work.

Please,any other idea or suggestion?

0 likes
6 replies
bobbybouwmann's avatar

You also need to add the web middleware, otherwise there is no session to check the authentication against

'middlewares'  => ['web', 'auth:admin'],

Alternatively you can just register the routes yourself with a proper middleware group:

Route::group(['middleware' => 'auth:admin'], function () {
    Route::get('/laravel-filemanager', '\UniSharp\LaravelFilemanager\Controllers\LfmController@show');
    Route::post('/laravel-filemanager/upload', '\UniSharp\LaravelFilemanager\Controllers\UploadController@upload');
    // list all lfm routes here...
});

Documentation: https://github.com/UniSharp/laravel-filemanager#security

bobbybouwmann's avatar

Doesn't work for me is a little bit unclear... Are you logged in with a user that falls under the admin guard?

amk's avatar
Level 4

I login as admin,it does't not work.When I logged in with a user,it work well. I'am using multiple authentication guards in my project. @bobbybouwmann Is there anyway to define multiple authentication in filemanager?

bobbybouwmann's avatar

IDK man, I just told you what I can find in the books. Something is probably going wrong on your end with the extra added guard!

1 like
emmanero90's avatar

In Route, Set like this

Route::group(['prefix' => 'laravel-filemanager', 'middleware' => ['auth:admin']], function () {

    \UniSharp\LaravelFilemanager\Lfm::routes();
});

Then go to AppServiceProvider, Inside the boot metod, add

// Force to use admin guard for filemanager
        if (str_starts_with(Request::path(), 'filemanager')) {
            Auth::shouldUse('admin');
        }	


//remember to include at the top:

use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Request;

Please or to participate in this conversation.