laravel-websockets icon indicating copy to clipboard operation
laravel-websockets copied to clipboard

Multi-Tenancy with Private Channels

Open jandante opened this issue 4 years ago • 1 comments

Hi,

In a multi-tenancy environment I have laravel-websockets running on a primary server. To let another app on a different server use this service I've created a second app in config/websockets.php.

I can connect to it from my 'other app'. However when trying to access a private channel I need to authenticate. To accomplish that I do the following on the primary server:

  1. Create seperate routes for authentication. In BroadcastServiceProvider.php added: Broadcast::routes(['prefix' => 'device', 'middleware' => ['client', 'auth.guest']]);
  2. The client middleware is to allow machine to machine login
  3. The auth.guest middleware is logging in a dummy user because Laravel requires a $user for Private/Presence channels

On the 'client app' I define the correct information to Echo (authEndPoint & auth information) so it can connect to the correct url for authentication. Also in config/broadasting.php I have the correct information for the app I want to connect with. It's also connecting with the correct app so that's OK.

Authenticating is succesfull from the app but it returns an auth key with the wrong APP ID.

How can I instruct the primary server to return auth key for another app when authenticating via the authEndPoint for this application?

Because now I get an error 'InvalidSignature' in my attempt to subscribe to the private channel. Seems logical since this is probably a signature for the 'main' websockets application.

Hope I'm in the right place here and my question is clear.

Best regards

jandante avatar Apr 06 '21 21:04 jandante

I have same issue, beside if i tried to skip it Im facing that my default app configuration never change while pushing. @mpociot

mohamed-foly avatar Oct 12 '21 02:10 mohamed-foly

@jandante have you found a solution?

cbrhex avatar Dec 22 '22 00:12 cbrhex

@jandante have you found a solution?

Not really.

I'm using one websockets app for all my websockets needs :). Would love to be able to split them but when in need for authentication I always run into this.

I might be doing something wrong but since you are experiencing the same I suppose my findings are correct.

jandante avatar Dec 23 '22 08:12 jandante