- Sort Score
- Num 10 results
- Language All
Results 1 - 10 of 283 for Security (0.14 seconds)
The search processing time has exceeded the limit. The displayed results may be partial.
-
docs/en/docs/advanced/security/oauth2-scopes.md
{* ../../docs_src/security/tutorial005_an_py310.py hl[5,9,13,47,65,106,108:116,122:126,130:136,141,157] *} Now let's review those changes step by step. ## OAuth2 Security scheme { #oauth2-security-scheme } The first change is that now we are declaring the OAuth2 security scheme with two available scopes, `me` and `items`.Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Mar 05 18:13:19 GMT 2026 - 13.4K bytes - Click Count (0) -
docs/en/docs/advanced/security/index.md
# Advanced Security { #advanced-security } ## Additional Features { #additional-features } There are some extra features to handle security apart from the ones covered in the [Tutorial - User Guide: Security](../../tutorial/security/index.md). /// tip The next sections are **not necessarily "advanced"**. And it's possible that for your use case, the solution is in one of them. /// ## Read the Tutorial first { #read-the-tutorial-first }Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Mar 05 18:13:19 GMT 2026 - 648 bytes - Click Count (0) -
docs/en/docs/tutorial/security/get-current-user.md
# Get Current User { #get-current-user } In the previous chapter the security system (which is based on the dependency injection system) was giving the *path operation function* a `token` as a `str`: {* ../../docs_src/security/tutorial001_an_py310.py hl[12] *} But that is still not that useful. Let's make it give us the current user. ## Create a user model { #create-a-user-model } First, let's create a Pydantic user model.Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Feb 12 13:19:43 GMT 2026 - 4K bytes - Click Count (0) -
tests/test_security_oauth2_authorization_code_bearer_scopes_openapi.py
"/with-oauth2-scheme", dependencies=[Security(oauth2_scheme, scopes=["read", "write"])], ) async def read_with_oauth2_scheme(): return {"message": "Admin Access"} @app.get( "/with-get-token", dependencies=[Security(get_token, scopes=["read", "write"])] ) async def read_with_get_token(): return {"message": "Admin Access"} router = APIRouter(dependencies=[Security(oauth2_scheme, scopes=["read"])])Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Tue Feb 17 09:59:14 GMT 2026 - 6.6K bytes - Click Count (0) -
docs/zh-hant/docs/advanced/security/oauth2-scopes.md
{* ../../docs_src/security/tutorial005_an_py310.py hl[5,9,13,47,65,106,108:116,122:126,130:136,141,157] *} 接著我們一步一步檢視這些變更。 ## OAuth2 安全性方案 { #oauth2-security-scheme } 第一個變更是:我們現在宣告了帶有兩個可用 scope 的 OAuth2 安全性方案,`me` 與 `items`。 參數 `scopes` 接收一個 `dict`,以各 scope 為鍵、其描述為值: {* ../../docs_src/security/tutorial005_an_py310.py hl[63:66] *}Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Fri Mar 20 17:05:38 GMT 2026 - 12.7K bytes - Click Count (0) -
tests/test_dependency_paramless.py
from typing import Annotated from fastapi import FastAPI, HTTPException, Security from fastapi.security import ( OAuth2PasswordBearer, SecurityScopes, ) from fastapi.testclient import TestClient app = FastAPI() oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token") def process_auth( credentials: Annotated[str | None, Security(oauth2_scheme)], security_scopes: SecurityScopes, ):
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Tue Feb 17 09:59:14 GMT 2026 - 2.3K bytes - Click Count (0) -
docs/en/docs/tutorial/security/first-steps.md
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Sat Mar 07 09:29:03 GMT 2026 - 8.3K bytes - Click Count (0) -
docs/zh/docs/advanced/security/oauth2-scopes.md
/// {* ../../docs_src/security/tutorial005_an_py310.py hl[157] *} ## 在*路径操作*与依赖项中声明作用域 { #declare-scopes-in-path-operations-and-dependencies } 现在我们声明,路径操作 `/users/me/items/` 需要作用域 `items`。 为此,从 `fastapi` 导入并使用 `Security`。 你可以用 `Security` 来声明依赖(就像 `Depends` 一样),但 `Security` 还接收一个 `scopes` 参数,其值是作用域(字符串)列表。 在这里,我们把依赖函数 `get_current_active_user` 传给 `Security`(就像用 `Depends` 一样)。Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Fri Mar 20 17:06:37 GMT 2026 - 13K bytes - Click Count (0) -
fastapi/security/oauth2.py
from fastapi.openapi.models import OAuth2 as OAuth2Model from fastapi.openapi.models import OAuthFlows as OAuthFlowsModel from fastapi.param_functions import Form from fastapi.security.base import SecurityBase from fastapi.security.utils import get_authorization_scheme_param from starlette.requests import Request from starlette.status import HTTP_401_UNAUTHORIZED class OAuth2PasswordRequestForm: """Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Tue Mar 24 16:32:10 GMT 2026 - 23.6K bytes - Click Count (0) -
tests/test_security_oauth2_password_bearer_optional_description.py
from fastapi import FastAPI, Security from fastapi.security import OAuth2PasswordBearer from fastapi.testclient import TestClient from inline_snapshot import snapshot app = FastAPI() oauth2_scheme = OAuth2PasswordBearer( tokenUrl="/token", description="OAuth2PasswordBearer security scheme", auto_error=False, ) @app.get("/items/") async def read_items(token: str | None = Security(oauth2_scheme)): if token is None:
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Tue Feb 17 09:59:14 GMT 2026 - 2.4K bytes - Click Count (0)