oliyh / re-graph

A graphql client for clojurescript and clojure
460 stars 39 forks source link

cookie handling with re-frame on clojure #58

Closed loomis closed 4 years ago

loomis commented 4 years ago

I have a service that uses cookies for managing authn/authz tokens and that does not permit unauthenticated websocket connections. The initial authn is done with http requests; afterwards an authenticated websocket connection can be used. For this to work, the http and websocket clients must share a cookie store. This seems to be impossible (or at least extremely difficult) because clj-http uses the Apache HTTP client and the WebSockets are handled via Jetty.

I've created a fork that uses hato for both HTTP and WebSocket requests. This allows sharing a cookie store.

Is there an easier fix/workaround that I've missed? If not, @oliyh would you be interested in a PR to use hato instead of clj-http/gniazdo? This would unfortunately restrict the code to JDK 11+ only.

oliyh commented 4 years ago

Hi,

I have no objection to using hato, it looks good. I think JDK11 is a reasonable requirement these days, and as re-graph is fairly feature complete / mature now anyone using older JDKs will not miss out on too much in newer versions. If the surface area of the actual http implementation is small enough, perhaps it could even be pluggable?

loomis commented 4 years ago

@oliyh thanks for the response. I'll prepare a PR with the changes. I've added a ws-parameters option, which you might want to be handled differently. Although the changes for the switch to hato are relatively minor, I've not made the backend implementations pluggable. We can discuss both of these through the PR.