tlaverdure / laravel-echo-server

Socket.io server for Laravel Echo
MIT License
2.64k stars 509 forks source link

Option to set Authorization header from Request Authorization header (basic http auth) #556

Open ClCfe opened 3 years ago

ClCfe commented 3 years ago

Hello

I use basic http auth on my server laravel-echo-server is behind reverse proxy laravel is also served by the same apache server (i use Lumen to be precise! so I don't have sessions!)

For private channel, laravel-echo-server sends a request to laravel on /broadcasting/auth in my server, this is protected by apache http auth basic

I think it could be great to have an option to automatically set Authorization header from the request header:

https://github.com/tlaverdure/laravel-echo-server/blob/6a4125d96d238c2e99c09c9918925ef6322aca35/src/channels/private-channel.ts#L26

like this: data.auth.headers.Authorization=socket.request.headers.authorization;

this would avoid complex solutions, like : -remove basic auth on "/broadcasting/auth" in apache conf and implement another Guard -or migrating my lumen to laravel -or to make an ajax request prior initialising Echo js client, to get the "Basic: xxxxxxxxxxxxxxxxx" base64 credential

Thanks