oauth2-proxy / oauth2-proxy

A reverse proxy that provides authentication with Google, Azure, OpenID Connect and many more identity providers.
https://oauth2-proxy.github.io/oauth2-proxy
MIT License
9.85k stars 1.6k forks source link

Server Sent Events #1125

Closed Steffi14 closed 3 years ago

Steffi14 commented 3 years ago

I use two applications. One is a single page application and one is kind of a backend. Both are written in scala and use http to communicate. They also use SSE to send events to the single page application. But the events do not reach the browser.

Expected Behavior

image

In the application there is an event endpoint and an open event stream. Through this stream the frontend gets messages on events. Those events need to be passed through the OAuth2 Proxy without any interruptions.

Current Behavior

The event stream is not receiving any notification from the backend. The event stream is empty. But also no error occurs.

Context

We would like to use the OAuth2 Proxy in our Framework. We use Keycloak as Identity Provider. The application which is protected through the oauth2 flow is used as a control center for different actions in the backend. Because the actions in the backend need some more time to be handled we use SSE to tell the single page application the result of the action.

Your Environment

We host our Framework on Openshift (currently version 3.11) The OAuth2 Proxy would be deployed as a sidecar to the single page application The applications are written in Scala and use akka.http.scaladsl.model.sse.ServerSentEvent

OAuth2 Proxy Version used: 6.1.1

JoelSpeed commented 3 years ago

Does this work if you take OAuth2 Proxy out of the equation? I wouldn't have thought OAuth2 proxy would stop events being sent if there is already a connection establised.

That said, if it does work without OAuth2 Proxy, could it be to do with websocket proxying and how that differs from normal HTTP requests? We do have a special proxy-websockets option though I can't remember right now if it defaults to on/off

Steffi14 commented 3 years ago

Yes without the OAuth2 Proxy everything works fine. I read that the proxy-websockets flag should be on true by default. But I also tried with setting it explicitly on true and it was not working either.

I also tried to set the skip-auth-regex on the particular path where the backend application will send the notifications but this also was not helpful. I thought it maybe will solve the problem because the notifications from the backend are not sent with a token or cookie

Steffi14 commented 3 years ago

I made it work. In Openshift I made an additional service for the port of the single page application. The backend app will then communicate through this port directly and will not go through the proxy with the Push Notification for the Server Sent Event.

So it is maybe not a problem with the Proxy.....

JoelSpeed commented 3 years ago

I'd be interested to try and have a play with an application that uses the same protocol to try and work out how to get it to work with OAuth2 Proxy but I don't know what I could use to reproduce the issue

Steffi14 commented 3 years ago

Sorry for my really late answer. I am sorry.

So I don't know with what application you can reproduce the issue because I was using an application from my company.

But the issue was that we sent the notifications through the proxy from front instead sending it directly to the backend of the application. image So the red arrow is wrong. It is not working because we do not have a token/cookie inside the request. The green arrows is right and is working :)

github-actions[bot] commented 3 years ago

This issue has been inactive for 60 days. If the issue is still relevant please comment to re-activate the issue. If no action is taken within 7 days, the issue will be marked closed.