Search Options

Display Count
Sort
Preferred Language
Advanced Search

Results 1 - 10 of 35 for get_current_user (0.09 seconds)

  1. docs/zh-hant/docs/advanced/security/oauth2-scopes.md

    ## 相依性樹與 scopes { #dependency-tree-and-scopes }
    
    我們再回顧一次這個相依性樹與 scopes。
    
    由於 `get_current_active_user` 相依於 `get_current_user`,因此在 `get_current_active_user` 宣告的 `"me"` 這個 scope 會包含在傳給 `get_current_user` 的 `security_scopes.scopes` 的必須 scopes 清單中。
    
    路徑操作本身也宣告了 `"items"` 這個 scope,因此它也會包含在傳給 `get_current_user` 的 `security_scopes.scopes` 中。
    
    以下是相依性與 scopes 的階層關係:
    
    - 路徑操作 `read_own_items` 具有:
      - 需要的 scopes `["items"]`,並有相依性:
    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)
  2. docs/zh/docs/advanced/security/oauth2-scopes.md

    ## 依赖树与作用域 { #dependency-tree-and-scopes }
    
    再次回顾这个依赖树与作用域。
    
    由于 `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"]`:
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Mar 20 17:06:37 GMT 2026
    - 13K bytes
    - Click Count (0)
  3. docs/ja/docs/advanced/security/oauth2-scopes.md

    ## 依存関係ツリーとスコープ { #dependency-tree-and-scopes }
    
    依存関係ツリーとスコープをもう一度見てみましょう。
    
    `get_current_active_user` 依存関係は `get_current_user` をサブ依存として持つため、`get_current_active_user` で宣言された `"me"` スコープは、`get_current_user` に渡される `security_scopes.scopes` の必須スコープ一覧に含まれます。
    
    path operation 自体も `"items"` スコープを宣言するため、これも `get_current_user` に渡される `security_scopes.scopes` に含まれます。
    
    依存関係とスコープの階層は次のようになります:
    
    - *path operation* `read_own_items` には:
    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)
  4. docs/en/docs/advanced/security/oauth2-scopes.md

    As the `get_current_active_user` dependency has as a sub-dependency on `get_current_user`, the scope `"me"` declared at `get_current_active_user` will be included in the list of required scopes in the `security_scopes.scopes` passed to `get_current_user`.
    
    The *path operation* itself also declares a scope, `"items"`, so this will also be in the list of `security_scopes.scopes` passed to `get_current_user`.
    
    Here's how the hierarchy of dependencies and scopes looks like:
    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)
  5. fastapi/.agents/skills/fastapi/SKILL.md

    ```python
    from typing import Annotated
    
    from fastapi import Depends, FastAPI
    
    app = FastAPI()
    
    
    def get_current_user():
        return {"username": "johndoe"}
    
    
    CurrentUserDep = Annotated[dict, Depends(get_current_user)]
    
    
    @app.get("/items/")
    async def read_item(current_user: CurrentUserDep):
        return {"message": "Hello World"}
    ```
    
    instead of:
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sun Mar 01 10:05:57 GMT 2026
    - 10.1K bytes
    - Click Count (0)
  6. tests/test_security_oauth2.py

            }
        }
    )
    
    
    class User(BaseModel):
        username: str
    
    
    # Here we use string annotations to test them
    def get_current_user(oauth_header: "str" = Security(reusable_oauth2)):
        user = User(username=oauth_header)
        return user
    
    
    @app.post("/login")
    # Here we use string annotations to test them
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sun Feb 08 10:18:38 GMT 2026
    - 9.8K bytes
    - Click Count (0)
  7. tests/test_security_oauth2_optional_description.py

            }
        },
        description="OAuth2 security scheme",
        auto_error=False,
    )
    
    
    class User(BaseModel):
        username: str
    
    
    def get_current_user(oauth_header: str | None = Security(reusable_oauth2)):
        if oauth_header is None:
            return None
        user = User(username=oauth_header)
        return user
    
    
    @app.post("/login")
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Tue Feb 17 09:59:14 GMT 2026
    - 9.9K bytes
    - Click Count (0)
  8. docs/en/docs/tutorial/security/oauth2-jwt.md

    Create a utility function to generate a new access token.
    
    {* ../../docs_src/security/tutorial004_an_py310.py hl[4,7,13:15,29:31,82:90] *}
    
    ## Update the dependencies { #update-the-dependencies }
    
    Update `get_current_user` to receive the same token as before, but this time, using JWT tokens.
    
    Decode the received token, verify it, and return the current user.
    
    If the token is invalid, return an HTTP error right away.
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Mar 05 18:13:19 GMT 2026
    - 10.7K bytes
    - Click Count (0)
  9. docs/zh-hant/docs/tutorial/security/oauth2-jwt.md

    建立一個權杖有效期的變數。
    
    定義一個用於權杖端點回應的 Pydantic Model。
    
    建立一個工具函式來產生新的 access token。
    
    {* ../../docs_src/security/tutorial004_an_py310.py hl[4,7,13:15,29:31,82:90] *}
    
    ## 更新相依項目 { #update-the-dependencies }
    
    更新 `get_current_user`,讓它仍接收相同的權杖,但這次改用 JWT 權杖。
    
    解碼收到的權杖、驗證它,並回傳目前的使用者。
    
    如果權杖無效,立即回傳一個 HTTP 錯誤。
    
    {* ../../docs_src/security/tutorial004_an_py310.py hl[93:110] *}
    
    ## 更新 `/token` 路徑操作 { #update-the-token-path-operation }
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Mar 20 17:05:38 GMT 2026
    - 10.1K bytes
    - Click Count (0)
  10. docs/zh/docs/tutorial/security/oauth2-jwt.md

    创建一个变量用于设置令牌的过期时间。
    
    定义一个用于令牌端点响应的 Pydantic 模型。
    
    创建一个生成新访问令牌的工具函数。
    
    {* ../../docs_src/security/tutorial004_an_py310.py hl[4,7,13:15,29:31,82:90] *}
    
    ## 更新依赖项 { #update-the-dependencies }
    
    更新 `get_current_user` 以接收与之前相同的令牌,但这次使用的是 JWT 令牌。
    
    解码接收到的令牌,进行校验,并返回当前用户。
    
    如果令牌无效,立即返回一个 HTTP 错误。
    
    {* ../../docs_src/security/tutorial004_an_py310.py hl[93:110] *}
    
    ## 更新 `/token` 路径操作 { #update-the-token-path-operation }
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Mar 20 17:06:37 GMT 2026
    - 10.1K bytes
    - Click Count (0)
Back to Top