-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.netrc should not be honored if username and password is given to the client #206
Comments
I did some more research and you can disable Regardings proxys: One can already allow to specify the proxy to use. So that I looked at the requests library and might have found a workaround: But first, lets look at the code.... The if we are interested look like this (in from requests import sessions
class SessionIgnoringNetrc(sessions.Session):
def prepare_request(self, request):
# set this to anything except None and a dict (so the if block is skipped)
# that is not a mapping type (so the value we set is not merged with those
# from the request).
self.auth = ("foo", "bar")
prepared_request = super(SessionIgnoringNetrc, self).prepare_request(request)
self.auth = None # might not be needed
return prepared_request When you use the following code at the first request where we don't use any authentication and also want to ignore netrc, you could use this code: with SessionIgnoringNetrc() as session:
response = session.request(method="get", url="some url") I know, it is hacky... This solution is interception at two points. First the |
I'm frequently getting pull requests on various parameters people want passed from the DAVClient to the requests library, I think I think there are many possible solutions to this problem, here are some ideas: Push the problem to the requests libraryAs said, I believe this complexity belongs in the requests library and not in the caldav library. It would be nice to do some research - how is this solved by other users of the requests library? I find it hard to believe that this problem is unique to the caldav library. Best thing would probably be to communicate directly and informally with the main contributors/maintainers of the requests library and hear what they think. If it's difficult to get in touch with them, raising an issue at their side could possibly be a way to get in touch with the relevant people. I thought of raising an issue earlier that it should be possible to pass username and password to the library without explicitly telling what kind of auth to use - but then it would be a "feature request" and not a "bug report", and feature requests are not accepted. There is a drawback - there exists many weird caldav servers out there, and the current code is like optimized to work on as many servers as possible. If the whole logic is to be moved to the requests library, it's a risk that it will cause regression issues for some users. Your SessionIgnoringNetrc solutionI think the requests library is a very mature library, so the risk that Explicit check that username and password is utilizedIt's possible to do a check - if username and password is provided but still not utilized when doing the Reverting to the old behaviour - try all kind of auth methodsI really don't want to go this route, and as experienced this also caused problems for some (very few) users. Simply ignoring the whole issue and ensure it's documented... possibly combined with raising an issue at the requests library issue tracker. To encounter this issue, it's needed to have a .netrc file, the .netrc has to cover the calendar server, and the username/password provided in the netrc has to deviate from what is given to the caldav server. How likely is it that other people are affected by this issue? |
Seems like there is a version 3 of the requests library coming at some point in the future. While I will accept a pull request on the SessionIgnoringNetrc-solution, I think my favored approach is to wait for requests3 and consider from there what is the best solution. |
Ref #205, it was found that the python requests library will honor a .netrc file. While it's a feature that such a file is honored when username and password is omitted, it's a bug that the file is honored when a (different) username and password is given to the library.
The text was updated successfully, but these errors were encountered: