Search Options

Display Count
Sort
Preferred Language
Advanced Search

Results 1 - 10 of 21 for get_current_active_user (0.11 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/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)
  3. 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_user
    
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Mon Nov 24 19:03:06 GMT 2025
    - 2.5K bytes
    - Click Count (0)
  4. 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)
  5. 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)
  6. 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)
  7. 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)
  8. docs/zh/docs/tutorial/security/simple-oauth2.md

    这几乎是唯一需要开发者牢记在心,并按规范要求正确执行的事。
    
    **FastAPI** 则负责处理其它的工作。
    
    ///
    
    ## 更新依赖项 { #update-the-dependencies }
    
    接下来,更新依赖项。
    
    使之仅在当前用户为激活状态时,才能获取 `current_user`。
    
    为此,要再创建一个依赖项 `get_current_active_user`,此依赖项以 `get_current_user` 依赖项为基础。
    
    如果用户不存在,或状态为未激活,这两个依赖项都会返回 HTTP 错误。
    
    因此,在端点中,只有当用户存在、通过身份验证、且状态为激活时,才能获得该用户:
    
    {* ../../docs_src/security/tutorial003_an_py310.py hl[58:66,69:74,94] *}
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Mar 20 17:06:37 GMT 2026
    - 9K bytes
    - Click Count (0)
  9. docs/tr/docs/advanced/security/oauth2-scopes.md

    Bu durumda `Security`'ye dependency fonksiyonu olarak `get_current_active_user` veriyoruz (`Depends` ile yaptığımız gibi).
    
    Ama ayrıca bir `list` olarak scope'ları da veriyoruz; burada tek bir scope var: `items` (daha fazla da olabilir).
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Mar 20 07:53:17 GMT 2026
    - 14.7K bytes
    - Click Count (0)
  10. docs/ru/docs/advanced/security/oauth2-scopes.md

    В этом случае мы передаём функцию‑зависимость `get_current_active_user` в `Security` (точно так же, как сделали бы с `Depends`).
    
    Но мы также передаём `list` scopes — в данном случае только один scope: `items` (их могло быть больше).
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Mar 19 17:56:20 GMT 2026
    - 20.6K bytes
    - Click Count (0)
Back to Top