コンテンツにスキップ
per page, with , order by , clip by
Results of 1 - 10 of about 19 for username (0.010 sec.)
OAuth2 scopes 11611
OAuth2 scopes Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . You can use OAuth2 scopes directly with FastAPI , they are integrated to work seamlessly. This would ... 9563b93f7099f6f0f4caa6cf63b88e8d3e7" ALGORITHM = "HS256" ACCESS_TOKEN_EXPIRE_MINUTES = 30 fake_users_db = { "johndoe" : { "username" : "johndoe" , "full_name" : "John Doe" , "email" : "johndoe@example.com" , "hashed_password" : "$2b$12$EixZaYVK1fsbw1ZfbX ... 3OXePaWxn96p36WQoeG6Lruj3vjPGga31lW" , "disabled" : False , }, "alice" : { "username" : "alice" , "full_name" : "Alice Chains" , "email" : "alicechains@example.com" , "hashed_password" : "$2b$12$gSvqqUPvlXP2 ... " , "disabled" : True , }, } class Token ( BaseModel ): access_token : str token_type : str class TokenData ( BaseModel ): username : str | None = None scopes : list [ str ] = [] class User ( BaseModel ): username : str email : str | None = None full_nam ...
https://man.mtool.work/fastapi/0.115/advanced/security/oauth2-scopes/
パスワード(およびハッシュ化)によるOAuth2、JWTトークンによるBearer 11423
パスワード(およびハッシュ化)によるOAuth2、JWTトークンによるBearer これでセキュリティの流れが全てわかったので、 JWT トークンと安全なパスワードのハッシュ化を使用して、実際にアプリケーションを安全にしてみましょう。 このコードは、アプリケーシ ... 9563b93f7099f6f0f4caa6cf63b88e8d3e7" ALGORITHM = "HS256" ACCESS_TOKEN_EXPIRE_MINUTES = 30 fake_users_db = { "johndoe" : { "username" : "johndoe" , "full_name" : "John Doe" , "email" : "johndoe@example.com" , "hashed_password" : "$2b$12$EixZaYVK1fsbw1ZfbX ... " , "disabled" : False , } } class Token ( BaseModel ): access_token : str token_type : str class TokenData ( BaseModel ): username : Union [ str , None ] = None class User ( BaseModel ): username : str email : Union [ str , None ] = None full_name : Uni ... assword , hashed_password ) def get_password_hash ( password ): return pwd_context . hash ( password ) def get_user ( db , username : str ): if username in db : user_dict = db [ username ] return UserInDB ( ** user_dict ) def authenticate_user ( fake_db ...
https://man.mtool.work/fastapi/0.115/tutorial/security/oauth2-jwt/
HTTP Basic Auth 11303
HTTP Basic Auth Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . For the simplest cases, you can use HTTP Basic Auth. In HTTP Basic Auth, the application expects a ... header that contains a username and a password. If it doesn't receive it, it returns an HTTP 401 "Unauthorized" error. And returns a header WWW-Authentica ... te with a value of Basic , and an optional realm parameter. That tells the browser to show the integrated prompt for a username and password. Then, when you type that username and password, the browser sends them in the header automatically. Simple H ... at security with a dependency in your path operation . It returns an object of type HTTPBasicCredentials : It contains the username and password sent. Python 3.9+ from typing import Annotated from fastapi import Depends , FastAPI from fastapi.security im ...
https://man.mtool.work/fastapi/0.115/advanced/security/http-basic-auth/
Simple OAuth2 with Password and Bearer 11303
Simple OAuth2 with Password and Bearer Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . Now let's build from the previous chapter and add the missing parts to have ... a complete security flow. Get the username and password We are going to use FastAPI security utilities to get the username and password . OAuth2 specifies that when ... using the "password flow" (that we are using) the client/user must send a username and password fields as form data. And the spec says that the fields have to be named like that. So user-name or email woul ... le with the spec (and be able to, for example, use the integrated API documentation system). The spec also states that the username and password must be sent as form data (so, no JSON here). scope The spec also says that the client can send another form ...
https://man.mtool.work/fastapi/0.115/tutorial/security/simple-oauth2/
現在のユーザーの取得 9784
現在のユーザーの取得 一つ前の章では、(依存性注入システムに基づいた)セキュリティシステムは、 path operation関数 に str として token を与えていました: Python 3.8+ - non-Annotated from fastapi import Depends , FastAPI from fastapi.security i ... ic import BaseModel app = FastAPI () oauth2_scheme = OAuth2PasswordBearer ( tokenUrl = "token" ) class User ( BaseModel ): username : str email : Union [ str , None ] = None full_name : Union [ str , None ] = None disabled : Union [ bool , None ] = None ... def fake_decode_token ( token ): return User ( username = token + "fakedecoded" , email = "john@example.com" , full_name = "John Doe" ) async def get_current_user ( token : str = ... ic import BaseModel app = FastAPI () oauth2_scheme = OAuth2PasswordBearer ( tokenUrl = "token" ) class User ( BaseModel ): username : str email : str | None = None full_name : str | None = None disabled : bool | None = None def fake_decode_token ( token ...
https://man.mtool.work/fastapi/0.115/tutorial/security/get-current-user/
フォームデータ 9664
フォームデータ JSONの代わりにフィールドを受け取る場合は、 Form を使用します。 情報 フォームを使うためには、まず python-multipart をインストールします。 たとえば、 pip install python-multipart のように。 Form のインポート fastapi から Form を ... ython 3.8+ - non-Annotated from fastapi import FastAPI , Form app = FastAPI () @app . post ( "/login/" ) async def login ( username : str = Form (), password : str = Form ()): return { "username" : username } ? Other versions and variants Python 3.9+ Pyt ... om typing import Annotated from fastapi import FastAPI , Form app = FastAPI () @app . post ( "/login/" ) async def login ( username : Annotated [ str , Form ()], password : Annotated [ str , Form ()]): return { "username" : username } from fastapi import ... FastAPI , Form from typing_extensions import Annotated app = FastAPI () @app . post ( "/login/" ) async def login ( username : Annotated [ str , Form ()], password : Annotated [ str , Form ()]): return { "username" : username } Form のパラメータの ...
https://man.mtool.work/fastapi/0.115/tutorial/request-forms/
Custom Docs UI Static Assets (Self-Hosting) 8554
Custom Docs UI Static Assets (Self-Hosting) Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . The API docs use Swagger UI and ReDoc , and each of those need some Jav ... title + " - ReDoc" , redoc_js_url = "https://unpkg.com/redoc@next/bundles/redoc.standalone.js" , ) @app . get ( "/users/ {username} " ) async def read_user ( username : str ): return { "message" : f "Hello { username } " } Include the custom docs Now yo ... title + " - ReDoc" , redoc_js_url = "https://unpkg.com/redoc@next/bundles/redoc.standalone.js" , ) @app . get ( "/users/ {username} " ) async def read_user ( username : str ): return { "message" : f "Hello { username } " } Tip The path operation for swa ... title + " - ReDoc" , redoc_js_url = "https://unpkg.com/redoc@next/bundles/redoc.standalone.js" , ) @app . get ( "/users/ {username} " ) async def read_user ( username : str ): return { "message" : f "Hello { username } " } Test it Now, you should be abl ...
https://man.mtool.work/fastapi/0.115/how-to/custom-docs-ui-assets/
モデル - より詳しく 8059
モデル - より詳しく 先ほどの例に続き、複数の関連モデルを持つことが一般的です。 これはユーザーモデルの場合は特にそうです。なぜなら: 入力モデル にはパスワードが必要です。 出力モデル はパスワードをもつべきではありません。 データベースモデル は ... t Union from fastapi import FastAPI from pydantic import BaseModel , EmailStr app = FastAPI () class UserIn ( BaseModel ): username : str password : str email : EmailStr full_name : Union [ str , None ] = None class UserOut ( BaseModel ): username : str ... email : EmailStr full_name : Union [ str , None ] = None class UserInDB ( BaseModel ): username : str hashed_password : str email : EmailStr full_name : Union [ str , None ] = None def fake_password_hasher ( raw_passwo ... n 3.10+ from fastapi import FastAPI from pydantic import BaseModel , EmailStr app = FastAPI () class UserIn ( BaseModel ): username : str password : str email : EmailStr full_name : str | None = None class UserOut ( BaseModel ): username : str email : Em ...
https://man.mtool.work/fastapi/0.115/tutorial/extra-models/
Form Models 7957
Form Models Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . You can use Pydantic models to declare form fields in FastAPI. Info To use forms, first install python- ... Annotated from fastapi import FastAPI , Form from pydantic import BaseModel app = FastAPI () class FormData ( BaseModel ): username : str password : str @app . post ( "/login/" ) async def login ( data : Annotated [ FormData , Form ()]): return data ? Ot ... Form from pydantic import BaseModel from typing_extensions import Annotated app = FastAPI () class FormData ( BaseModel ): username : str password : str @app . post ( "/login/" ) async def login ( data : Annotated [ FormData , Form ()]): return data Tip ... possible. from fastapi import FastAPI , Form from pydantic import BaseModel app = FastAPI () class FormData ( BaseModel ): username : str password : str @app . post ( "/login/" ) async def login ( data : FormData = Form ()): return data FastAPI will extr ...
https://man.mtool.work/fastapi/0.115/tutorial/request-form-models/
レスポンスモデル 7752
レスポンスモデル path operations のいずれにおいても、 response_model パラメータを使用して、レスポンスのモデルを宣言することができます: @app.get() @app.post() @app.put() @app.delete() など。 Python 3.8+ from typing import Any , List , Union ... t Union from fastapi import FastAPI from pydantic import BaseModel , EmailStr app = FastAPI () class UserIn ( BaseModel ): username : str password : str email : EmailStr full_name : Union [ str , None ] = None # Don't do this in production! @app . post ( ... n 3.10+ from fastapi import FastAPI from pydantic import BaseModel , EmailStr app = FastAPI () class UserIn ( BaseModel ): username : str password : str email : EmailStr full_name : str | None = None # Don't do this in production! @app . post ( "/user/" ... t Union from fastapi import FastAPI from pydantic import BaseModel , EmailStr app = FastAPI () class UserIn ( BaseModel ): username : str password : str email : EmailStr full_name : Union [ str , None ] = None # Don't do this in production! @app . post ( ...
https://man.mtool.work/fastapi/0.115/tutorial/response-model/
PREV 1 2 NEXT