コンテンツにスキップ
per page, with , order by , clip by
Results of 1 - 7 of about 7 for scheme (0.008 sec.)
現在のユーザーの取得 11905
現在のユーザーの取得 一つ前の章では、(依存性注入システムに基づいた)セキュリティシステムは、 path operation関数 に str として token を与えていました: Python 3.8+ - non-Annotated from fastapi import Depends , FastAPI from fastapi.security i ... mport OAuth2PasswordBearer app = FastAPI () oauth2_scheme = OAuth2PasswordBearer ( tokenUrl = "token" ) @app . get ( "/items/" ) async def read_items ( token : str = Depends ( oaut ... h2_scheme )): return { "token" : token } ? Other versions and variants Python 3.9+ Python 3.8+ from typing import Annotated from fas ... tapi import Depends , FastAPI from fastapi.security import OAuth2PasswordBearer app = FastAPI () oauth2_scheme = OAuth2PasswordBearer ( tokenUrl = "token" ) @app . get ( "/items/" ) async def read_items ( token : Annotated [ str , De ...
https://man.mtool.work/fastapi/0.115/tutorial/security/get-current-user/
Simple OAuth2 with Password and Bearer 10269
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 ... "disabled" : True , }, } app = FastAPI () def fake_hash_password ( password : str ): return "fakehashed" + password oauth2_scheme = OAuth2PasswordBearer ( tokenUrl = "token" ) class User ( BaseModel ): username : str email : str | None = None full_name ... r = get_user ( fake_users_db , token ) return user async def get_current_user ( token : Annotated [ str , Depends ( oauth2_scheme )]): user = fake_decode_token ( token ) if not user : raise HTTPException ( status_code = status . HTTP_401_UNAUTHORIZED , ... "disabled" : True , }, } app = FastAPI () def fake_hash_password ( password : str ): return "fakehashed" + password oauth2_scheme = OAuth2PasswordBearer ( tokenUrl = "token" ) class User ( BaseModel ): username : str email : Union [ str , None ] = None ...
https://man.mtool.work/fastapi/0.115/tutorial/security/simple-oauth2/
セキュリティ - 最初の一歩 9742
セキュリティ - 最初の一歩 あるドメインに、 バックエンド APIを持っているとしましょう。 そして、別のドメインか同じドメインの違うパス(またはモバイルアプリケーションの中)に フロントエンド を持っています。 さらに、フロントエンドが ユーザー名 と ... -Annotated from fastapi import Depends , FastAPI from fastapi.security import OAuth2PasswordBearer app = FastAPI () oauth2_scheme = OAuth2PasswordBearer ( tokenUrl = "token" ) @app . get ( "/items/" ) async def read_items ( token : str = Depends ( oaut ... h2_scheme )): return { "token" : token } ? Other versions and variants Python 3.9+ Python 3.8+ from typing import Annotated from fas ... tapi import Depends , FastAPI from fastapi.security import OAuth2PasswordBearer app = FastAPI () oauth2_scheme = OAuth2PasswordBearer ( tokenUrl = "token" ) @app . get ( "/items/" ) async def read_items ( token : Annotated [ str , De ...
https://man.mtool.work/fastapi/0.115/tutorial/security/first-steps/
OAuth2 scopes 9615
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 ... should not contain spaces. These scopes represent "permissions". In OpenAPI (e.g. the API docs), you can define "security schemes". When one of these security schemes uses OAuth2, you can also declare and use scopes. Each "scope" is just a string (wit ... tr | None = None disabled : bool | None = None class UserInDB ( User ): hashed_password : str pwd_context = CryptContext ( schemes = [ "bcrypt" ], deprecated = "auto" ) oauth2_scheme = OAuth2PasswordBearer ( tokenUrl = "token" , scopes = { "me" : "Read ... urn encoded_jwt async def get_current_user ( security_scopes : SecurityScopes , token : Annotated [ str , Depends ( oauth2_scheme )] ): if security_scopes . scopes : authenticate_value = f 'Bearer scope=" { security_scopes . scope_str } "' else : authe ...
https://man.mtool.work/fastapi/0.115/advanced/security/oauth2-scopes/
パスワード(およびハッシュ化)によるOAuth2、JWTトークンによるBearer 8942
パスワード(およびハッシュ化)によるOAuth2、JWTトークンによるBearer これでセキュリティの流れが全てわかったので、 JWT トークンと安全なパスワードのハッシュ化を使用して、実際にアプリケーションを安全にしてみましょう。 このコードは、アプリケーシ ... = None disabled : Union [ bool , None ] = None class UserInDB ( User ): hashed_password : str pwd_context = CryptContext ( schemes = [ "bcrypt" ], deprecated = "auto" ) oauth2_scheme = OAuth2PasswordBearer ( tokenUrl = "token" ) app = FastAPI () def ve ... code , SECRET_KEY , algorithm = ALGORITHM ) return encoded_jwt async def get_current_user ( token : str = Depends ( oauth2_scheme )): credentials_exception = HTTPException ( status_code = status . HTTP_401_UNAUTHORIZED , detail = "Could not validate cr ... tr | None = None disabled : bool | None = None class UserInDB ( User ): hashed_password : str pwd_context = CryptContext ( schemes = [ "bcrypt" ], deprecated = "auto" ) oauth2_scheme = OAuth2PasswordBearer ( tokenUrl = "token" ) app = FastAPI () def ve ...
https://man.mtool.work/fastapi/0.115/tutorial/security/oauth2-jwt/
Advanced Middleware 6616
Advanced Middleware Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . In the main tutorial you read how to add Custom Middleware to your application. And then you al ... at all incoming requests must either be https or wss . Any incoming request to http or ws will be redirected to the secure scheme instead. Python 3.8+ from fastapi import FastAPI from fastapi.middleware.httpsredirect import HTTPSRedirectMiddleware app ...
https://man.mtool.work/fastapi/0.115/advanced/middleware/
HTTP Basic Auth 6452
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 ... s them in the header automatically. Simple HTTP Basic Auth Import HTTPBasic and HTTPBasicCredentials . Create a " security scheme" using HTTPBasic . Use that security with a dependency in your path operation . It returns an object of type HTTPBasicCred ...
https://man.mtool.work/fastapi/0.115/advanced/security/http-basic-auth/
PREV 1 NEXT