-
Notifications
You must be signed in to change notification settings - Fork 658
Multi-tenancy Invalid signature on Private channels #184
Comments
Ive manually overridden the response from the auth route with: Route::post('broadcasting/auth', function () {
$response = Broadcast::auth(request());
$key = app(\Hyn\Tenancy\Environment::class)->tenant()->key;
$response['auth'] = $key.$response['auth'];
return $response;
}) And still receiving the InvalidSignatureException so the key not being set wasn't the issue. Im still at a loss as to why the signature is invalid. Any help would be greatly appreciated. Thanks |
Ok so it looks to be that the pusher instance used for generating the auth response has an empty config. Where about is this pusher instance set? This may be due to the config being set in the middleware being done later down the stack from where this instance is set. |
Solved!
namespace App\Providers;
use Hyn\Tenancy\Environment;
use Illuminate\Broadcasting\BroadcastManager;
use Illuminate\Support\ServiceProvider;
use Illuminate\Contracts\Broadcasting\Factory as BroadcastingFactory;
use Illuminate\Contracts\Broadcasting\Broadcaster as BroadcasterContract;
class BroadcastServiceProvider extends ServiceProvider
{
/**
* Register the service provider.
*
* @return void
*/
public function boot()
{
if ($website = app(Environment::class)->tenant()) {
config([
'broadcasting.connections.pusher' => [
'driver' => 'pusher',
'key' => $website->key,
'secret' => $website->secret,
'app_id' => $website->id,
'options' => [
'encrypted' => true,
'host' => '127.0.0.1',
'port' => 6001,
'scheme' => 'http',
'auth_key' => $website->key,
],
],
]);
}
$this->app->singleton(BroadcastManager::class, function ($app) {
return new BroadcastManager($app);
});
$this->app->singleton(BroadcasterContract::class, function ($app) {
return $app->make(BroadcastManager::class)->connection();
});
$this->app->alias(
BroadcastManager::class, BroadcastingFactory::class
);
}
} Basically resolves the host name and applies the config accordingly before the Pusher instance is created in container. Very much did a rubber duck on this one... |
@SolStis86 did you have any luck getting this to work with queued notifications? It appears the queue worker is not getting the proper pusher settings applied. |
Hello, I've tried this with https://tenancyforlaravel.com/ lib. But I'm unable to get it working. If I overwrite BroadcastServiceProvider , I got 403 on broadcasting/auth call. Any idea? Regards |
I've been able to get it working... Instead overwrite BroadcastServiceProvider, I've mad a bootstrapper that achieve the same goal. Hope that helps somebody
|
@scramatte I tried your code but still when I try to connect to a private channel the I created the Is there anything that I am missing here? |
@scramatte please can you explain more your code and the files that you changed or import |
When receiving and authentication payload from a private or presence channel, the payload should be in the format
key:signature
. However, whats actually returned from the auth endpoint is something like this:Note that only the signature is present, not the key.
From what i can see the auth string is generated in
Pusher\Pusher@socket_auth
(Ln:735) however it seems that the auth_key isnt being set ready for the response.Im using a custom AppProvider that retrieves the config on a per tenant basis and the overrides the config for the pusher connection through middleware on every request.
My app provider is as follows:
And the middleware:
Anyone else ran in to this issue and solved it? Thanks
The text was updated successfully, but these errors were encountered: