Skip to content

Livewire update does not apply middlewares set up in the configuration #277

@Vinksyunit

Description

@Vinksyunit

Pulse Version

v1.0.0-beta9

Laravel Version

10.40.0

PHP Version

8.3.1

Livewire Version

3.3.5

Database Driver & Version

postgres:16-alpine3.19 (Docker linux amd/64)

Description

Working on a solution with two different user's guards, we notice that the POST /livewire/update requests does not use the intended guard for pulse. Indeed, the auth:other_guard middleware is set up in the Pulse config file, but it seems that the POST livewire/update request does not use the middleware in the pulse config and instead, only the web middleware, thus using the default user guard.

Steps To Reproduce

  1. Set up a second Auth provider (admin_session in this example)

  2. Add another user guard in config/auth.php.

<?php

use App\Models\User;

return [
    'defaults' => [
        'guard' => 'web',
        'passwords' => 'users',
    ],

    'guards' => [
        'web' => [
            'driver' => 'session',
            'provider' => 'users',
        ],
        'admin' => [
            'driver' => 'admin_session',
            'provider' => 'users',
        ],
    ],
   // ...
}
  1. Adapt pulse config (config/pulse.php) to use the intended guard
use Laravel\Pulse\Http\Middleware\Authorize;

return [
    'middleware' => [
        'auth:admin',
        'web',
        Authorize::class,
    ],
]
  1. Connect to both user systems, and notice that the main pulse page uses the admin guard as intended, whereas POST livewire/update uses the default webguard. It can be easily noticed using the viewPulse Gate.
use Illuminate\Support\Facades\Gate;
use App\Models\User;

Gate::define('viewPulse', function (?User $user) {
    if ($user->login !== 'theoneconnectedtotheadmin') {
       throw new \Exception('Wrong one');
    }
    return true;
});

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions