Open leifwalsh opened 10 months ago
From my perspective I like the idea. Currently the Jira client init method is bloated with auth stuff. I think it would be great to have an auth
module and then dedicated AuthBase subclasses. Perhaps a method like a generic get_jira_auth()
that has all that complexity of the current implementation can be used to preserve backwards compatibility.
Some points to consider:
httpx
(my current preference for an Async Jira client) how would we want to handle the auth class (if the classes are incompatible, I haven't really checked). But might be worth considering at this stage.httpx doesn't support request style auth classes, because the callback may need to be async. But their customization mechanism is pretty similar: https://www.python-httpx.org/advanced/#customizing-authentication
Problem trying to solve
At work we configure lots of python libraries to do authentication with our internal SSO system, and to do so we've got our own subclasses of
requests.auth.AuthBase
that do mostly well known things like OAuth and Kerberos, but also handle retries and fallback mechanisms in ways that are important to us.Anyway, there seems to be no way to pass either a pre-configured
requests.Session
, or a subclass ofrequests.auth.AuthBase
in toJIRA
's constructor. It accepts the parameters needed to construct a variety ofAuthBase
derivatives, but won't let me say "trust me" and pass an Auth object.Possible solution(s)
Basically, dependency injection: change
JIRA
to accept either aSession
or anAuth
object and use it, instead of it constructing its own. Many (not all, sadly) other libraries let you pass in a Session, but I think actually the way requests is designed it's better to pass in an Auth object, but most people don't.Alternatives
For now I can subclass it and have my constructor do something like
but I don't love monkeying with
self._session
nor that code duplication.Additional Context
I know you're busy and have asked for help with CI. If I can find someone who has some time to propose a PR, we can do that, I just wanted to float the idea as an issue first to see if you hate it.