add_websocket_handler should provide a way to read client http headers
@florent.thiery
Submitted by Florent Thiery Assigned to libsoup-maint@gnome.bugs
Link to original bug (#789210)
Description
Currently using libsoup from python/gi, behind an nginx proxy; i'm trying to bypass authentication for local clients (127.0.0.1 / ::1). My nginx adds an X-Forwarded-For header, which lets me identify the client IPs using regular http handlers easily (with msg.request_headers.get_one("X-Forwarded-For")).
However, with websocket, the callback of add_websocket_handler only gets client_context which is tcp level, and does not allow getting the client initial headers (before the handshake).
I understand that an amount of methods are exposed to handle creating the websocket session manually, but not all of it seems available from python (only handshake checking related methods such as https://lazka.github.io/pgi-docs/#Soup-2.4/functions.html#Soup.websocket_server_check_handshake), so i don't think it is possible to really do this. If it is, i would be happy to see an example somewhere.
That said, it would be very handy if X-Forwarded-For headers were exposed, or more generally the initial http headers, e.g. by ClientContext, similarly to (albeit indirectly) get_auth_domain() which is basically exposing the initial WWW-Authenticate header.
Version: 2.60.x