コンテンツにスキップ
per page, with , order by , clip by
Results of 1 - 8 of about 8 for credentials (0.011 sec.)
OAuth2 scopes 11386
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 ... . scopes : authenticate_value = f 'Bearer scope=" { security_scopes . scope_str } "' else : authenticate_value = "Bearer" credentials_exception = HTTPException ( status_code = status . HTTP_401_UNAUTHORIZED , detail = "Could not validate credentials" , hea ... . decode ( token , SECRET_KEY , algorithms = [ ALGORITHM ]) username = payload . get ( "sub" ) if username is None : raise credentials_exception token_scopes = payload . get ( "scopes" , []) token_data = TokenData ( scopes = token_scopes , username = userna ... me ) except ( InvalidTokenError , ValidationError ): raise credentials_exception user = get_user ( fake_users_db , username = token_data . username ) if user is None : raise credentials_excepti ...
https://man.mtool.work/fastapi/0.115/advanced/security/oauth2-scopes/
HTTP Basic Auth 11350
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 ... ame and password, the browser sends 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 HTTPBasicCredentials : It contains the username and password sent. Python 3.9+ from typing import Annotated from fastapi import Depends , FastA ... PI from fastapi.security import HTTPBasic , HTTPBasicCredentials app = FastAPI () security = HTTPBasic () @app . get ( "/users/me" ) def read_current_user ( credentials : Annotated [ HTTP ...
https://man.mtool.work/fastapi/0.115/advanced/security/http-basic-auth/
パスワード(およびハッシュ化)によるOAuth2、JWTトークンによるBearer 11188
パスワード(およびハッシュ化)によるOAuth2、JWTトークンによるBearer これでセキュリティの流れが全てわかったので、 JWT トークンと安全なパスワードのハッシュ化を使用して、実際にアプリケーションを安全にしてみましょう。 このコードは、アプリケーシ ... ET_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 credentials" , hea ... . decode ( token , SECRET_KEY , algorithms = [ ALGORITHM ]) username = payload . get ( "sub" ) if username is None : raise credentials_exception token_data = TokenData ( username = username ) except InvalidTokenError : raise credentials_exception user = get ... _user ( fake_users_db , username = token_data . username ) if user is None : raise credentials_exception return user async def get_current_active_user ( current_user : User = Depends ( get_current_user )): if current_ ...
https://man.mtool.work/fastapi/0.115/tutorial/security/oauth2-jwt/
Simple OAuth2 with Password and Bearer 8603
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 ... oken ) if not user : raise HTTPException ( status_code = status . HTTP_401_UNAUTHORIZED , detail = "Invalid authentication credentials" , headers = { "WWW-Authenticate" : "Bearer" }, ) return user async def get_current_active_user ( current_user : Annotated ... oken ) if not user : raise HTTPException ( status_code = status . HTTP_401_UNAUTHORIZED , detail = "Invalid authentication credentials" , headers = { "WWW-Authenticate" : "Bearer" }, ) return user async def get_current_active_user ( current_user : Annotated ... oken ) if not user : raise HTTPException ( status_code = status . HTTP_401_UNAUTHORIZED , detail = "Invalid authentication credentials" , headers = { "WWW-Authenticate" : "Bearer" }, ) return user async def get_current_active_user ( current_user : Annotated ...
https://man.mtool.work/fastapi/0.115/tutorial/security/simple-oauth2/
Security Tools 7519
Security Tools When you need to declare dependencies with OAuth2 scopes you use Security() . But you still need to define what is the dependable, the callable that you pass as a parameter to Depends() or Security() . There are multiple tool ... t them from fastapi.security : from fastapi.security import ( APIKeyCookie , APIKeyHeader , APIKeyQuery , HTTPAuthorizationCredentials , HTTPBasic , HTTPBasicCredentials , HTTPBearer , HTTPDigest , OAuth2 , OAuth2AuthorizationCodeBearer , OAuth2PasswordBear ... Authentication Schemes ::: fastapi.security.HTTPBasic ::: fastapi.security.HTTPBearer ::: fastapi.security.HTTPDigest HTTP Credentials ::: fastapi.security.HTTPAuthorizationCredentials ::: fastapi.security.HTTPBasicCredentials OAuth2 Authentication ::: fast ...
https://man.mtool.work/fastapi/0.115/reference/security/
CORS (オリジン間リソース共有) 7464
CORS (オリジン間リソース共有) CORSまたは「オリジン間リソース共有」 は、ブラウザで実行されているフロントエンドにバックエンドと通信するJavaScriptコードがあり、そのバックエンドがフロントエンドとは異なる「オリジン」にある状況を指します。 オリジ ... , "http://localhost" , "http://localhost:8080" , ] app . add_middleware ( CORSMiddleware , allow_origins = origins , allow_credentials = True , allow_methods = [ "*" ], allow_headers = [ "*" ], ) @app . get ( "/" ) async def main (): return { "message" : "H ... ます。CORSリクエストでは、 Accept 、 Accept-Language 、 Content-Language 、 Content-Type ヘッダーが常に許可されます。 allow_credentials - オリジン間リクエストでCookieをサポートする必要があることを示します。デフォルトは False です。 expose_headers - ブラウザか ...
https://man.mtool.work/fastapi/0.115/tutorial/cors/
Custom Docs UI Static Assets (Self-Hosting) 7374
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 ... tegrate your API with an OAuth2 provider, you will be able to authenticate and come back to the API docs with the acquired credentials. And interact with it using the real OAuth2 authentication. Swagger UI will handle it behind the scenes for you, but it ne ... tegrate your API with an OAuth2 provider, you will be able to authenticate and come back to the API docs with the acquired credentials. And interact with it using the real OAuth2 authentication. Swagger UI will handle it behind the scenes for you, but it ne ...
https://man.mtool.work/fastapi/0.115/how-to/custom-docs-ui-assets/
Settings and Environment Variables 7338
Settings and Environment Variables Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . In many cases your application could need some external settings or configuratio ... ns, for example secret keys, database credentials, credentials for email services, etc. Most of these settings are variable (can change), like database URLs. And many could ...
https://man.mtool.work/fastapi/0.115/advanced/settings/
PREV 1 NEXT