Search Options

Results per page
Sort
Preferred Languages
Advance

Results 11 - 16 of 16 for TokenData (0.07 sec)

  1. docs_src/security/tutorial005_an.py

            "disabled": True,
        },
    }
    
    
    class Token(BaseModel):
        access_token: str
        token_type: str
    
    
    class TokenData(BaseModel):
        username: Union[str, None] = None
        scopes: List[str] = []
    
    
    class User(BaseModel):
        username: str
        email: Union[str, None] = None
        full_name: Union[str, None] = None
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Mon May 20 17:37:28 UTC 2024
    - 5.3K bytes
    - Viewed (0)
  2. docs/zh/docs/advanced/security/oauth2-scopes.md

    ## 校验 `username` 与数据形状
    
    我们可以校验是否获取了 `username`,并抽取作用域。
    
    然后,使用 Pydantic 模型校验数据(捕获 `ValidationError` 异常),如果读取 JWT 令牌或使用 Pydantic 模型验证数据时出错,就会触发之前创建的 `HTTPException` 异常。
    
    对此,要使用新的属性 `scopes` 更新 Pydantic 模型 `TokenData`。
    
    使用 Pydantic 验证数据可以确保数据中含有由作用域组成的**字符串列表**,以及 `username` 字符串等内容。
    
    反之,如果使用**字典**或其它数据结构,就有可能在后面某些位置破坏应用,形成安全隐患。
    
    还可以使用用户名验证用户,如果没有用户,也会触发之前创建的异常。
    
    ```Python hl_lines="46  116-127"
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 11.8K bytes
    - Viewed (0)
  3. docs/em/docs/advanced/security/oauth2-scopes.md

    👥 ✔ 👈 👥 🤚 `username`, & ⚗ ↔.
    
    & ⤴️ 👥 ✔ 👈 📊 ⏮️ Pydantic 🏷 (✊ `ValidationError` ⚠), & 🚥 👥 🤚 ❌ 👂 🥙 🤝 ⚖️ ⚖ 📊 ⏮️ Pydantic, 👥 🤚 `HTTPException` 👥 ✍ ⏭.
    
    👈, 👥 ℹ Pydantic 🏷 `TokenData` ⏮️ 🆕 🏠 `scopes`.
    
    ⚖ 📊 ⏮️ Pydantic 👥 💪 ⚒ 💭 👈 👥 ✔️, 🖼, ⚫️❔ `list` `str` ⏮️ ↔ & `str` ⏮️ `username`.
    
    ↩️, 🖼, `dict`, ⚖️ 🕳 🙆, ⚫️ 💪 💔 🈸 ☝ ⏪, ⚒ ⚫️ 💂‍♂ ⚠.
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 11K bytes
    - Viewed (0)
  4. docs/en/docs/advanced/security/oauth2-scopes.md

    For that, we update the Pydantic model `TokenData` with a new property `scopes`.
    
    By validating the data with Pydantic we can make sure that we have, for example, exactly a `list` of `str` with the scopes and a `str` with the `username`.
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Tue Oct 29 11:02:16 UTC 2024
    - 13.1K bytes
    - Viewed (0)
  5. docs/de/docs/advanced/security/oauth2-scopes.md

    Dazu aktualisieren wir das Pydantic-Modell `TokenData` mit einem neuen Attribut `scopes`.
    
    Durch die Validierung der Daten mit Pydantic können wir sicherstellen, dass wir beispielsweise präzise eine `list`e von `str`s mit den Scopes und einen `str` mit dem `username` haben.
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 22.5K bytes
    - Viewed (0)
  6. docs/pt/docs/advanced/security/oauth2-scopes.md

    Para isso, nós atualizamos o modelo Pydantic `TokenData` com a nova propriedade `scopes`.
    
    Ao validar os dados com o Pydantic nós podemos garantir que temos, por exemplo, exatamente uma `list` de `str` com os escopos e uma `str` com o `username`.
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 21.7K bytes
    - Viewed (0)
Back to top