From: Nick Chen <119087246+nick-cjyx9@users.noreply.github.com>
Date: Sun, 5 May 2024 21:32:54 +0000 (+0800)
Subject: 🌐 Update Chinese translation for `/docs/advanced/security/http-basic-auth.md` (#11512)
X-Git-Tag: 0.111.1~156
X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6ec46c17d3f88054de4a89908380b0e171b20e87;p=thirdparty%2Ffastapi%2Ffastapi.git
🌐 Update Chinese translation for `/docs/advanced/security/http-basic-auth.md` (#11512)
---
diff --git a/docs/zh/docs/advanced/security/http-basic-auth.md b/docs/zh/docs/advanced/security/http-basic-auth.md
index 1f251ca452..ab8961e7cf 100644
--- a/docs/zh/docs/advanced/security/http-basic-auth.md
+++ b/docs/zh/docs/advanced/security/http-basic-auth.md
@@ -14,15 +14,32 @@ HTTP åºç¡ææè®©æµè§å¨æ¾ç¤ºå
ç½®çç¨æ·åä¸å¯ç æç¤ºã
## ç®åç HTTP åºç¡ææ
-* 导å
¥ `HTTPBsic` ä¸ `HTTPBasicCredentials`
-* ä½¿ç¨ `HTTPBsic` å建**å®å
¨æ¦å¾**
+* 导å
¥ `HTTPBasic` ä¸ `HTTPBasicCredentials`
+* ä½¿ç¨ `HTTPBasic` å建**å®å
¨æ¦å¾**
* å¨*è·¯å¾æä½*çä¾èµé¡¹ä¸ä½¿ç¨ `security`
* è¿åç±»å为 `HTTPBasicCredentials` ç对象ï¼
* å
å«åéç `username` ä¸ `password`
-```Python hl_lines="2 6 10"
-{!../../../docs_src/security/tutorial006.py!}
-```
+=== "Python 3.9+"
+
+ ```Python hl_lines="4 8 12"
+ {!> ../../../docs_src/security/tutorial006_an_py39.py!}
+ ```
+
+=== "Python 3.8+"
+
+ ```Python hl_lines="2 7 11"
+ {!> ../../../docs_src/security/tutorial006_an.py!}
+ ```
+
+=== "Python 3.8+ non-Annotated"
+
+ !!! tip
+ å°½å¯è½éæ©ä½¿ç¨ `Annotated` ççæ¬ã
+
+ ```Python hl_lines="2 6 10"
+ {!> ../../../docs_src/security/tutorial006.py!}
+ ```
ç¬¬ä¸æ¬¡æå¼ URLï¼æå¨ API ææ¡£ä¸ç¹å» **Execute** æé®ï¼æ¶ï¼æµè§å¨è¦æ±è¾å
¥ç¨æ·åä¸å¯ç ï¼
@@ -34,13 +51,35 @@ HTTP åºç¡ææè®©æµè§å¨æ¾ç¤ºå
ç½®çç¨æ·åä¸å¯ç æç¤ºã
使ç¨ä¾èµé¡¹æ£æ¥ç¨æ·åä¸å¯ç æ¯å¦æ£ç¡®ã
-为æ¤è¦ä½¿ç¨ Python æ 忍¡å `secrets` æ£æ¥ç¨æ·åä¸å¯ç ï¼
+为æ¤è¦ä½¿ç¨ Python æ 忍¡å `secrets` æ£æ¥ç¨æ·åä¸å¯ç ã
-```Python hl_lines="1 11-13"
-{!../../../docs_src/security/tutorial007.py!}
-```
+`secrets.compare_digest()` éè¦ä»
å
å« ASCII å符ï¼è±è¯å符ï¼ç `bytes` æ `str`ï¼è¿æå³çå®ä¸éç¨äºå`á`䏿 ·çå符ï¼å¦ `Sebastián`ã
+
+为äºè§£å³è¿ä¸ªé®é¢ï¼æä»¬é¦å
å° `username` å `password` 转æ¢ä¸ºä½¿ç¨ UTF-8 ç¼ç ç `bytes` ã
+
+ç¶åæä»¬å¯ä»¥ä½¿ç¨ `secrets.compare_digest()` æ¥ç¡®ä¿ `credentials.username` æ¯ `"stanleyjobson"`ï¼ä¸ `credentials.password` æ¯`"swordfish"`ã
+
+=== "Python 3.9+"
+
+ ```Python hl_lines="1 12-24"
+ {!> ../../../docs_src/security/tutorial007_an_py39.py!}
+ ```
-è¿æ®µä»£ç ç¡®ä¿ `credentials.username` æ¯ `"stanleyjobson"`ï¼ä¸ `credentials.password` æ¯`"swordfish"`ãä¸ä»¥ä¸ä»£ç 类似ï¼
+=== "Python 3.8+"
+
+ ```Python hl_lines="1 12-24"
+ {!> ../../../docs_src/security/tutorial007_an.py!}
+ ```
+
+=== "Python 3.8+ non-Annotated"
+
+ !!! tip
+ å°½å¯è½éæ©ä½¿ç¨ `Annotated` ççæ¬ã
+
+ ```Python hl_lines="1 11-21"
+ {!> ../../../docs_src/security/tutorial007.py!}
+ ```
+è¿ç±»ä¼¼äºï¼
```Python
if not (credentials.username == "stanleyjobson") or not (credentials.password == "swordfish"):
@@ -102,6 +141,23 @@ if "stanleyjobsox" == "stanleyjobson" and "love123" == "swordfish":
æ£æµå°åè¯ä¸æ£ç¡®åï¼è¿å `HTTPException` åç¶æç 401ï¼ä¸æ åè¯æ¶è¿åçå
容䏿 ·ï¼ï¼å¹¶æ·»å 请æ±å¤´ `WWW-Authenticate`ï¼è®©æµè§å¨å次æ¾ç¤ºç»å½æç¤ºï¼
-```Python hl_lines="15-19"
-{!../../../docs_src/security/tutorial007.py!}
-```
+=== "Python 3.9+"
+
+ ```Python hl_lines="26-30"
+ {!> ../../../docs_src/security/tutorial007_an_py39.py!}
+ ```
+
+=== "Python 3.8+"
+
+ ```Python hl_lines="26-30"
+ {!> ../../../docs_src/security/tutorial007_an.py!}
+ ```
+
+=== "Python 3.8+ non-Annotated"
+
+ !!! tip
+ å°½å¯è½éæ©ä½¿ç¨ `Annotated` ççæ¬ã
+
+ ```Python hl_lines="23-27"
+ {!> ../../../docs_src/security/tutorial007.py!}
+ ```