- Sort Score
- Num 10 results
- Language All
Results 1 - 10 of 31 for get_current_active_user (0.48 seconds)
-
docs_src/security/tutorial004_an_py310.py
@app.get("/users/me/") async def read_users_me( current_user: Annotated[User, Depends(get_current_active_user)], ) -> User: return current_user @app.get("/users/me/items/") async def read_own_items( current_user: Annotated[User, Depends(get_current_active_user)], ):
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Feb 12 18:10:35 GMT 2026 - 4.2K bytes - Click Count (0) -
docs/en/docs/advanced/security/oauth2-scopes.md
In this case, we pass a dependency function `get_current_active_user` to `Security` (the same way we would do with `Depends`). But we also pass a `list` of scopes, in this case with just one scope: `items` (it could have more).
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_src/security/tutorial003_an_py310.py
status_code=status.HTTP_401_UNAUTHORIZED, detail="Not authenticated", headers={"WWW-Authenticate": "Bearer"}, ) return user async def get_current_active_user( current_user: Annotated[User, Depends(get_current_user)], ): if current_user.disabled: raise HTTPException(status_code=400, detail="Inactive user") return current_userCreated: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Mon Nov 24 19:03:06 GMT 2025 - 2.5K bytes - Click Count (0) -
docs_src/security/tutorial004_py310.py
@app.get("/users/me/") async def read_users_me(current_user: User = Depends(get_current_active_user)) -> User: return current_user @app.get("/users/me/items/") async def read_own_items(current_user: User = Depends(get_current_active_user)):
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Feb 12 18:10:35 GMT 2026 - 4.1K bytes - Click Count (0) -
docs_src/security/tutorial005_py310.py
@app.get("/users/me/") async def read_users_me(current_user: User = Depends(get_current_active_user)) -> User: return current_user @app.get("/users/me/items/") async def read_own_items( current_user: User = Security(get_current_active_user, scopes=["items"]), ): return [{"item_id": "Foo", "owner": current_user.username}] @app.get("/status/")
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Feb 12 18:10:35 GMT 2026 - 5.3K bytes - Click Count (0) -
docs_src/security/tutorial005_an_py310.py
@app.get("/users/me/") async def read_users_me( current_user: Annotated[User, Depends(get_current_active_user)], ) -> User: return current_user @app.get("/users/me/items/") async def read_own_items( current_user: Annotated[User, Security(get_current_active_user, scopes=["items"])], ): return [{"item_id": "Foo", "owner": current_user.username}] @app.get("/status/")
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Feb 12 18:10:35 GMT 2026 - 5.4K bytes - Click Count (0) -
docs_src/security/tutorial003_py310.py
status_code=status.HTTP_401_UNAUTHORIZED, detail="Not authenticated", headers={"WWW-Authenticate": "Bearer"}, ) return user async def get_current_active_user(current_user: User = Depends(get_current_user)): if current_user.disabled: raise HTTPException(status_code=400, detail="Inactive user") return current_user @app.post("/token")Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Mon Nov 24 19:03:06 GMT 2025 - 2.4K bytes - Click Count (0) -
docs/zh-hant/docs/advanced/security/oauth2-scopes.md
為此,我們從 `fastapi` 匯入並使用 `Security`。 你可以使用 `Security` 來宣告相依性(就像 `Depends`),但 `Security` 也能接收參數 `scopes`,其為 scopes(字串)的列表。 在這裡,我們將相依函式 `get_current_active_user` 傳給 `Security`(就像使用 `Depends` 一樣)。 但同時也傳入一個 `list` 的 scopes,這裡只有一個 scope:`items`(當然也可以有更多)。 而相依函式 `get_current_active_user` 也能宣告子相依性,不只用 `Depends`,也能用 `Security`。它宣告了自己的子相依函式(`get_current_user`),並加入更多 scope 要求。 在這個例子中,它要求 `me` 這個 scope(也可以要求多個)。 /// note
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) -
docs/zh/docs/advanced/security/oauth2-scopes.md
再次回顾这个依赖树与作用域。 由于 `get_current_active_user` 依赖把 `get_current_user` 作为子依赖,因此在 `get_current_active_user` 中声明的作用域 `"me"` 会被包含在传给 `get_current_user` 的 `security_scopes.scopes` 所需作用域列表中。 *路径操作*本身也声明了一个作用域 `"items"`,它也会包含在传给 `get_current_user` 的 `security_scopes.scopes` 列表中。 依赖与作用域的层级结构如下: * *路径操作* `read_own_items` 包含: * 带有依赖的必需作用域 `["items"]`: * `get_current_active_user`:
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Fri Mar 20 17:06:37 GMT 2026 - 13K bytes - Click Count (0) -
docs/ja/docs/advanced/security/oauth2-scopes.md
そのために、`fastapi` から `Security` をインポートして使います。 `Security` は(`Depends` と同様に)依存関係を宣言できますが、さらにスコープ(文字列)のリストを受け取る `scopes` パラメータも持ちます。 この場合、`Security` に依存関数 `get_current_active_user` を渡します(`Depends` と同様です)。 加えて、`items` という 1 つのスコープ(複数でも可)を含む `list` も渡します。 依存関数 `get_current_active_user` は、`Depends` だけでなく `Security` でもサブ依存関係を宣言できます。自身のサブ依存関数(`get_current_user`)を宣言し、さらにスコープ要件を追加します。 この場合、`me` スコープを要求します(複数のスコープも可)。 /// note | 備考
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Fri Mar 20 14:07:17 GMT 2026 - 16.6K bytes - Click Count (0)