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

Support using netrc for non-proxy HTTP credentials #7249

Conversation

Dreamsorcerer
Copy link
Member

Currently, setting trust_env=True in ClientSession will only use the .netrc file if present for authentication to proxies. With this change, the credentials will also be used for regular HTTP hosts, and Basic Auth will be sent if an appropriate entry is present in the user's .netrc file.

PR #7131.

Co-authored-by: Sam Bull aa6bs0@sambull.org
Co-authored-by: Sviatoslav Sydorenko webknjaz@redhat.com
(cherry picked from commit 6da0469)

What do these changes do?

Are there changes in behavior for the user?

Related issue number

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes
  • If you provide code modification, please add yourself to CONTRIBUTORS.txt
    • The format is <Name> <Surname>.
    • Please keep alphabetical order, the file is sorted by names.
  • Add a new news fragment into the CHANGES folder
    • name it <issue_id>.<type> for example (588.bugfix)
    • if you don't have an issue_id change it to the pr id after creating the pr
    • ensure type is one of the following:
      • .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.
    • Make sure to use full sentences with correct case and punctuation, for example: "Fix issue with non-ascii contents in doctest text files."

Currently, setting `trust_env=True` in `ClientSession` will only use the `.netrc`
file if present for authentication to proxies. With this change, the credentials will
also be used for regular HTTP hosts, and Basic Auth will be sent if an appropriate
entry is present in the user's `.netrc` file.

PR #7131.

Co-authored-by: Sam Bull <aa6bs0@sambull.org>
Co-authored-by: Sviatoslav Sydorenko <webknjaz@redhat.com>
(cherry picked from commit 6da0469)
@psf-chronographer psf-chronographer bot added the bot:chronographer:provided There is a change note present in this PR label Apr 8, 2023
@codecov
Copy link

codecov bot commented Apr 8, 2023

Codecov Report

Merging #7249 (d3daeb8) into 3.9 (43e568b) will decrease coverage by 0.01%.
The diff coverage is 95.23%.

@@            Coverage Diff             @@
##              3.9    #7249      +/-   ##
==========================================
- Coverage   97.34%   97.34%   -0.01%     
==========================================
  Files         107      107              
  Lines       31490    31544      +54     
  Branches     3977     4002      +25     
==========================================
+ Hits        30654    30706      +52     
  Misses        634      634              
- Partials      202      204       +2     
Flag Coverage Δ
CI-GHA 97.24% <95.23%> (-0.01%) ⬇️
OS-Linux 96.90% <95.23%> (-0.01%) ⬇️
OS-Windows 94.50% <95.23%> (-0.01%) ⬇️
OS-macOS 96.48% <95.23%> (-0.01%) ⬇️
Py-3.10.10 96.97% <95.23%> (-0.01%) ⬇️
Py-3.11.0 96.40% <95.23%> (-0.01%) ⬇️
Py-3.7.16 96.71% <95.16%> (-0.01%) ⬇️
Py-3.7.9 94.35% <95.16%> (-0.01%) ⬇️
Py-3.8.10 94.28% <95.23%> (+<0.01%) ⬆️
Py-3.8.16 96.63% <95.23%> (-0.01%) ⬇️
Py-3.9.13 94.29% <95.23%> (+<0.01%) ⬆️
Py-3.9.16 96.65% <95.23%> (-0.01%) ⬇️
Py-pypy7.3.11 94.06% <84.12%> (-0.01%) ⬇️
VM-macos 96.48% <95.23%> (-0.01%) ⬇️
VM-ubuntu 96.90% <95.23%> (-0.01%) ⬇️
VM-windows 94.50% <95.23%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
aiohttp/client.py 94.80% <ø> (+0.20%) ⬆️
aiohttp/helpers.py 95.08% <86.66%> (-0.32%) ⬇️
tests/conftest.py 92.03% <87.50%> (-0.35%) ⬇️
aiohttp/client_reqrep.py 97.84% <100.00%> (+0.01%) ⬆️
tests/test_client_request.py 99.61% <100.00%> (+<0.01%) ⬆️
tests/test_helpers.py 98.79% <100.00%> (+0.04%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@Dreamsorcerer Dreamsorcerer enabled auto-merge (squash) April 8, 2023 19:53
@Dreamsorcerer Dreamsorcerer merged commit e0adc97 into 3.9 Apr 8, 2023
23 of 26 checks passed
@Dreamsorcerer Dreamsorcerer deleted the patchback/backports/3.9/6da04694fd87a39af9c3856048c9ff23ca815f88/pr-7131 branch April 8, 2023 20:04
@yuvipanda
Copy link
Contributor

Thank you so much for doing the cherry-picking, @Dreamsorcerer!

@yuvipanda
Copy link
Contributor

Do you know when a 3.9 might be made?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot:chronographer:provided There is a change note present in this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants