Results of 1 - 10 of about 11 for access (0.010 sec.)
- OAuth2 scopes 12660
- 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
...# openssl rand -hex 32 SECRET_KEY = "09d25e094faa6ca2556c818166b7a9563b93f7099f6f0f4caa6cf63b88e8d3e7" ALGORITHM = "HS256" ACCESS_TOKEN_EXPIRE_MINUTES = 30 fake_users_db = { "johndoe" : { "username" : "johndoe" , "full_name" : "John Doe" , "email" : "j...rd" : "$2b$12$gSvqqUPvlXP2tfVFaWK1Be7DlH.PKZbv5H8KnzzVgXXbVxpva.pFm" , "disabled" : True , }, } class Token ( BaseModel ): access_token : str token_type : str class TokenData ( BaseModel ): username : str | None = None scopes : list [ str ] = [] class...not user : return False if not verify_password ( password , user . hashed_password ): return False return user def create_access_token ( data : dict , expires_delta : timedelta | None = None ): to_encode = data . copy () if expires_delta : expire = da... - https://man.mtool.work/fastapi/0.115/advanced/security/oauth2-scopes/
- パスワード(およびハッシュ化)によるOAuth2、JWTトークンによるBearer 12500
- パスワード(およびハッシュ化)によるOAuth2、JWTトークンによるBearer これでセキュリティの流れが全てわかったので、 JWT トークンと安全なパスワードのハッシュ化を使用して、実際にアプリケーションを安全にしてみましょう。 このコードは、アプリケーシ
...# openssl rand -hex 32 SECRET_KEY = "09d25e094faa6ca2556c818166b7a9563b93f7099f6f0f4caa6cf63b88e8d3e7" ALGORITHM = "HS256" ACCESS_TOKEN_EXPIRE_MINUTES = 30 fake_users_db = { "johndoe" : { "username" : "johndoe" , "full_name" : "John Doe" , "email" : "j...rd" : "$2b$12$EixZaYVK1fsbw1ZfbX3OXePaWxn96p36WQoeG6Lruj3vjPGga31lW" , "disabled" : False , } } class Token ( BaseModel ): access_token : str token_type : str class TokenData ( BaseModel ): username : Union [ str , None ] = None class User ( BaseModel...not user : return False if not verify_password ( password , user . hashed_password ): return False return user def create_access_token ( data : dict , expires_delta : Union [ timedelta , None ] = None ): to_encode = data . copy () if expires_delta : e... - https://man.mtool.work/fastapi/0.115/tutorial/security/oauth2-jwt/
- Simple OAuth2 with Password and Bearer 9033
- 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
...= user . hashed_password : raise HTTPException ( status_code = 400 , detail = "Incorrect username or password" ) return { "access_token" : user . username , "token_type" : "bearer" } @app . get ( "/users/me" ) async def read_users_me ( current_user : A...= user . hashed_password : raise HTTPException ( status_code = 400 , detail = "Incorrect username or password" ) return { "access_token" : user . username , "token_type" : "bearer" } @app . get ( "/users/me" ) async def read_users_me ( current_user : A...= user . hashed_password : raise HTTPException ( status_code = 400 , detail = "Incorrect username or password" ) return { "access_token" : user . username , "token_type" : "bearer" } @app . get ( "/users/me" ) async def read_users_me ( current_user : A... - https://man.mtool.work/fastapi/0.115/tutorial/security/simple-oauth2/
- Behind a Proxy 8339
- Behind a Proxy Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . In some situations, you might need to use a proxy server like Traefik or Nginx with a configuration
...00/app you will see the normal response: { "message" : "Hello World" , "root_path" : "/api/v1" } So, it won't expect to be accessed at http://127.0.0.1:8000/api/v1/app . Uvicorn will expect the proxy to access Uvicorn at http://127.0.0.1:8000/app , and...pi/v1/app and your server (e.g. Uvicorn) listens on http://127.0.0.1:8000 the proxy (without a stripped path prefix) would access Uvicorn at the same path: http://127.0.0.1:8000/api/v1/app . Testing locally with Traefik You can easily run the experimen...will see the normal response: { "message" : "Hello World" , "root_path" : "/api/v1" } Tip Notice that even though you are accessing it at http://127.0.0.1:8000/app it shows the root_path of /api/v1 , taken from the option --root-path . And now open th... - https://man.mtool.work/fastapi/0.115/advanced/behind-a-proxy/
- Using the Request Directly 8144
- Using the Request Directly Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . Up to now, you have been declaring the parts of the request that you need with their typ
...a, converting it and generating documentation for your API automatically. But there are situations where you might need to access the Request object directly. Details about the Request object As FastAPI is actually Starlette underneath, with a layer of...y Let's imagine you want to get the client's IP address/host inside of your path operation function . For that you need to access the request directly. Python 3.8+ from fastapi import FastAPI , Request app = FastAPI () @app . get ( "/items/ {item_id} "... - https://man.mtool.work/fastapi/0.115/advanced/using-request-directly/
- Request class 8072
- Request class You can declare a parameter in a path operation function or dependency to be of type Request and then you can access the raw request object directly, without any validation, etc. You can import it directly from fastapi : from
... - https://man.mtool.work/fastapi/0.115/reference/request/
- Status Codes 8001
- Status Codes You can import the status module from fastapi : from fastapi import status status is provided directly by Starlette. It contains a group of named constants (variables) with integer status codes. For example: 200: status.HTTP_20
...0_OK 403: status.HTTP_403_FORBIDDEN etc. It can be convenient to quickly access HTTP (and WebSocket) status codes in your app, using autocompletion for the name without having to remember the integer st... - https://man.mtool.work/fastapi/0.115/reference/status/
- Custom Request and APIRoute class 7752
- Custom Request and APIRoute class Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . In some cases, you may want to override the logic used by the Request and APIRout
...hanges in GzipRequest.body , the request body will be automatically decompressed when it is loaded by FastAPI when needed. Accessing the request body in an exception handler Tip To solve this same problem, it's probably a lot easier to use the body in...is example is still valid and it shows how to interact with the internal components. We can also use this same approach to access the request body in an exception handler. All we need to do is handle the request inside a try / except block: Python 3.8+... - https://man.mtool.work/fastapi/0.115/how-to/custom-request-and-route/
- CORS (オリジン間リソース共有) 7752
- CORS (オリジン間リソース共有) CORSまたは「オリジン間リソース共有」 は、ブラウザで実行されているフロントエンドにバックエンドと通信するJavaScriptコードがあり、そのバックエンドがフロントエンドとは異なる「オリジン」にある状況を指します。 オリジ
...600 です。 このミドルウェアは2種類のHTTPリクエストに応答します... CORSプリフライトリクエスト これらは、 Origin ヘッダーと Access-Control-Request-Method ヘッダーを持つ OPTIONS リクエストです。 この場合、ミドルウェアはリクエストを横取りし、適切なCORSヘッ... - https://man.mtool.work/fastapi/0.115/tutorial/cors/
- Custom Docs UI Static Assets (Self-Hosting) 7735
- 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
...cript and CSS could be useful if, for example, you need your app to keep working even while offline, without open Internet access, or in a local network. Here you'll see how to serve those files yourself, in the same FastAPI app, and configure the docs... - https://man.mtool.work/fastapi/0.115/how-to/custom-docs-ui-assets/