JWT
About 266 wordsLess than 1 minute
We wrote a JWT authorization middleware so every request can be authorized automatically. User information is also cached and parsed with Redis and a Rust library to keep the performance impact as low as possible.
API Authentication
The file backend/common/security/jwt.py includes the following code:
# JWT dependency injection
DependsJwtAuth = Depends(HTTPBearer())Add this dependency to an API function for quick JWT validation. It checks whether the request header contains a Bearer Token. Example:
@router.get('/hello', summary='你好', dependencies=[DependsJwtAuth])
async def hello():
...Token
The built-in token authorization follows rfc6750.
Swagger Login
This is a quick authorization method for debugging only. After the service starts, open the Swagger docs and use this debug endpoint to obtain a token quickly (no captcha required).
Captcha Login
You can obtain a token this way. In most cases this is better suited for frontend login authorization.
In fba we use fast_captcha to generate a base64 captcha, then return it via the API. You can convert base64 to an image online or use the frontend project to preview it as an image.

