Description
Is your feature request related to a problem? Please describe.
This is related to #587 as that user and I work together. Our company requires all egress traffic to go through an HTTP forward proxy that requires authentication. For that authentication, mTLS with the proxy is strongly preferred by the company. For us, in Python, this is done by setting the cert
, verify
, and proxies
keywords on a requests.Session
( or similar ) instance, as we have our own CA, can't use the system default cacert, etc.
We have found that in various places in azure-kusto-python
( specifically azure-kusto-data
), the Session is not being propagated to other clients, helpers, etc., and new instances of Session
are created instead. The proxies
value is usually carried forward, but we would like to have the option to use the same Session
instance.
#588 helped with this, but after pulling in azure-kusto-data==5.0.4
, we found another issue. Here, a generic Session
instance is created after calling super().__init__()
on the superclass.
In the superclass, an instance of AadHelper
is created, but the original Session
instance is not passed to the AadHelper
instance because the initializer doesn't allow for it at present.
That instance of AadHelper
is then, in our use case, creating an instance of ApplicationCertificateTokenProvider, which again does not provide an option to inject the original Session
object.
Eventually, the ApplicationCertificateTokenProvider
class is calling a class from the msal
library ( as seen in pdb
) to create the msal_client
.
The ConfidentialClientApplication
class from msal
is a subclass of ClientApplication
which does allow the caller to supply an http client ( Session
), but we are not exposing that as the classes ( AadHelper
and ApplicationCertificateTokenProvider
) are not making this an option at present. Finally, a call is being made to login.microsoftonline.com
for login purposes but, as the Session is new and doesn't have our custom attributes, the call fails.
Describe the solution you'd like
We would like to be able to optionally inject the Session
instance into KustoClient
and the other classes ( AadHelper
and ApplicationCertificateTokenProvider
).
This would make it so that:
- We can customize the Session as needed before all other classes init.
- The Session will follow the other classes.
- Not providing the session would have the same effect as before - a default
Session
instance will be created. Users can still callset_proxy(url)
on theKustoClient
instance to use a proxy with basic auth or no auth, as theproxy_dict
is typically forwarded through the other classes mentioned.
Describe alternatives you've considered
N/A
Additional context
I made these changes in a local environment and it worked as expected. I also ran the existing E2E tests ( got a free database as seen in Contributing.md
) and all existing tests passed, as well as a new test that I wrote. I'm happy to put in a PR for this change if desired.