Prefer URL parameter over header for Authorization (customize socket_ws.go)

Our client application is using the SocketRocket package to setup the socket connection. Unfortunately there is currently a bug in SocketRocket which results in the Authorization header being always set on all requests.

See: Fix Basic Authorization header by ElfSundae · Pull Request #617 · facebookincubator/SocketRocket · GitHub

Nakama is returning a HTTP 401 error due to header being present and being invalid, which is of course the expect behaviour. However, Nakama also doesn’t check the URL parameter for the token since it never reaches that code.

See: nakama/socket_ws.go at c7d34a89c6ecb7c1ef4757de5881a77f4f2a6e3e · heroiclabs/nakama · GitHub

We’re using the Nakama Project Template for building the Docker image. How can we (temporary) add our own version of the socket_ws.go file?

Hi @RobinM,

As you’ve pointed out Nakama is behaving as intended here since the bug is with the SocketRocket library incorrectly passing an Authorization header.

My recommendation here would be to fork SocketRocket itself and merge the PR you linked into your fork, rather than attempt to “fix” the issue by modifying Nakama.

However, you are of course free to fork Nakama and modify the socket_ws.go file as you see fit.

Hi @tom,

Thanks for the reply. I understand your recommendation to fork SocketRocket and fix it without modifying Nakama. Unfortunately the SocketRocket package is included in a third-party library which can’t be changed by us.

We would like to go for the (temporary) option where we adjust the socket_ws.go file. It’s unclear for us on how to do this when using the Nakama Project Template. How can we place a custom file in the Docker image and re-build Nakama?

You would need to create your own Docker image using your custom built Nakama binary. Since this would be a custom fork of Nakama it is not something we would be able to assist with.