Search Options

Display Count
Sort
Preferred Language
Advanced Search

Results 1 - 10 of 27 for get_current_active_user (0.51 seconds)

The search processing time has exceeded the limit. The displayed results may be partial.

  1. 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)
  2. 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)
  3. 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)
  4. 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)
  5. 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)
  6. 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)
  7. 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)
  8. 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)
  9. docs/ja/docs/tutorial/security/simple-oauth2.md

    それ以外は **FastAPI** が面倒を見てくれます。
    
    ///
    
    ## 依存関係の更新 { #update-the-dependencies }
    
    ここで依存関係を更新します。
    
    アクティブなユーザーの場合にのみ `current_user` を取得したいとします。
    
    そこで、`get_current_active_user` を依存関係として利用する追加の依存関係 `get_current_active_user` を作成します。
    
    これら2つの依存関係は、ユーザーが存在しない、または非アクティブである場合に、HTTPエラーを返すだけです。
    
    したがって、エンドポイントでは、ユーザーが存在し、正しく認証され、かつアクティブである場合にのみ、ユーザーを取得します:
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Mar 20 14:07:17 GMT 2026
    - 12.1K bytes
    - Click Count (0)
  10. docs/en/docs/tutorial/security/simple-oauth2.md

    ## Update the dependencies { #update-the-dependencies }
    
    Now we are going to update our dependencies.
    
    We want to get the `current_user` *only* if this user is active.
    
    So, we create an additional dependency `get_current_active_user` that in turn uses `get_current_user` as a dependency.
    
    Both of these dependencies will just return an HTTP error if the user doesn't exist, or if is inactive.
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Mar 05 18:13:19 GMT 2026
    - 9.4K bytes
    - Click Count (0)
Back to Top