- Sort Score
- Result 10 results
- Languages All
Results 1 - 10 of 15 for HTTPBasicCredentials (0.13 sec)
-
docs_src/security/tutorial007_an.py
import secrets from fastapi import Depends, FastAPI, HTTPException, status from fastapi.security import HTTPBasic, HTTPBasicCredentials from typing_extensions import Annotated app = FastAPI() security = HTTPBasic() def get_current_username( credentials: Annotated[HTTPBasicCredentials, Depends(security)], ): current_username_bytes = credentials.username.encode("utf8") correct_username_bytes = b"stanleyjobson"
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Tue Mar 26 16:56:53 UTC 2024 - 1.2K bytes - Viewed (0) -
docs_src/security/tutorial007.py
import secrets from fastapi import Depends, FastAPI, HTTPException, status from fastapi.security import HTTPBasic, HTTPBasicCredentials app = FastAPI() security = HTTPBasic() def get_current_username(credentials: HTTPBasicCredentials = Depends(security)): current_username_bytes = credentials.username.encode("utf8") correct_username_bytes = b"stanleyjobson" is_correct_username = secrets.compare_digest(
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Thu Jan 11 14:33:05 UTC 2024 - 1.1K bytes - Viewed (0) -
tests/test_security_http_basic_realm.py
from base64 import b64encode from fastapi import FastAPI, Security from fastapi.security import HTTPBasic, HTTPBasicCredentials from fastapi.testclient import TestClient app = FastAPI() security = HTTPBasic(realm="simple") @app.get("/users/me") def read_current_user(credentials: HTTPBasicCredentials = Security(security)): return {"username": credentials.username, "password": credentials.password} client = TestClient(app)
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Jun 30 18:25:16 UTC 2023 - 2.6K bytes - Viewed (0) -
docs/en/docs/reference/security/index.md
You can import them from `fastapi.security`: ```python from fastapi.security import ( APIKeyCookie, APIKeyHeader, APIKeyQuery, HTTPAuthorizationCredentials, HTTPBasic, HTTPBasicCredentials, HTTPBearer, HTTPDigest, OAuth2, OAuth2AuthorizationCodeBearer, OAuth2PasswordBearer, OAuth2PasswordRequestForm, OAuth2PasswordRequestFormStrict, OpenIdConnect,
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Thu Apr 18 19:53:19 UTC 2024 - 1.6K bytes - Viewed (0) -
docs_src/security/tutorial007_an_py39.py
import secrets from typing import Annotated from fastapi import Depends, FastAPI, HTTPException, status from fastapi.security import HTTPBasic, HTTPBasicCredentials app = FastAPI() security = HTTPBasic() def get_current_username( credentials: Annotated[HTTPBasicCredentials, Depends(security)], ): current_username_bytes = credentials.username.encode("utf8") correct_username_bytes = b"stanleyjobson"
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Tue Mar 26 16:56:53 UTC 2024 - 1.1K bytes - Viewed (0) -
tests/test_security_http_basic_realm_description.py
from base64 import b64encode from fastapi import FastAPI, Security from fastapi.security import HTTPBasic, HTTPBasicCredentials from fastapi.testclient import TestClient app = FastAPI() security = HTTPBasic(realm="simple", description="HTTPBasic scheme") @app.get("/users/me") def read_current_user(credentials: HTTPBasicCredentials = Security(security)): return {"username": credentials.username, "password": credentials.password}
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Jun 30 18:25:16 UTC 2023 - 2.8K bytes - Viewed (0) -
docs_src/security/tutorial006_an.py
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sat Mar 18 12:29:59 UTC 2023 - 371 bytes - Viewed (0) -
docs_src/security/tutorial006_an_py39.py
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sat Mar 18 12:29:59 UTC 2023 - 361 bytes - Viewed (0) -
docs/zh/docs/advanced/security/http-basic-auth.md
并返回含 `Basic` 值的请求头 `WWW-Authenticate`以及可选的 `realm` 参数。 HTTP 基础授权让浏览器显示内置的用户名与密码提示。 输入用户名与密码后,浏览器会把它们自动发送至请求头。 ## 简单的 HTTP 基础授权 * 导入 `HTTPBasic` 与 `HTTPBasicCredentials` * 使用 `HTTPBasic` 创建**安全概图** * 在*路径操作*的依赖项中使用 `security` * 返回类型为 `HTTPBasicCredentials` 的对象: * 包含发送的 `username` 与 `password` //// tab | Python 3.9+ ```Python hl_lines="4 8 12" {!> ../../docs_src/security/tutorial006_an_py39.py!} ```
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sun Oct 06 20:36:54 UTC 2024 - 5.2K bytes - Viewed (0) -
fastapi/security/http.py
from typing import Annotated from fastapi import Depends, FastAPI from fastapi.security import HTTPBasic, HTTPBasicCredentials app = FastAPI() security = HTTPBasic() @app.get("/users/me") def read_current_user(credentials: Annotated[HTTPBasicCredentials, Depends(security)]): return {"username": credentials.username, "password": credentials.password} ``` """
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Thu Sep 19 09:47:28 UTC 2024 - 13.2K bytes - Viewed (0)