onecentlin / laravel-adminer

Adminer database manager for Laravel 5+
MIT License
243 stars 45 forks source link

my session from another guard not working #20

Open dragonplunker opened 2 years ago

dragonplunker commented 2 years ago

i use auth as middleware but not working, whenever i access adminer route it keep kick me and cannot let me in

onecentlin commented 2 years ago

@dragonplunker You may setup your own middleware groups

Please check v5.4.0 readme (https://github.com/onecentlin/laravel-adminer/tree/5.4.0)

Vinze commented 1 year ago

I've had the same issue when using only the default 'auth' middleware. In my case I also had to apply the 'web' middleware to the config/adminer.php file:

'middleware' => ['web', 'auth'],
onecentlin commented 1 year ago

Hi @Vinze

If you are not using global middleware including \Illuminate\Session\Middleware\StartSession::class

I'll recommend you use middlewareGroups, you may adjust to fit your needs.

Checkout README - Setup Access Permission (Middleware)

config/adminer.php

'middleware' => 'adminer',

app/Http/Kernel.php

protected $middlewareGroups = [
    ...
    'adminer' => [
        \App\Http\Middleware\EncryptCookies::class,
        \Illuminate\Session\Middleware\StartSession::class,

        // Laravel default authentication (default protection)
        \Illuminate\Auth\Middleware\Authenticate::class,
    ],
];
schonhose commented 1 year ago

Hi @onecentlin,

I have updated from the version from Miroc to your version. I have a question regarding middleware. In the old setup I used:

Route::middleware('role:Administrator')->group(function () {
    /*
    |--------------------------------------------------------------------------
    | ADMINER
    |--------------------------------------------------------------------------
    */
    Route::any('adminer', [\Miroc\LaravelAdminer\AdminerAutologinController::class, 'index']);
});

That way it required the role of administrator to work. I am not sure how I can achieve the same thing with your setup. Can you provide some guidance?