-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Support credentials in URL with empty user, http://:password@host (#6494) #6495
Conversation
For the test case added to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blocking until we can decide if this change is correct. What cURL does is not indicative as it relies on the user/invoker constructing parts of the request properly. And the RFC seems to indicate that having an empty username is incorrect.
This needs more research and we must remain RFC-compliant.
Ref: #6494 (comment)
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #6495 +/- ##
=======================================
Coverage 98.25% 98.25%
=======================================
Files 107 107
Lines 34125 34136 +11
Branches 4048 4048
=======================================
+ Hits 33530 33541 +11
Misses 421 421
Partials 174 174
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
If we look at the collected ABNF for a URL from Appendix-A of the RFC3986 in particular:
You can see that The regexp given in Appendex-B of the same document also permits the authority to contain an empty username. Looking at other relevant RFCs, Basic Auth has to join back together the user/password (recreating the RFC2617 section 2 (Basic Auth) specifies an ABNF that allows zero length usernames (and passwords)
RFC7617 (Basic Auth) does not mandate the username be of any particular length. I cannot see anything in relevant RFCs that prohibit a zero-length username. |
I don't really mind either way. Looks fine. As mentioned, the whole basic auth thing is a rather old deprecated thing, but that's more a concern for the server-side implementations still making the mistake of using it, rather than the client-side code which is forced to use it. |
Updated commit and |
WHATWG seems to think that this corner case is valid: whatwg/url#139. OTOH I haven't found any explicit tests in the |
Any chance of re-review and/or merge? |
Co-authored-by: Sviatoslav Sydorenko <wk.cvs.github@sydorenko.org.ua>
To summarise: WHATWG also seems to allow it: https://url.spec.whatwg.org/#authority-state RFC7617 doesn't appear to disallow it. So, I think we can just proceed with this. |
Backport to 3.10: 💔 cherry-picking failed — conflicts found❌ Failed to cleanly apply ce9c4eb on top of patchback/backports/3.10/ce9c4eb0f895f356e775ca268d7ccef908f4c936/pr-6495 Backporting merged PR #6495 into master
🤖 @patchback |
Backport to 3.11: 💔 cherry-picking failed — conflicts found❌ Failed to cleanly apply ce9c4eb on top of patchback/backports/3.11/ce9c4eb0f895f356e775ca268d7ccef908f4c936/pr-6495 Backporting merged PR #6495 into master
🤖 @patchback |
What do these changes do?
Per issue #6494 this brings our handling of credentials in the URL where the username is blank in line with the behavior of curl, requests and perhaps other client libraries.
Are there changes in behavior for the user?
Potentially - although vanishingly remote. One could imagine a client to be providing a password in this style, and for aiohttp to be ignoring it, and for the service to allow anonymous access, but not with a Basic authentication header provided. However this is a hidden misconfiguration, so perhaps we are helping them out.
Related issue number
Fixes #6494
Checklist
CONTRIBUTORS.txt
CHANGES
folder<issue_id>.<type>
for example (588.bugfix)issue_id
change it to the pr id after creating the pr.feature
: Signifying a new feature..bugfix
: Signifying a bug fix..doc
: Signifying a documentation improvement..removal
: Signifying a deprecation or removal of public API..misc
: A ticket has been closed, but it is not of interest to users.