]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
📝 Replace `email` with `username` in `docs_src/security/tutorial007` code examples...
authorNils Lindemann <nilslindemann@tutanota.com>
Thu, 11 Jan 2024 14:33:05 +0000 (15:33 +0100)
committerGitHub <noreply@github.com>
Thu, 11 Jan 2024 14:33:05 +0000 (09:33 -0500)
docs/en/docs/advanced/security/http-basic-auth.md
docs_src/security/tutorial007.py
docs_src/security/tutorial007_an.py
docs_src/security/tutorial007_an_py39.py

index 6f9002f608022420b0b997196168de51c4a54eb2..680f4dff53e6c77a2fc016b37610fcba7eae8d24 100644 (file)
@@ -105,7 +105,7 @@ if "johndoe" == "stanleyjobson" and "love123" == "swordfish":
     ...
 ```
 
-But right at the moment Python compares the first `j` in `johndoe` to the first `s` in `stanleyjobson`, it will return `False`, because it already knows that those two strings are not the same, thinking that "there's no need to waste more computation comparing the rest of the letters". And your application will say "incorrect user or password".
+But right at the moment Python compares the first `j` in `johndoe` to the first `s` in `stanleyjobson`, it will return `False`, because it already knows that those two strings are not the same, thinking that "there's no need to waste more computation comparing the rest of the letters". And your application will say "Incorrect username or password".
 
 But then the attackers try with username `stanleyjobsox` and password `love123`.
 
@@ -116,11 +116,11 @@ if "stanleyjobsox" == "stanleyjobson" and "love123" == "swordfish":
     ...
 ```
 
-Python will have to compare the whole `stanleyjobso` in both `stanleyjobsox` and `stanleyjobson` before realizing that both strings are not the same. So it will take some extra microseconds to reply back "incorrect user or password".
+Python will have to compare the whole `stanleyjobso` in both `stanleyjobsox` and `stanleyjobson` before realizing that both strings are not the same. So it will take some extra microseconds to reply back "Incorrect username or password".
 
 #### The time to answer helps the attackers
 
-At that point, by noticing that the server took some microseconds longer to send the "incorrect user or password" response, the attackers will know that they got _something_ right, some of the initial letters were right.
+At that point, by noticing that the server took some microseconds longer to send the "Incorrect username or password" response, the attackers will know that they got _something_ right, some of the initial letters were right.
 
 And then they can try again knowing that it's probably something more similar to `stanleyjobsox` than to `johndoe`.
 
index 790ee10bc6b1dff6db74727df05fca99b57fef14..ac816eb0c19d261ff9d99952fa097a8e464f48b6 100644 (file)
@@ -22,7 +22,7 @@ def get_current_username(credentials: HTTPBasicCredentials = Depends(security)):
     if not (is_correct_username and is_correct_password):
         raise HTTPException(
             status_code=status.HTTP_401_UNAUTHORIZED,
-            detail="Incorrect email or password",
+            detail="Incorrect username or password",
             headers={"WWW-Authenticate": "Basic"},
         )
     return credentials.username
index 5fb7c8e57560c13fc27ad6e8d8ee60c188ae53dc..9e9c3cd7020f0f06e08ecb97bfa0487a117e7ef6 100644 (file)
@@ -25,7 +25,7 @@ def get_current_username(
     if not (is_correct_username and is_correct_password):
         raise HTTPException(
             status_code=status.HTTP_401_UNAUTHORIZED,
-            detail="Incorrect email or password",
+            detail="Incorrect username or password",
             headers={"WWW-Authenticate": "Basic"},
         )
     return credentials.username
index 17177dabf9e47db92c6c616a0ab24e568cbb3d6c..3d9ea27269eed54c9de5f470363d09950909dc1d 100644 (file)
@@ -25,7 +25,7 @@ def get_current_username(
     if not (is_correct_username and is_correct_password):
         raise HTTPException(
             status_code=status.HTTP_401_UNAUTHORIZED,
-            detail="Incorrect email or password",
+            detail="Incorrect username or password",
             headers={"WWW-Authenticate": "Basic"},
         )
     return credentials.username