Thanks to visit codestin.com
Credit goes to github.com

Skip to content

📝 Update docs for handling HTTP Basic Auth with secrets.compare_digest() to account for non-ASCII characters#3536

Merged
tiangolo merged 4 commits into
fastapi:masterfrom
lewoudar:master
Aug 24, 2022
Merged

📝 Update docs for handling HTTP Basic Auth with secrets.compare_digest() to account for non-ASCII characters#3536
tiangolo merged 4 commits into
fastapi:masterfrom
lewoudar:master

Conversation

@lewoudar

@lewoudar lewoudar commented Jul 15, 2021

Copy link
Copy Markdown
Contributor

Updated by @tiangolo:

📝 Update docs for handling HTTP Basic Auth with secrets.compare_digest() to account for non-ASCII characters.


I changed the basic auth security example to encode data in bytes using the idna format. This is because compare_digest only checks ascii characters but in the real world, many people have a name with non-ascii characters 😃

I also removed useless docstring comment.

@tiangolo tiangolo changed the title fix basic auth security example and docstring 📝 Update docs for handling HTTP Basic Auth with secrets.compare_digest() to account for non-ASCII characters Aug 24, 2022
@codecov

codecov Bot commented Aug 24, 2022

Copy link
Copy Markdown

Codecov Report

Merging #3536 (fa8fa26) into master (2201f29) will not change coverage.
The diff coverage is n/a.

@@            Coverage Diff            @@
##            master     #3536   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          533       533           
  Lines        13755     13755           
=========================================
  Hits         13755     13755           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@tiangolo

Copy link
Copy Markdown
Member

Thank you @lewoudar! 🤓

I updated the example and docs a bit to make it more explicit. I used UTF-8 instead of IDNA, as this is not related to domains.

I reverted the change in the docstring to put it in a different PR as that is a different thing. Also because only removing that line also left the example code broken. But let's fix that in another PR later.

Thanks for your contribution! 🍰

@tiangolo tiangolo merged commit 8c6ad35 into fastapi:master Aug 24, 2022
@lewoudar

Copy link
Copy Markdown
Contributor Author

@tiangolo perfect!

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

Successfully merging this pull request may close these issues.

2 participants