AxaFrance / oidc-client

Light, Secure, Pure Javascript OIDC (Open ID Connect) Client. We provide also a REACT wrapper (compatible NextJS, etc.).
MIT License
597 stars 160 forks source link

Authorization Header in WebSocket requests #956

Closed dragos-rosca closed 1 year ago

dragos-rosca commented 1 year ago

Hello,

I don't get an authorization header in my WebSocket requests.

"@axa-fr/react-oidc": "^6.14.1"

I have a react frontend with Apollo client as my main communication with the GQL backend. When I run queries or mutations (this are HTTP POST calls) I see the authorization header injected in the request, but when I have a subscription (this is a WebSocket GET call) there is nothing.

I have added the WebSocket URL to the OidcTrustedDomains.js file (because this is a ws://localhost:4001 URL) and still nothing.

In the past I used to inject the header by hand in the Apollo client configuration, but this is JS code, no react involved. I was using getUserManager to access the token, but this is not the way now with react-oidc.

Kind regards, Dragos Rosca

guillaume-chervet commented 1 year ago

Hi @dragos-rosca , thank you again for your issue. Unfortunally, Service worker does not catch websocket data. The only way is to use the library without service worker and to send them from javascript side.

dragos-rosca commented 1 year ago

Hello,

Thank you for the quick response. I'll do that.