Hi there,
I am having difficulties trying to connect to a websocket-enabled server behind Tyk gateway with “use_openid” option being true. As the browser don’t allow modifying ws:// request headers, we are forced to pass the JWT token via query parameters, more specifically using the “access_token” parameter. I read somewhere in the forums that you can read the token from query parameters as a fallback when it’s not found in the request headers, therefore I have done the following in the configuration:
{
...
"auth": {
"use_param": true,
"param_name": "access_token",
"disable_header": false,
"auth_header_name": "Authorization"
}
...
}
Following which I have tried to test the endpoint under these situations:
- Sending via query parameter by appending access_token=<JWT token> in the ws:// url
This resulted in an Error 401, and the following logs can be seen emitted by the Tyk gateway container:
tyk-gateway_1 | time="Nov 24 10:35:16" level=warning msg="JWT Invalid" api_id=ntsignalrproxy api_name=ntsignalrproxy error="Validation error. The 'Authorization' header was not found or was empty." mw=OpenIDMW org_id=60f08cb4b4c0be0001a87762 origin=192.168.224.1 path="/ntsignalrproxy/"
tyk-gateway_1 | time="Nov 24 10:35:16" level=warning msg="Attempted access with invalid key." api_id=ntsignalrproxy api_name=ntsignalrproxy key="****JWT]" mw=OpenIDMW org_id=60f08cb4b4c0be0001a87762 origin=192.168.224.1 path="/ntsignalrproxy/
Which probably meant that Tyk gateway doesn’t check the access_token query parameter despite being configured that way?
- Sending via Authorization header by appending Bearer <JWT token>
This didn’t produce and logs but resulted in an Error 500 returned, which I am not sure how to debug further. Besides, this second approach is unfeasible because in the browser, we can’t use request headers when establishing a websocket connection. But I did so just to test what was Tyk was doing internally.
However, I have tested the same configuration but using “use_keyless” = true and changing “use_openid” = false, and it successfully connects without any authentication check which is expected, so I am led to believe that using websockets protected by open id doesn’t work well in Tyk gateway.
Any ideas would be greatly appreciated… Thank you.
Prakoso