Skip to content
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

authentication header is case sensitive. #458

Open
erahhal opened this issue Nov 27, 2024 · 5 comments
Open

authentication header is case sensitive. #458

erahhal opened this issue Nov 27, 2024 · 5 comments

Comments

@erahhal
Copy link

erahhal commented Nov 27, 2024

Extraction of WWW-Authenticate header appears to be case sensitive. Headers are not case sensitive according to the HTTP standard, and Caddy sends www-authenticate, which can't be seen by the davclient, e.g in this line.

tobixen added a commit that referenced this issue Nov 27, 2024
…e, WWW-Authenticate and any bastard casing styles. Updates #458
tobixen added a commit that referenced this issue Nov 27, 2024
…e, WWW-Authenticate and any bastard casing styles. Updates #458
@tobixen
Copy link
Member

tobixen commented Nov 27, 2024

Sorry the noise, should try to remember not to do any commits before getting my morning cafffeine next time :-)

So the requests library has a CaseInsensitiveDict which is meant to be used exactly for this purpose. It was used in parts of the code, but not consistently.

Could you please try to use either the issue458 branch or the v1.x-branch and see if that solves your problem? (hm, lack of morning caffeine again ... I shouldn't check things into the v1.x-branch before it has been merged to master)

@erahhal
Copy link
Author

erahhal commented Nov 27, 2024

Totally understand re: the coffee :) I'm not actually using it directly. Was trying to use another package called Errands and it kept failing to authenticate so I dug into it and found out it was using this library. Would need to get that app running in a local dev environment first.

@tobixen
Copy link
Member

tobixen commented Nov 27, 2024

I should probably try to write up some unit tests that mocks the authentication, but ... I'm not up for it today at least.

If you would have the possibility to create a test account for me on your caldav server it would be great, then I could run the test code towards it.

(The authentication part ought to be solved by the Requests library, it's silly that I need to do all this low-level http stuff in the caldav library. Now that we're moving away from requests, perhaps this code can be discarded completely)

@tobixen
Copy link
Member

tobixen commented Nov 27, 2024

Came to think, the headers returned from the requests library ought to already be a CaseInsensitiveDict. And probably more people would have complained if this was a bug - after all, it seems reasonably normal to pass headers in lower case. So I'm really curious as to weather my latest hacking solves any real-world problems or not :-)

@tobixen
Copy link
Member

tobixen commented Nov 27, 2024

Correct. The headers returned from the requests library is a CaseInsensitiveDict, hence r.headers['WWW-Authenticate'] will always work, no matter if the server returns the header in lower case or upper case (but I should fix that DAVClients.headers is a CaseInsensitiveDict anyway).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants