Replies: 1 comment 1 reply
-
Heya @jborean93 - this is fantastic love it! 😅
Right, that makes sense, yup! Complex, but makes sense.
So - I rather think we need some extra docs here. The What do we do about that? Well... the sensible thing is to call that out in the docs. Essentially "if you're using the trace extension, then you should avoid relying on the callback information being structured in a particular way. If you are relying on a particular structure then we recommend that you use a strictly pinned version of Make sense? Would you be up for opening an issue along these lines, citing this discussion? It's possible that at some point
Oh neat - that's pretty interesting. Issue encode/httpx#2033 is somewhat related to that too. The discussion there might help give you some context onto resolving that. Do let us know how you get on! |
Beta Was this translation helpful? Give feedback.
-
I'm trying to adapt my code to the new way of working introduced with #419. I've got a fairly weird edge case where the authentication protocol I'm using needs access to the TLS context set up during the connection for channel binding. Unfortunately the current auth callback does not fit this model as it is called before the socket is connected and TLS negotiated and the use of connection pools can cause a lot of trickiness when it comes to re-authentication and the like. In the old world I had a very weird setup that relied on private classes in this library which worked for pretty much all the scenarios I needed (Negotiate auth with proxies, socks, etc). The downside to the use of these private interfaces means it doesn't work anymore which is understandable.
When looking at the new way of working I think I've found an acceptable mechanism that uses the new trace functionality that was added. The only downside is I think the way I'm (ab)using it might not be entirely sanctioned and hoping to get some confirmation as to whether this is ok from a public consumption perspective. The POC code I had which demonstrates this in action is the below
Click to expand!
Essentially it is creating it's own transport that interacts with
AsyncHTTPConnection
. On the first request it will send the request with thetrace
extension and does special actions for the following traces:connection.start_tls.complete
- Uses the supplied SSL context to get the cert information for the channel binding tokenhttp11.send_request_headers.started
- Sets up the security context with the channel binding token and injects theAuthentication
header with the first security token returned by the contextOnce these weird steps are completed the transport will continue to handle the authentication sequence in
handle_async_request
as per normal. This works perfectly but I'm worried that injecting this header into the request during the trace is something that could break in the future or shouldn't be done in general.I've taken the code a bit further where the transport also encrypts the data with the security context when it is completed and all this works wonderfully but this usage is nagging me a bit.
Just as an FYI the next step for me is to try and get Negotiate auth working for proxies which I had working on the old model. I haven't really looked into it in depth but I'm hoping it will be possible. Thanks for the great library, loving the work that you've put into it so far.
Beta Was this translation helpful? Give feedback.
All reactions