-
Notifications
You must be signed in to change notification settings - Fork 11.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[5.3] Pusher authentication across domains #15746
Comments
Can you please explain your changes? I don't seem to follow, why do you think these changes solve your problem? |
Sure, I have 3 parts to my application: I was going through the process of setting up broadcasts to send notifications to my UI and found that when Laravel Echo makes the authentication request to my API for private channels, it did not attach any credentials to the request, and they would fail (403). This is because my API is on a different domain to the Echo Javascript. After reading through pusher docs (https://pusher.com/docs/authenticating_users) I found that the only way to do the cross domain authentication is with JSONp, this can be set in Laravel Echo with The other difference is pusher expects the authentication signature to be returned in a callback when using JSONp, not just the standard JSON format. I have modified These changes have fixed my problem entirely and now the broadcasting works, I am not sure if there is a better place to achieve the same results, or a better place to modify the broadcast package, but I figured once the problem and solution were detailed, the Laravel team would be able to make that decision. |
ping @themsaid. @jedjones-uk No offense, but this doesn't seem so clean to me. |
@morloderex None taken, I wanted to raise the issue and at least provide a solution with the problem, but I knew it was quite likely there would be a better/cleaner/more Laravel way of handling it. |
It's hard to believe years later I'm trying to authenticate with pusher cross-domain and all I can find is this unresolved issue, is there no fix/workaround in 5.6 now @jedjones-uk @morloderex @themsaid ? |
I currently use Laravel as an API and have an AngularJS client side running on a separate domain, authentication is handled with cookies, and not auth tokens.
When using pusher across domains on private channels it does not attach the credentials to the request, the only way I found to do it is by setting
authTransport: 'jsonp'
in the Echo options, but when you do this the authentication request made by pusher is a GET request and pusher expects a callback as the response. With the small changes below, it will allow the pusher broadcaster to be used when the auth domain is different from the requesting domain.I have modified PusherBroadcaster.php as follows to make it work:
I also had to change
Illuminate\Broadcasting\BroadcastManager@routes
to include a GET endpoint like so:Is there a better way to handle what I am doing?
The text was updated successfully, but these errors were encountered: